Title: False postives when decorating functions with signature that uses ParamSpec within a decoarator · Issue #12909 · python/mypy · GitHub
Open Graph Title: False postives when decorating functions with signature that uses ParamSpec within a decoarator · Issue #12909 · python/mypy
X Title: False postives when decorating functions with signature that uses ParamSpec within a decoarator · Issue #12909 · python/mypy
Description: Bug Report When using a decorator on the decorated function within the definition of another decorator, mypy reports false positives. To Reproduce from typing import Callable, TypeVar from typing_extensions import ParamSpec, Concatenate ...
Open Graph Description: Bug Report When using a decorator on the decorated function within the definition of another decorator, mypy reports false positives. To Reproduce from typing import Callable, TypeVar from typing_e...
X Description: Bug Report When using a decorator on the decorated function within the definition of another decorator, mypy reports false positives. To Reproduce from typing import Callable, TypeVar from typing_e...
Opengraph URL: https://github.com/python/mypy/issues/12909
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False postives when decorating functions with signature that uses ParamSpec within a decoarator","articleBody":"\u003c!--\r\n If you're new to mypy and you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form\r\n instead.\r\n Please also consider:\r\n\r\n - checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html\r\n - searching our issue tracker: https://github.com/python/mypy/issues to see if\r\n it's already been reported\r\n - asking on gitter chat: https://gitter.im/python/typing\r\n-->\r\n\r\n**Bug Report**\r\n\r\n\u003c!--\r\nNote: If the problem you are reporting is about a specific library function, then the typeshed tracker is better suited\r\nfor this report: https://github.com/python/typeshed/issues\r\n-->\r\n\r\nWhen using a decorator on the decorated function within the definition of another decorator, mypy reports false positives.\r\n\r\n**To Reproduce**\r\n\r\n```python3\r\nfrom typing import Callable, TypeVar\r\nfrom typing_extensions import ParamSpec, Concatenate\r\n\r\nP = ParamSpec(\"P\")\r\nT = TypeVar(\"T\")\r\n\r\n\r\ndef identity(func: Callable[P, T]) -> Callable[P, T]:\r\n def _wrapped(*args: P.args, **kwargs: P.kwargs) -> T:\r\n return func(*args, **kwargs)\r\n\r\n return _wrapped\r\n\r\n\r\ndef int_identity(func: Callable[Concatenate[int, P], T]) -> Callable[Concatenate[int, P], T]:\r\n # identify should preserve the signature of _wrapped\r\n # error: Argument 1 to \"identity\" has incompatible type \"Callable[[Arg(int, 'number'), **P], T]\"; expected \"Callable[[Arg(int, 'number'), **P], T]\"\r\n @identity\r\n def _wrapped(number: int, *args: P.args, **kwargs: P.kwargs) -> T:\r\n return func(number, *args, **kwargs)\r\n\r\n return _wrapped\r\n```\r\n\r\n**Expected Behavior**\r\n\r\n\u003c!--\r\n How did you expect your project to behave?\r\n It’s fine if you’re not sure your understanding is correct.\r\n Write down what you thought would happen. If you just expected no errors, you can delete this section.\r\n-->\r\n\r\nThe code should pass type-check with no errors.\r\n\r\n**Actual Behavior**\r\n\r\n\u003c!--\r\n Did something go wrong?\r\n Is something broken, or not behaving as you expected?\r\n-->\r\n\r\nGot error:\r\n`error: Argument 1 to \"identity\" has incompatible type \"Callable[[Arg(int, 'number'), **P], T]\"; expected \"Callable[[Arg(int, 'number'), \r\n**P], T]\"`\r\n\r\n**Your Environment**\r\n\r\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\n- Mypy version used: 0.960\r\n- Mypy command-line flags: `--strict`\r\n- Python version used: Python 3.8.10\r\n- Operating system and version: WSL2 - Ubuntu 20.04","author":{"url":"https://github.com/PIG208","@type":"Person","name":"PIG208"},"datePublished":"2022-05-30T18:38:10Z","url":"https://github.com/python/mypy/issues/12909"}
| 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:4a3ebfde-a0f5-70c1-1c00-fcffa1bca682 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C0D0:4D1C6:1F7A768:2AC1B67:6B001B43 |
| html-safe-nonce | 079f2502dac5eb36b881181fe86fedd9ca1ee1331855ab359e7403dabfa08f70 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEQwOjREMUM2OjFGN0E3Njg6MkFDMUI2Nzo2QjAwMUI0MyIsInZpc2l0b3JfaWQiOiI1NDQwODYzOTQ5NTk3NzExMTcxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1922b93be97f16c611347e221484df1d423c960a35489391c076e09dec3ea923 |
| hovercard-subject-tag | issue:1253034347 |
| 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/12909/issue_layout |
| twitter:image | https://opengraph.githubassets.com/59f949d2809545e9b4ddf99c81556da0cd849c166bf072d6cc59fb7f165dbf34/python/mypy/issues/12909 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/59f949d2809545e9b4ddf99c81556da0cd849c166bf072d6cc59fb7f165dbf34/python/mypy/issues/12909 |
| og:image:alt | Bug Report When using a decorator on the decorated function within the definition of another decorator, mypy reports false positives. To Reproduce from typing import Callable, TypeVar from typing_e... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | PIG208 |
| 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