File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1516,6 +1516,23 @@ def value_to_type(
15161516 # TODO(cretz): Want way to convert snake case to camel case?
15171517 return hint (** field_values )
15181518
1519+ # Pydantic model instance
1520+ # Pydantic users should use
1521+ # temporalio.contrib.pydantic.pydantic_data_converter, in which case a
1522+ # pydantic model instance will have been handled by the custom_converters at
1523+ # the start of this function. We retain the following for backwards
1524+ # compatibility with pydantic users who are not using contrib.pydantic, but
1525+ # this is deprecated.
1526+ parse_obj_attr = inspect .getattr_static (hint , "parse_obj" , None )
1527+ if isinstance (parse_obj_attr , classmethod ) or isinstance (
1528+ parse_obj_attr , staticmethod
1529+ ):
1530+ if not isinstance (value , dict ):
1531+ raise TypeError (
1532+ f"Cannot convert to { hint } , value is { type (value )} not dict"
1533+ )
1534+ return getattr (hint , "parse_obj" )(value )
1535+
15191536 # IntEnum
15201537 if inspect .isclass (hint ) and issubclass (hint , IntEnum ):
15211538 if not isinstance (value , int ):
You can’t perform that action at this time.
0 commit comments