Title: Regression in 1.2.0: callback protocol with Callable and Concatenate · Issue #15065 · python/mypy · GitHub
Open Graph Title: Regression in 1.2.0: callback protocol with Callable and Concatenate · Issue #15065 · python/mypy
X Title: Regression in 1.2.0: callback protocol with Callable and Concatenate · Issue #15065 · python/mypy
Description: Bug Report The code below passed with mypy 1.1.1 but not in 1.2.0 To Reproduce from typing import Concatenate, Callable, ParamSpec, Protocol P = ParamSpec("P") class Decorator(Protocol): def __call__(self, fct: Callable[Concatenate[str, ...
Open Graph Description: Bug Report The code below passed with mypy 1.1.1 but not in 1.2.0 To Reproduce from typing import Concatenate, Callable, ParamSpec, Protocol P = ParamSpec("P") class Decorator(Protocol): def __call...
X Description: Bug Report The code below passed with mypy 1.1.1 but not in 1.2.0 To Reproduce from typing import Concatenate, Callable, ParamSpec, Protocol P = ParamSpec("P") class Decorator(Protocol): ...
Opengraph URL: https://github.com/python/mypy/issues/15065
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression in 1.2.0: callback protocol with Callable and Concatenate","articleBody":"**Bug Report**\r\n\r\nThe code below passed with mypy `1.1.1` but not in `1.2.0`\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import Concatenate, Callable, ParamSpec, Protocol\r\n\r\nP = ParamSpec(\"P\")\r\n\r\n\r\nclass Decorator(Protocol):\r\n def __call__(self, fct: Callable[Concatenate[str, P], int]) -> Callable[P, int]:\r\n ...\r\n\r\n\r\ndef foo(value: int) -> Decorator:\r\n def bar(fct: Callable[Concatenate[str, P], int]) -> Callable[P, int]:\r\n raise NotImplementedError\r\n\r\n return bar\r\n\r\n```\r\nI haven't been able to strip down any further, it seems that it has something to do with both `Callable` and `Concatenate`.\r\n\r\n**Expected Behavior**\r\n\r\nNo error (as in mypy 1.1.1).\r\n\r\n**Actual Behavior**\r\n\r\nThe following error is displayed:\r\n```\r\nissue.py:15: error: Incompatible return value type (got \"Callable[[Callable[[str, **P], int]], Callable[P, int]]\", expected \"Decorator\") [return-value]\r\nissue.py:15: note: \"Decorator.__call__\" has type \"Callable[[Arg(Callable[[str, **P], int], 'fct')], Callable[P, int]]\"\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\nNote that I have tried to change the `Decorator` definition to make `fct` parameter positional-only:\r\n```python\r\nclass Decorator(Protocol):\r\n def __call__(self, fct: Callable[Concatenate[str, P], int], /) -> Callable[P, int]:\r\n ...\r\n```\r\nWhich resulted in the error message being even more confusing:\r\n```\r\nissue.py:15: error: Incompatible return value type (got \"Callable[[Callable[[str, **P], int]], Callable[P, int]]\", expected \"Decorator\") [return-value]\r\nissue.py:15: note: \"Decorator.__call__\" has type \"Callable[[Callable[[str, **P], int]], Callable[P, int]]\"\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\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: 1.2.0\r\n- Mypy command-line flags: none\r\n- Mypy configuration options from `mypy.ini` (and other config files): none\r\n- Python version used: 3.11.3","author":{"url":"https://github.com/Rogdham","@type":"Person","name":"Rogdham"},"datePublished":"2023-04-16T18:13:31Z","url":"https://github.com/python/mypy/issues/15065"}
| 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:40528f7b-2e73-6a14-c616-e4915200193e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB2C:15D703:BF687E:F7EF5C:6AFFF19B |
| html-safe-nonce | 3dafe9ac9ed89ed656c095b29398b4e63d253cfcc3e28302327b3e4f32da15f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjJDOjE1RDcwMzpCRjY4N0U6RjdFRjVDOjZBRkZGMTlCIiwidmlzaXRvcl9pZCI6Ijg5NDY2MDAxNTQyMDc2MTMzMzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2161119b7063d3c6acbfbb31f2063d497ba3bbd00894a0d67f1965c06e9bfe06 |
| hovercard-subject-tag | issue:1670075612 |
| 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/15065/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1994e3f3cb658a80f669b1c1c3b05f5ac0ecfd85641f0220bdaf97ad7db76582/python/mypy/issues/15065 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1994e3f3cb658a80f669b1c1c3b05f5ac0ecfd85641f0220bdaf97ad7db76582/python/mypy/issues/15065 |
| og:image:alt | Bug Report The code below passed with mypy 1.1.1 but not in 1.2.0 To Reproduce from typing import Concatenate, Callable, ParamSpec, Protocol P = ParamSpec("P") class Decorator(Protocol): def __call... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Rogdham |
| 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