Skip to content

Commit bacef82

Browse files
committed
Update pydantic hack
1 parent 64e95c5 commit bacef82

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

temporalio/converter.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)