Skip to content

Commit 13791bb

Browse files
committed
Add regression test for NamedTuple with recursive bound
See python#18351 (review)
1 parent 9bf5169 commit 13791bb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test-data/unit/check-namedtuple.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,3 +1460,17 @@ Func = NamedTuple('Func', [
14601460
])
14611461
[builtins fixtures/tuple.pyi]
14621462
[typing fixtures/typing-namedtuple.pyi]
1463+
1464+
[case testGenericNamedTupleRecursiveBound]
1465+
from typing import Generic, NamedTuple, TypeVar
1466+
T = TypeVar("T", bound="NT")
1467+
class NT(NamedTuple, Generic[T]):
1468+
parent: T
1469+
item: int
1470+
1471+
def main(n: NT[T]) -> None:
1472+
reveal_type(n.parent) # N: Revealed type is "T`-1"
1473+
reveal_type(n.item) # N: Revealed type is "builtins.int"
1474+
1475+
[builtins fixtures/tuple.pyi]
1476+
[typing fixtures/typing-namedtuple.pyi]

0 commit comments

Comments
 (0)