File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -138,11 +138,7 @@ def cast_value(type_hint, value):
138138 pass
139139 else :
140140 if issubclass (type_hint , Model ):
141- if isinstance (value , dict ):
142- value = type_hint (** value )
143- break
144- else :
145- continue
141+ continue
146142
147143 value = type_hint (value )
148144 break
Original file line number Diff line number Diff line change @@ -71,6 +71,16 @@ def test_cast_value_model_none():
7171 assert actual is None
7272
7373
74+ def test_cast_value_model_dict ():
75+ example_class = ExampleClass ()
76+ type_hints = typing_get_type_hints (example_class )
77+ type_hint = type_hints ["a_model" ]
78+
79+ actual = cast_value (type_hint , {"id" : 1 })
80+
81+ assert actual == {"id" : 1 }
82+
83+
7484def test_cast_value_optional ():
7585 type_hints = typing_get_type_hints (ExampleClass ())
7686 type_hint = type_hints ["optional_model" ]
You can’t perform that action at this time.
0 commit comments