Skip to content

Commit 97e6f47

Browse files
committed
Add one more test as suggested in python#3990
1 parent c1a63ec commit 97e6f47

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎test-data/unit/check-incremental.test‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,6 +2952,19 @@ def foo(a: int, b: int) -> str:
29522952
[out2]
29532953
tmp/b.py:2: error: Incompatible return value type (got "int", expected "str")
29542954

2955+
[case testForwardNamedTupleToUnionWithOtherNamedTUple]
2956+
from typing import NamedTuple, Union
2957+
2958+
class Person(NamedTuple):
2959+
name: Union[str, "NamePair"]
2960+
2961+
class NamePair(NamedTuple):
2962+
first: str
2963+
last: str
2964+
2965+
Person(name=NamePair(first="John", last="Doe"))
2966+
[out]
2967+
29552968
-- Some crazy selef-referential named tuples, types dicts, and aliases
29562969
-- to be sure that everything can be _serialized_ (i.e. ForwardRef's are removed)
29572970

0 commit comments

Comments
 (0)