You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rename sample pydantic_converter to pydanticv1_converter (and tests/packages/dep-group/etc) and make a new pydantic_converter sample that works with v2
Reacted by Jane Jeon, Nathan Price, Fidel Salgado, Gabriel, Tim Chan and Zev Isert
Until the sample is present, you can apply the concepts/approaches of the custom conversion to whatever is needed for v2 without applying the specific code
@JaneJeon I am using pydantic 2 with temporal just by changing pydantic_encoder to to_jsonable_python:
frompydantic_coreimportto_jsonable_python
...
# We let JSON conversion errors be thrown to callerreturnPayload(
metadata={"encoding": self.encoding.encode()},
data=json.dumps(value, separators=(",", ":"), sort_keys=True, default=to_jsonable_python).encode(),
)
Reacted by Nathan Price, Thiago, Charles Liu and GuilleI-EdMachina
@JaneJeon I am using pydantic 2 with temporal just by changing pydantic_encoder to to_jsonable_python:
frompydantic_coreimportto_jsonable_python
...
# We let JSON conversion errors be thrown to callerreturnPayload(
metadata={"encoding": self.encoding.encode()},
data=json.dumps(value, separators=(",", ":"), sort_keys=True, default=to_jsonable_python).encode(),
)
I am still getting
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'datetime.datetime'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.`
Activity
[-]Sample request: Pydantic v2[/-][+]Sample request: Pydantic v2 converter[/+]JaneJeon commentedon Jan 24, 2024
I am setting up a new project and I would really appreciate this for the "type safety without having to redefine attributes twice" benefits!
In particular, the
pydantic_encoderdoes not work anymore in v2: pydantic/pydantic#6652cretz commentedon Jan 24, 2024
Until the sample is present, you can apply the concepts/approaches of the custom conversion to whatever is needed for v2 without applying the specific code
slingshotsys commentedon Jan 26, 2024
@JaneJeon I am using pydantic 2 with temporal just by changing
pydantic_encodertoto_jsonable_python:SamZhangQingChuan commentedon Dec 30, 2024
I am still getting
Does it work on your side?
dandavison commentedon Apr 9, 2025
The SDK now contains official Pydantic v2 support, and the sample has been updated. This is the sample to follow for Pydantic v2: https://github.com/temporalio/samples-python/tree/main/pydantic_converter