Skip to content

Commit

Permalink
Add regression test for NamedTuple with recursive bound
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Jan 1, 2025
1 parent 9bf5169 commit 13791bb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test-data/unit/check-namedtuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -1460,3 +1460,17 @@ Func = NamedTuple('Func', [
])
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-namedtuple.pyi]

[case testGenericNamedTupleRecursiveBound]
from typing import Generic, NamedTuple, TypeVar
T = TypeVar("T", bound="NT")
class NT(NamedTuple, Generic[T]):
parent: T
item: int

def main(n: NT[T]) -> None:
reveal_type(n.parent) # N: Revealed type is "T`-1"
reveal_type(n.item) # N: Revealed type is "builtins.int"

[builtins fixtures/tuple.pyi]
[typing fixtures/typing-namedtuple.pyi]

0 comments on commit 13791bb

Please sign in to comment.