File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1213,6 +1213,27 @@ def test_chaining(d: Config) -> None:
12131213[typing fixtures/typing-typeddict.pyi]
12141214
12151215
1216+ [case testTypedDictGetWithNestedUnionOfTypedDicts]
1217+ # https://github.com/python/mypy/issues/19902
1218+ from typing import TypedDict, Union
1219+ from typing_extensions import TypeAlias, NotRequired
1220+ class A(TypedDict):
1221+ key: NotRequired[int]
1222+
1223+ class B(TypedDict):
1224+ key: NotRequired[int]
1225+
1226+ class C(TypedDict):
1227+ key: NotRequired[int]
1228+
1229+ A_or_B: TypeAlias = Union[A, B]
1230+ A_or_B_or_C: TypeAlias = Union[A_or_B, C]
1231+
1232+ def test(d: A_or_B_or_C) -> None:
1233+ reveal_type(d.get("key")) # N: Revealed type is "Union[builtins.int, None]"
1234+ [builtins fixtures/dict.pyi]
1235+ [typing fixtures/typing-typeddict.pyi]
1236+
12161237-- Totality (the "total" keyword argument)
12171238
12181239[case testTypedDictWithTotalTrue]
You can’t perform that action at this time.
0 commit comments