Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions temporalio/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,11 @@ def value_to_type(
origin = getattr(hint, "__origin__", hint)
type_args: tuple = getattr(hint, "__args__", ())

# using Dict[None,...] produces the type args (NoneType,...)
# using dict[None,...] produces the type args (None,...)
# Ensure we're always using NoneType over None
type_args = tuple(type(t) if t is None else t for t in type_args)

# Literal
if origin is Literal or origin is typing_extensions.Literal:
if value not in type_args:
Expand Down
5 changes: 1 addition & 4 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,8 @@ def fail(hint: Any, value: Any) -> None:
ok(dict[float, str], {1.0: "1"})
ok(dict[bool, str], {True: "1"})

# On a 3.10+ dict type, None isn't returned from a key. This is potentially a bug
ok(dict[None, str], {"null": "1"})

# Dict has a different value for None keys
ok(Dict[None, str], {None: "1"})
ok(dict[None, str], {None: "1"})

# Alias
ok(MyDataClassAlias, MyDataClass("foo", 5, SerializableEnum.FOO))
Expand Down
Loading