@@ -116,13 +116,13 @@ def __init__(self, key_type = None):
116116 global _simple_type_remap
117117 if key_type in _simple_type_remap :
118118 key_type = _simple_type_remap [key_type ]
119-
119+
120120 if not isinstance (key_type , (Int64 , String )):
121121 raise TypeError ("Key type for dictionary must be either string or integer." )
122122
123123 self .key_type = key_type
124124
125- _DatatypeBase .__init__ (self , "Dictionary" , "Dictionary({})" .format (repr (self .key_type ), None ) )
125+ _DatatypeBase .__init__ (self , "Dictionary" , "Dictionary({})" .format (repr (self .key_type )) , None )
126126
127127
128128_simple_type_remap = {int : Int64 (),
@@ -140,19 +140,19 @@ def _is_valid_datatype(datatype_instance):
140140 """
141141 Returns true if datatype_instance is a valid datatype object and false otherwise.
142142 """
143-
143+
144144 # Remap so we can still use the python types for the simple cases
145145 global _simple_type_remap
146146 if datatype_instance in _simple_type_remap :
147147 return True
148-
148+
149149 # Now set the protobuf from this interface.
150150 if isinstance (datatype_instance , (Int64 , Double , String , Array )):
151151 return True
152152
153153 elif isinstance (datatype_instance , Dictionary ):
154154 kt = datatype_instance .key_type
155-
155+
156156 if isinstance (kt , (Int64 , String )):
157157 return True
158158
@@ -161,28 +161,28 @@ def _is_valid_datatype(datatype_instance):
161161
162162def _normalize_datatype (datatype_instance ):
163163 """
164- Translates a user specified datatype to an instance of the ones defined above.
165-
164+ Translates a user specified datatype to an instance of the ones defined above.
165+
166166 Valid data types are passed through, and the following type specifications
167167 are translated to the proper instances:
168168
169169 str, "String" -> String()
170170 int, "Int64" -> Int64()
171171 float, "Double" -> Double()
172172
173- If a data type is not recognized, then an error is raised.
173+ If a data type is not recognized, then an error is raised.
174174 """
175175 global _simple_type_remap
176176 if datatype_instance in _simple_type_remap :
177177 return _simple_type_remap [datatype_instance ]
178-
178+
179179 # Now set the protobuf from this interface.
180180 if isinstance (datatype_instance , (Int64 , Double , String , Array )):
181181 return datatype_instance
182182
183183 elif isinstance (datatype_instance , Dictionary ):
184184 kt = datatype_instance .key_type
185-
185+
186186 if isinstance (kt , (Int64 , String )):
187187 return datatype_instance
188188
@@ -217,7 +217,7 @@ def _set_datatype(proto_type_obj, datatype_instance):
217217 proto_type_obj .dictionaryType .MergeFromString (b'' )
218218
219219 kt = datatype_instance .key_type
220-
220+
221221 if isinstance (kt , Int64 ):
222222 proto_type_obj .dictionaryType .int64KeyType .MergeFromString (b'' )
223223 elif isinstance (kt , String ):
@@ -229,4 +229,3 @@ def _set_datatype(proto_type_obj, datatype_instance):
229229 raise TypeError ("Datatype parameter not recognized; must be an instance "
230230 "of datatypes.{Double, Int64, String, Dictionary, Array}, or "
231231 "python int, float, or str types." )
232-
0 commit comments