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
Use a dataclass as activity input with a field of type Literal["success", "failure"]
Describe the bug
When using the Literal type_hint, value_to_type shows an error
Unserializable type during conversion: typing.Literal['success', 'failure']
This seems to happen because temporal checks referential equality with Literal from typing_extensions, but typing_extensions doesnt reuse the one from typing unless 3.10+
Workaroundable by using Literal from typing_extensions, but this isnt documented. It would be nice if temporal just used the normal Literal from typing (and perhaps replicate the deduplication logic in 3.10+)
Minimal Reproduction
python3.9 -m venv venv
venv/bin/pip install temporalio
venv/bin/python
from temporalio.converter import value_to_type
from typing import *
value_to_type(Literal["a", "b"], "a")
Environment/Versions
OS and processor: [e.g. M1 Mac, x86 Windows, Linux]
Temporal Version: [e.g. 1.14.0?] and/or SDK version
Are you using Docker or Kubernetes or building Temporal from source?
Additional context
The text was updated successfully, but these errors were encountered:
raiseTypeError(f"Value {value} not in literal values {type_args}")
returnvalue
the dedupe isn't really needed I think since we just do a validation check on the collection (regardless of whether it's in there multiple times) before accepting the raw value.
maciejdudko
added a commit
to maciejdudko/temporal-sdk-python
that referenced
this issue
May 14, 2025
What are you really trying to do?
Use a dataclass as activity input with a field of type
Literal["success", "failure"]
Describe the bug
When using the Literal type_hint, value_to_type shows an error
This seems to happen because temporal checks referential equality with Literal from typing_extensions, but typing_extensions doesnt reuse the one from typing unless 3.10+
Workaroundable by using Literal from typing_extensions, but this isnt documented. It would be nice if temporal just used the normal Literal from typing (and perhaps replicate the deduplication logic in 3.10+)
Minimal Reproduction
Environment/Versions
Additional context
The text was updated successfully, but these errors were encountered: