Title: Incompatible return type for wrappers around `ParamSpec`-generics · Issue #12276 · python/mypy · GitHub
Open Graph Title: Incompatible return type for wrappers around `ParamSpec`-generics · Issue #12276 · python/mypy
X Title: Incompatible return type for wrappers around `ParamSpec`-generics · Issue #12276 · python/mypy
Description: Bug Report When creating a helper function around a ParamSpec-based generic I recently stumbled upon a spurious "Incompatible return value type" error. Mypy seems to (internally) represent CustomCallable[~P]-parametrized generics as Cust...
Open Graph Description: Bug Report When creating a helper function around a ParamSpec-based generic I recently stumbled upon a spurious "Incompatible return value type" error. Mypy seems to (internally) represent CustomCa...
X Description: Bug Report When creating a helper function around a ParamSpec-based generic I recently stumbled upon a spurious "Incompatible return value type" error. Mypy seems to (internally) represen...
Opengraph URL: https://github.com/python/mypy/issues/12276
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incompatible return type for wrappers around `ParamSpec`-generics","articleBody":"**Bug Report**\r\n\r\nWhen creating a helper function around a `ParamSpec`-based generic I recently stumbled upon a spurious \"Incompatible return value type\" error. \r\n\r\nMypy seems to (internally) represent `CustomCallable[~P]`-parametrized generics as `CustomCallable[Callable[P, None]]` instead of just `CustomCallable[P]`. This internal representation can be exposed in certain situations though, resulting in false positives such as in the example below.\r\n\r\n**To Reproduce**\r\n\r\n``` python\r\nfrom collections.abc import Callable\r\nfrom typing import Generic, Any\r\nfrom typing_extensions import ParamSpec\r\n\r\nP = ParamSpec(\"P\")\r\n\r\n\r\nclass CustomCallable(Generic[P]):\r\n def __init__(self, func: Callable[P, Any]) -> None: ...\r\n def __call__(self, *args: P.args, **kwargs: P.kwargs) -> None: ...\r\n\r\n\r\ndef func(func: Callable[P, Any]) -> CustomCallable[P]:\r\n # error: Incompatible return value type (got \"CustomCallable[Callable[P, None]]\", expected \"CustomCallable[P]\")\r\n return CustomCallable(func)\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: mypy 0.931\r\n- Mypy command-line flags: n.a.\r\n- Mypy configuration options from `mypy.ini` (and other config files): n.a.\r\n- Python version used: 3.10.2\r\n- Operating system and version: Windows 10 (build 19044.1526)","author":{"url":"https://github.com/BvB93","@type":"Person","name":"BvB93"},"datePublished":"2022-03-02T16:43:31Z","url":"https://github.com/python/mypy/issues/12276"}
| 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:177e7056-c0c0-6bdd-1f66-a948451dcdd8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84F0:33DDEF:1E10744:2913979:6B001D25 |
| html-safe-nonce | d2bfbc4847a17d0425cea9594b3cfc6f3de2991a8565d9f96c66b3254e7eb26f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEYwOjMzRERFRjoxRTEwNzQ0OjI5MTM5Nzk6NkIwMDFEMjUiLCJ2aXNpdG9yX2lkIjoiMTUxNDYzOTAxMzUwNjQ1Njg2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bc3be429ff1ab6056011a1d8142c636f550442d61dee9291d9c6fa84a75cf046 |
| hovercard-subject-tag | issue:1157437582 |
| 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/12276/issue_layout |
| twitter:image | https://opengraph.githubassets.com/562230e11720661050d584dabc9b9992a33c8fa19c23345f11089a614ec47e9d/python/mypy/issues/12276 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/562230e11720661050d584dabc9b9992a33c8fa19c23345f11089a614ec47e9d/python/mypy/issues/12276 |
| og:image:alt | Bug Report When creating a helper function around a ParamSpec-based generic I recently stumbled upon a spurious "Incompatible return value type" error. Mypy seems to (internally) represent CustomCa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | BvB93 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width