Title: `NamedTuple` parametrized with a `ParamSpec` can't be used as an annotation · Issue #19658 · python/mypy · GitHub
Open Graph Title: `NamedTuple` parametrized with a `ParamSpec` can't be used as an annotation · Issue #19658 · python/mypy
X Title: `NamedTuple` parametrized with a `ParamSpec` can't be used as an annotation · Issue #19658 · python/mypy
Description: Bug Report 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 d...
Open Graph Description: Bug Report 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-i...
X Description: Bug Report 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 ...
Opengraph URL: https://github.com/python/mypy/issues/19658
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`NamedTuple` parametrized with a `ParamSpec` can't be used as an annotation","articleBody":"**Bug Report**\n\n`NamedTuple` parametrized with a `ParamSpec` can't be used as an annotation.\n\nIt's probably easiest to look at my repro to see what I mean.\n\nI 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.\n\n**To Reproduce**\n\n```python\nfrom collections.abc import Callable\nfrom typing import NamedTuple\n\n\nclass T[**P](NamedTuple):\n plugin: Callable[P, int]\n\n\ndef f[**P](a: T[P]) -> None:\n pass\n```\n\nI note that if I change `T` from a `NamedTuple` to a `dataclass`, there's no error.\n\n**Expected Behavior**\n\n```shell\n$ mypy t.py \nSuccess: no issues found in 1 source file\n```\n\n**Actual Behavior**\n\n```shell\n$ mypy t.py\nt.py:9: error: Invalid location for ParamSpec \"P\" [valid-type]\nt.py:9: note: You can use ParamSpec as the first argument to Callable, e.g., \"Callable[P, int]\"\nFound 1 error in 1 file (checked 1 source file)\n```\n\nThe error is referring to the `T[P]` annotation.\n\n**Your Environment**\n\n- Mypy version used: `mypy 1.17.1 (compiled: yes)`\n- Mypy command-line flags: `mypy`\n- Mypy configuration options from `mypy.ini` (and other config files): none\n- Python version used: `Python 3.13.5`\n","author":{"url":"https://github.com/sbrudenell","@type":"Person","name":"sbrudenell"},"datePublished":"2025-08-14T06:44:32Z","url":"https://github.com/python/mypy/issues/19658"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4235cb1c-b4da-fcdf-8314-4f6dd4cd66dc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D74A:3EE8F1:15B6FB6:1CA2546:6B001566 |
| html-safe-nonce | 11d709945b7b9f2c4edf1f676ae4e25cbfcd04de6e8d7218efc52569d59c41cd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzRBOjNFRThGMToxNUI2RkI2OjFDQTI1NDY6NkIwMDE1NjYiLCJ2aXNpdG9yX2lkIjoiNjU1NDE3MDc0NjA0MDQ4OTMxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ad8a397e41d3df24255110dd205452681f0840f22e7c359536c4315bf8d806d4 |
| hovercard-subject-tag | issue:3320992652 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/19658/issue_layout |
| twitter:image | https://opengraph.githubassets.com/599cfc35a57e95ad1e0bdadaec27bc4c689851c815e0298ec2b3bc7cb2dd261b/python/mypy/issues/19658 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/599cfc35a57e95ad1e0bdadaec27bc4c689851c815e0298ec2b3bc7cb2dd261b/python/mypy/issues/19658 |
| og:image:alt | Bug Report 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-i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sbrudenell |
| hostname | github.com |
| expected-hostname | github.com |
| None | a2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 70121d4e855ee0bb7b75cf15d061d91f8863c0f8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width