Title: Callables like `operator.call` produce `arg-type` error with callables that take `*args: Unpack[Ts]` and >= 1 keyword argument · Issue #16662 · python/mypy · GitHub
Open Graph Title: Callables like `operator.call` produce `arg-type` error with callables that take `*args: Unpack[Ts]` and >= 1 keyword argument · Issue #16662 · python/mypy
X Title: Callables like `operator.call` produce `arg-type` error with callables that take `*args: Unpack[Ts]` and >= 1 keyword argument · Issue #16662 · python/mypy
Description: Bug Report operator.call and similar ParamSpec callables (e.g. concurrent.futures.Executor.submit) produce an arg-type error when doing call(fn, fn2, some_kwarg=...) where fn has signature (fn2: Callable[[Unpack[Ts]], T], *args: Unpack[T...
Open Graph Description: Bug Report operator.call and similar ParamSpec callables (e.g. concurrent.futures.Executor.submit) produce an arg-type error when doing call(fn, fn2, some_kwarg=...) where fn has signature (fn2: Ca...
X Description: Bug Report operator.call and similar ParamSpec callables (e.g. concurrent.futures.Executor.submit) produce an arg-type error when doing call(fn, fn2, some_kwarg=...) where fn has signature (fn2: Ca...
Opengraph URL: https://github.com/python/mypy/issues/16662
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Callables like `operator.call` produce `arg-type` error with callables that take `*args: Unpack[Ts]` and >= 1 keyword argument","articleBody":"**Bug Report**\r\n\r\n`operator.call` and similar `ParamSpec` callables (e.g. `concurrent.futures.Executor.submit`) produce an `arg-type` error when doing `call(fn, fn2, some_kwarg=...)` where `fn` has signature `(fn2: Callable[[Unpack[Ts]], T], *args: Unpack[Ts], some_kwarg: ...) -> ...`\r\n\r\nthis looks like a `TypeVarTuple` analog of #16405.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nimport operator\r\nfrom collections.abc import Callable\r\nfrom typing import TypeVar\r\nfrom typing import TypeVarTuple\r\nfrom typing import Unpack\r\n\r\nT = TypeVar(\"T\")\r\nTs = TypeVarTuple(\"Ts\")\r\n\r\n\r\ndef run(func: Callable[[Unpack[Ts]], T], *args: Unpack[Ts], some_kwarg: str = \"asdf\") -> T:\r\n raise NotImplementedError\r\n\r\n\r\ndef foo() -> str:\r\n raise NotImplementedError\r\n\r\n\r\nrun(foo) # OK\r\noperator.call(run, foo) # OK\r\nrun(foo, some_kwarg=\"a\") # OK\r\noperator.call(run, foo, some_kwarg=\"a\")\r\n# error: Argument 1 to \"call\" has incompatible type \"Callable[[Callable[[VarArg(*Ts)],\r\n# T], VarArg(*Ts), DefaultNamedArg(str, 'some_kwarg')], T]\"; expected\r\n# \"Callable[[Callable[[], str], str], str]\" [arg-type]\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nno error.\r\n\r\n**Actual Behavior**\r\n\r\nsee comments in the reproducer above.\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.7.1 (compiled) & latest master (uncompiled)\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: CPython 3.12.1\r\n\r\n\u003c!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->\r\n","author":{"url":"https://github.com/gschaffner","@type":"Person","name":"gschaffner"},"datePublished":"2023-12-14T12:14:44Z","url":"https://github.com/python/mypy/issues/16662"}
| 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:f837b64a-aa47-f5ca-bb6d-f924a983fdb9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFB2:1FB2:1059B20:167DB41:6B002B16 |
| html-safe-nonce | fc1c18f543e9b64e5994774f1dd574a0d709be5201d18d72aca27a1d2a2b990e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkIyOjFGQjI6MTA1OUIyMDoxNjdEQjQxOjZCMDAyQjE2IiwidmlzaXRvcl9pZCI6IjUxMTU3MzM2ODQwNDQ5NjY2NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | acb50036ceea43d11a6e067d9fc18ed5e0fbe1843fd52e8a182d999b43a9bdff |
| hovercard-subject-tag | issue:2041576025 |
| 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/16662/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1af892c2591545cb00f9c65a333e5dca0854554e42f3f523ad8c41e02055a3a/python/mypy/issues/16662 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1af892c2591545cb00f9c65a333e5dca0854554e42f3f523ad8c41e02055a3a/python/mypy/issues/16662 |
| og:image:alt | Bug Report operator.call and similar ParamSpec callables (e.g. concurrent.futures.Executor.submit) produce an arg-type error when doing call(fn, fn2, some_kwarg=...) where fn has signature (fn2: Ca... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gschaffner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width