File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -1523,11 +1523,12 @@ def value_to_type(
15231523 # TODO(cretz): Want way to convert snake case to camel case?
15241524 return hint (** field_values )
15251525
1526- # If there is a @staticmethod or @classmethod parse_obj, we will use it.
1527- # This covers Pydantic models.
1528- parse_obj_attr = inspect .getattr_static (hint , "parse_obj" , None )
1529- if isinstance (parse_obj_attr , classmethod ) or isinstance (
1530- parse_obj_attr , staticmethod
1526+ # Use validate() method if present (suggests it is a Pydantic model)
1527+ pydantic_validate_attr = inspect .getattr_static (
1528+ hint , "validate" , None
1529+ ) or inspect .getattr_static (hint , "parse_obj" , None )
1530+ if isinstance (pydantic_validate_attr , classmethod ) or isinstance (
1531+ pydantic_validate_attr , staticmethod
15311532 ):
15321533 if not isinstance (value , dict ):
15331534 raise TypeError (
You can’t perform that action at this time.
0 commit comments