@@ -167,31 +167,32 @@ def check_type(var_name, value, expect_type, type_value):
167167 raise CheckTypeError (
168168 "For " + var_name + " : Dict expected, " + type_value + " given"
169169 )
170- # Check type of value element
170+ # Check type of value element (None or expected type)
171171 expect_type = expect_type [1 :- 1 ]
172172 for key , element in value .items ():
173- type_value = type (element ).__name__
174- # Check if it's the expected type
175- if not type_value == expect_type :
176- # Check if object inherit from the expected type
177- mother = element .__class__ .__bases__ # List of inherited class
178- find = False # Store the result of the research
179- while mother != (): # Every class inherit from FrozenClass
180- if mother [0 ].__name__ == expect_type :
181- find = True
182- break
183- else :
184- mother = mother [0 ].__bases__
185- if not find : # Not the good type
186- raise CheckTypeError (
187- "For "
188- + var_name
189- + " : "
190- + expect_type
191- + " expected, "
192- + type_value
193- + " given"
194- )
173+ if element is not None :
174+ type_value = type (element ).__name__
175+ # Check if it's the expected type
176+ if not type_value == expect_type :
177+ # Check if object inherit from the expected type
178+ mother = element .__class__ .__bases__ # List of inherited class
179+ find = False # Store the result of the research
180+ while mother != (): # Every class inherit from FrozenClass
181+ if mother [0 ].__name__ == expect_type :
182+ find = True
183+ break
184+ else :
185+ mother = mother [0 ].__bases__
186+ if not find : # Not the good type
187+ raise CheckTypeError (
188+ "For "
189+ + var_name
190+ + " : "
191+ + expect_type
192+ + " expected, "
193+ + type_value
194+ + " given"
195+ )
195196 elif "." in expect_type :
196197 # Imported type
197198 module_to_import = import_module (expect_type [: expect_type .rfind ("." )])
0 commit comments