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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ to include examples, links to docs, or any other relevant information.

### Fixed

- Fixed JSON conversion of `dict[None, T]` type hints to restore `None` keys.

### Security

## [1.30.0] - 2026-07-01
Expand Down
6 changes: 4 additions & 2 deletions temporalio/converter/_payload_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,10 @@ def value_to_type(
origin, "__optional_keys__", None
):
per_key_types = get_type_hints(origin)
key_type = (
type_args[0]
key_type: Any = (
type(None)
if len(type_args) > 0 and type_args[0] is None
else type_args[0]
if len(type_args) > 0
and type_args[0] is not Any
and not isinstance(type_args[0], TypeVar)
Expand Down
5 changes: 1 addition & 4 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,7 @@ 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"}) # type:ignore[reportDeprecated]

# Alias
Expand Down