Title: Inference failure with Protocol and ParamSpec · Issue #15734 · python/mypy · GitHub
Open Graph Title: Inference failure with Protocol and ParamSpec · Issue #15734 · python/mypy
X Title: Inference failure with Protocol and ParamSpec · Issue #15734 · python/mypy
Description: To Reproduce mypy Playground from typing import Protocol, ParamSpec, Callable, Concatenate P = ParamSpec('P') class FuncType(Protocol[P]): def __call__(self, x: int, s: str, *args: P.args, **kw_args: P.kwargs) -> str: ... def forwarder1(...
Open Graph Description: To Reproduce mypy Playground from typing import Protocol, ParamSpec, Callable, Concatenate P = ParamSpec('P') class FuncType(Protocol[P]): def __call__(self, x: int, s: str, *args: P.args, **kw_arg...
X Description: To Reproduce mypy Playground from typing import Protocol, ParamSpec, Callable, Concatenate P = ParamSpec('P') class FuncType(Protocol[P]): def __call__(self, x: int, s: str, *args: P.args, ...
Opengraph URL: https://github.com/python/mypy/issues/15734
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inference failure with Protocol and ParamSpec","articleBody":"**To Reproduce**\r\n\r\n[mypy Playground](https://mypy-play.net/?mypy=latest&python=3.11&gist=4b2606194471a4837e62e7285bcd6014)\r\n\r\n```python\r\nfrom typing import Protocol, ParamSpec, Callable, Concatenate\r\n\r\nP = ParamSpec('P')\r\n\r\nclass FuncType(Protocol[P]):\r\n def __call__(self, x: int, s: str,\r\n *args: P.args, **kw_args: P.kwargs) -> str: ...\r\n\r\ndef forwarder1(fp: FuncType[P], *args: P.args, **kw_args: P.kwargs) -> str:\r\n return fp(0, '', *args, **kw_args)\r\n\r\ndef forwarder2(fp: Callable[Concatenate[int, str, P], str],\r\n *args: P.args, **kw_args: P.kwargs) -> str:\r\n return fp(0, '', *args, **kw_args)\r\n\r\ndef my_f(x: int, s: str, d: float) -> str:\r\n return f\"{x}, {s}, {d}\"\r\n\r\n# error: Argument 1 to \"forwarder1\" has incompatible type \"Callable[[int, str, float], str]\";\r\n# expected \"FuncType[\u003cnothing>]\" [arg-type]\r\n# error: Argument 2 to \"forwarder1\" has incompatible type \"float\";\r\n# expected \u003cnothing> [arg-type]\r\nforwarder1(my_f, 1.2)\r\n\r\nforwarder2(my_f, 1.2)\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nNo error found.\r\n\r\n**Actual Behavior**\r\n\r\nArgument 1 to \"forwarder1\" has incompatible type \"Callable[[int, str, float], str]\"; expected \"FuncType[\u003cnothing>]\" [arg-type]\r\nArgument 2 to \"forwarder1\" has incompatible type \"float\"; expected \u003cnothing> [arg-type]\r\n","author":{"url":"https://github.com/mtomassoli","@type":"Person","name":"mtomassoli"},"datePublished":"2023-07-21T10:02:08Z","url":"https://github.com/python/mypy/issues/15734"}
| 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:aaebddae-9d8f-9734-a7fb-421689d20d30 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A9AA:1F7A:96DA3F:CC7392:6AFFF1AD |
| html-safe-nonce | bd1822cdb68f51808d1905f471be4629e90507083dd4fde5d9302302db7dbb09 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUFBOjFGN0E6OTZEQTNGOkNDNzM5Mjo2QUZGRjFBRCIsInZpc2l0b3JfaWQiOiIxOTcyOTU1NzM3MTQzMzQxMjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 765bce942ba899dc89be656c64d0d6c98274fac471a16ec617c935412265bd82 |
| hovercard-subject-tag | issue:1815528701 |
| 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/15734/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fb9a356b3c55012af7f4db960970592b8a2a7f0d188ea318543a6320f01cba89/python/mypy/issues/15734 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fb9a356b3c55012af7f4db960970592b8a2a7f0d188ea318543a6320f01cba89/python/mypy/issues/15734 |
| og:image:alt | To Reproduce mypy Playground from typing import Protocol, ParamSpec, Callable, Concatenate P = ParamSpec('P') class FuncType(Protocol[P]): def __call__(self, x: int, s: str, *args: P.args, **kw_arg... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mtomassoli |
| 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