From 9baddc22aaf59ea78cf9ee0c9251261b9cfcc4b7 Mon Sep 17 00:00:00 2001 From: Alex Mazzeo Date: Tue, 9 Dec 2025 15:33:00 -0800 Subject: [PATCH] Ensure we're using NoneType instead of None when inspecting type args in converter --- temporalio/converter.py | 5 +++++ tests/test_converter.py | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/temporalio/converter.py b/temporalio/converter.py index 8af1e1dc6..3f89f6dfe 100644 --- a/temporalio/converter.py +++ b/temporalio/converter.py @@ -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: diff --git a/tests/test_converter.py b/tests/test_converter.py index 138ea65b5..f1f5473cc 100644 --- a/tests/test_converter.py +++ b/tests/test_converter.py @@ -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))