Skip to content

Commit

Permalink
Add regression test for NamedTuple with recursive bound (#18399)
Browse files Browse the repository at this point in the history
See
#18351 (review)

Co-authored-by: ilevkivskyi
  • Loading branch information
hauntsaninja authored Jan 6, 2025
1 parent bac9984 commit 02c07c8
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 02c07c8

Please sign in to comment.