Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit35347b9

Browse files
Fix: Resolve TypeError in value_to_type on Python 3.13 (issuetemporalio#1188) (temporalio#1189)
* Fix: Resolve TypeError in value_to_type on Python 3.13 (issuetemporalio#1188)* fix poe linting* replace newtype check 'temporalio#1189 (comment)'---------Co-authored-by: tconley1428 <tconley1428@gmail.com>
1 parent660ac2b commit35347b9

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

‎temporalio/converter.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,9 +1764,7 @@ def value_to_type(
17641764
elifkey_typeistype(None):
17651765
key= {"null":None}[key]
17661766

1767-
# Can't call isinstance if key_type is a newtype
1768-
is_newtype=getattr(key_type,"__supertype__",None)
1769-
ifis_newtypeornotisinstance(key,key_type):
1767+
ifnotisinstance(key_type,type)ornotisinstance(key,key_type):
17701768
key=value_to_type(key_type,key,custom_converters)
17711769
exceptExceptionaserr:
17721770
raiseTypeError(

‎tests/test_converter.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,3 +671,29 @@ async def test_json_type_converter():
671671
assert [addr,addr]== (
672672
awaitcustom_conv.decode([list_payload], [List[ipaddress.IPv4Address]])
673673
)[0]
674+
675+
676+
deftest_value_to_type_literal_key():
677+
# The type for the dictionary's *key*:
678+
KeyHint=Literal[
679+
"Key1",
680+
"Key2",
681+
]
682+
683+
# The type for the dictionary's *value* (the inner dict):
684+
InnerKeyHint=Literal[
685+
"Inner1",
686+
"Inner2",
687+
]
688+
InnerValueHint=str|int|float|None
689+
ValueHint=dict[InnerKeyHint,InnerValueHint]
690+
691+
# The full type hint for the mapping:
692+
hint_with_bug=dict[KeyHint,ValueHint]
693+
694+
# A value that uses one of the literal keys:
695+
value_to_convert= {"Key1": {"Inner1":123.45,"Inner2":10}}
696+
custom_converters:Sequence[JSONTypeConverter]= []
697+
698+
# Function executes without error
699+
value_to_type(hint_with_bug,value_to_convert,custom_converters)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp