Title: Potential false positives with `ParamSpec "P" is unbound` after upgrading from 1.14.1 to 1.15.0 · Issue #18745 · python/mypy · GitHub
Open Graph Title: Potential false positives with `ParamSpec "P" is unbound` after upgrading from 1.14.1 to 1.15.0 · Issue #18745 · python/mypy
X Title: Potential false positives with `ParamSpec "P" is unbound` after upgrading from 1.14.1 to 1.15.0 · Issue #18745 · python/mypy
Description: Bug Report After upgrading to mypy 1.15.0 from mypy 1.14.1, I am now experiencing hundreds of new ParamSpec "P" is unbound errors. I imagine quite a few of these are valid, and for my use-case, I'm going to just swap how I'm (incorrectly...
Open Graph Description: Bug Report After upgrading to mypy 1.15.0 from mypy 1.14.1, I am now experiencing hundreds of new ParamSpec "P" is unbound errors. I imagine quite a few of these are valid, and for my use-case, I'm...
X Description: Bug Report After upgrading to mypy 1.15.0 from mypy 1.14.1, I am now experiencing hundreds of new ParamSpec "P" is unbound errors. I imagine quite a few of these are valid, and for my use...
Opengraph URL: https://github.com/python/mypy/issues/18745
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Potential false positives with `ParamSpec \"P\" is unbound` after upgrading from 1.14.1 to 1.15.0","articleBody":"\u003c!--\nIf you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form instead.\nPlease consider:\n\n- checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html\n- searching our issue tracker: https://github.com/python/mypy/issues to see if it's already been reported\n- asking on gitter chat: https://gitter.im/python/typing\n-->\n\n**Bug Report**\n\n\u003c!--\nIf you're reporting a problem with a specific library function, the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues\n\nIf the project you encountered the issue in is open source, please provide a link to the project.\n-->\n\nAfter upgrading to mypy 1.15.0 from mypy 1.14.1, I am now experiencing hundreds of new `ParamSpec \"P\" is unbound` errors. I imagine quite a few of these are valid, and for my use-case, I'm going to just swap how I'm (incorrectly) using ParamSpec (`*args: P.args, **kwargs: P.kwargs`, where P is not bound to the function in many of these cases) with a separate appropriate version (`*args: object, **kwargs: object`; I don't want to use `Any` and turn off type-checking entirely). However, I am running into cases where I think `P` is bound, and yet still throwing a MyPy exception.\n\nFrom what I can tell, the [PR](https://github.com/python/mypy/pull/18278) which added this update may have missed my specific use-case. @sterliakov, as the author of this PR, any thoughts on my specific example? Also, would love to hear your thoughts on switching out unbound `*args: P.args` to `*args: object` instead of `*args: Any`. Thanks!\n\nExample and playground gist below.\n\n**To Reproduce**\n\n```python\nfrom collections.abc import Callable\nfrom functools import wraps\nfrom typing import ParamSpec, TypeAlias\n\nfrom flask import Response\nfrom flask_login import current_user\n\n\nP = ParamSpec(\"P\")\nFlaskRestfulHTTPMethodResponse: TypeAlias = tuple[Response | dict, int]\nFlaskRestfulHTTPMethod: TypeAlias = Callable[P, FlaskRestfulHTTPMethodResponse]\n\n\ndef check_auth(f: FlaskRestfulHTTPMethod) -> FlaskRestfulHTTPMethod:\n @wraps(f)\n def wrapper(*args: P.args, **kwargs: P.kwargs) -> FlaskRestfulHTTPMethodResponse:\n if not current_user.is_authenticated:\n return {\"message\": \"Unauthorized\"}, 401\n return f(*args, **kwargs)\n\n return wrapper\n\n```\n\n[Playground link](https://mypy-play.net/?mypy=1.15.0&python=3.11&gist=90eb6769565457c2934d7719e53ccb0b)\n[Gist link](https://gist.github.com/mypy-play/90eb6769565457c2934d7719e53ccb0b)\n\n**Expected Behavior**\n\n\u003c!--\nHow did you expect mypy to behave? It’s fine if you’re not sure your understanding is correct.\nWrite down what you thought would happen. If you expected no errors, delete this section.\n-->\n\nShould pass the mypy checker (as it does in mypy 1.14.1).\n\n**Actual Behavior**\n\n\u003c!-- What went wrong? Paste mypy's output. -->\n\nParamSpec \"P\" is unbound [valid-type]\n\n**Your Environment**\n\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\n\n- Mypy version used: 1.15.0\n- Mypy command-line flags: N/A\n- Mypy configuration options from `mypy.ini` (and other config files): `strict = True`\n- Python version used: 3.11.4\n\n\u003c!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->\n","author":{"url":"https://github.com/alichaudry","@type":"Person","name":"alichaudry"},"datePublished":"2025-02-27T21:49:18Z","url":"https://github.com/python/mypy/issues/18745"}
| 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:ca976109-3c3a-5107-eaf0-99ebada9a048 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9AD8:CF959:2B06E6D:38649F1:6B000AEE |
| html-safe-nonce | 4cca684703e74f248e0450cfe515a600c4f4879f911b72c9905660621c497c0e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUQ4OkNGOTU5OjJCMDZFNkQ6Mzg2NDlGMTo2QjAwMEFFRSIsInZpc2l0b3JfaWQiOiIyNjI3OTA3MDUyMTY0MzUyNzUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f9397889474dbfd12a0307a1033bdf50976b3798f7c6facad43b4d33e0a47e31 |
| hovercard-subject-tag | issue:2885679184 |
| 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/18745/issue_layout |
| twitter:image | https://opengraph.githubassets.com/af1ffcee84974726683bc2c46355b12ab6ceb3f472befc7be8c30ebbc5d0bd84/python/mypy/issues/18745 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/af1ffcee84974726683bc2c46355b12ab6ceb3f472befc7be8c30ebbc5d0bd84/python/mypy/issues/18745 |
| og:image:alt | Bug Report After upgrading to mypy 1.15.0 from mypy 1.14.1, I am now experiencing hundreds of new ParamSpec "P" is unbound errors. I imagine quite a few of these are valid, and for my use-case, I'm... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alichaudry |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width