[ty] Fix error message for invalidly providing type arguments to NamedTuple when it occurs in a type expression (#19940)

This commit is contained in:
Alex Waygood 2025-08-16 18:45:15 +01:00 committed by GitHub
parent 527a690a73
commit f4d8826428
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -312,6 +312,9 @@ def expects_named_tuple(x: typing.NamedTuple):
def _(y: type[typing.NamedTuple]):
reveal_type(y) # revealed: @Todo(unsupported type[X] special form)
# error: [invalid-type-form] "Special form `typing.NamedTuple` expected no type parameter"
def _(z: typing.NamedTuple[int]): ...
```
Any instance of a `NamedTuple` class can therefore be passed for a function parameter that is