Skip to content

Commit 02c07c8

Browse files
authored
Add regression test for NamedTuple with recursive bound (#18399)
See #18351 (review) Co-authored-by: ilevkivskyi
1 parent bac9984 commit 02c07c8

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)