You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NamedTuple parametrized with a ParamSpec can't be used as an annotation #19658
NamedTuple parametrized with a ParamSpec can't be used as an annotation.
It's probably easiest to look at my repro to see what I mean.
I know that generic support for NamedTuple is new-ish as of 3.11, but I couldn't find any documentation that says ParamSpec is somehow still unsupported.
I note that if I change T from a NamedTuple to a dataclass, there's no error.
Expected Behavior
$ mypy t.py
Success: no issues found in 1 source file
Actual Behavior
$ mypy t.py
t.py:9: error: Invalid location for ParamSpec "P" [valid-type]
t.py:9: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]"
Found 1 error in 1 file (checked 1 source file)
The error is referring to the T[P] annotation.
Your Environment
Mypy version used: mypy 1.17.1 (compiled: yes)
Mypy command-line flags: mypy
Mypy configuration options from mypy.ini (and other config files): none
Activity
sterliakov commentedon Aug 14, 2025
mypy/mypy/typeanal.py
Lines 865 to 881 in b17027e
I guess the answer to this "TODO" (and for TypedDict below too) should be "yes"...