Title: mypy 1.7.0, ParamSpec: `Cannot infer type argument 1 of "function_name"` when using keyword arguments. · Issue #16485 · python/mypy · GitHub
Open Graph Title: mypy 1.7.0, ParamSpec: `Cannot infer type argument 1 of "function_name"` when using keyword arguments. · Issue #16485 · python/mypy
X Title: mypy 1.7.0, ParamSpec: `Cannot infer type argument 1 of "function_name"` when using keyword arguments. · Issue #16485 · python/mypy
Description: Bug Report The issues with ParamSpec inference for pytypest first appeared in mypy 1.6.0, see #16301. In 1.7.0, it was fixed for some cases but not all. This specific issue happens when a function accepts multiple classes using ParamSpec...
Open Graph Description: Bug Report The issues with ParamSpec inference for pytypest first appeared in mypy 1.6.0, see #16301. In 1.7.0, it was fixed for some cases but not all. This specific issue happens when a function ...
X Description: Bug Report The issues with ParamSpec inference for pytypest first appeared in mypy 1.6.0, see #16301. In 1.7.0, it was fixed for some cases but not all. This specific issue happens when a function ...
Opengraph URL: https://github.com/python/mypy/issues/16485
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy 1.7.0, ParamSpec: `Cannot infer type argument 1 of \"function_name\"` when using keyword arguments.","articleBody":"**Bug Report**\r\n\r\nThe issues with ParamSpec inference for [pytypest](https://github.com/orsinium-labs/pytypest) first appeared in mypy 1.6.0, see #16301. In 1.7.0, it was fixed for some cases but not all.\r\n\r\nThis specific issue happens when a function accepts multiple classes using ParamSpec and some of them pass an argument as keyword one and some pass the same argument as a positional one.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import Callable, Generic\r\nfrom typing_extensions import ParamSpec\r\n\r\nP = ParamSpec('P')\r\n\r\nclass Case(Generic[P]):\r\n def __init__(self, *args: P.args, **kwargs: P.kwargs) -> None:\r\n pass\r\n\r\ndef _test(a: int, b: int = 0) -> None:\r\n assert a\r\n\r\ndef parametrize(\r\n func: Callable[P, None],\r\n *cases: Case[P],\r\n **named_cases: Case[P],\r\n) -> Callable[[], None]:\r\n raise NotImplementedError\r\n\r\n# this one works:\r\nparametrize(_test, Case(1, 2), Case(3, 4))\r\n\r\n# this one also works:\r\nparametrize(_test, Case(1, b=2), Case(3, b=4))\r\n\r\n# and this is also fine:\r\nparametrize(_test, Case(1, 2), Case(3))\r\n\r\n# but this one fails inference:\r\nparametrize(_test, Case(1, 2), Case(3, b=4))\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nIt shouldn't matter how an argument is passed into ParamSpec. If it can be passed into the target function described by the ParamSpec, it should pass type checking.\r\n\r\n**Actual Behavior**\r\n\r\nFor the last line of the code:\r\n\r\n```\r\nCannot infer type argument 1 of \"parametrize\" [misc]\r\n```\r\n\r\nThe same happens if instead of `*cases: Case[P]` the function accepts `case1: Case[P], case2: Case[P]`.\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.7.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.10\r\n","author":{"url":"https://github.com/orsinium","@type":"Person","name":"orsinium"},"datePublished":"2023-11-14T07:37:01Z","url":"https://github.com/python/mypy/issues/16485"}
| 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:92adec92-10a4-daaa-12e8-ca85b1dccc31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A9A8:2148FB:11317A1:1714506:6AFFC7D2 |
| html-safe-nonce | 0f08fba868d55e58f694ae1d29ab4e918a09ba9bae9b8d36e07a574c7b4c5ef1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUE4OjIxNDhGQjoxMTMxN0ExOjE3MTQ1MDY6NkFGRkM3RDIiLCJ2aXNpdG9yX2lkIjoiNTU5NzI1MTUzNDI3NTQ2MzEyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c2c85e12c9ce5c3d2b1aa5e673a1722573c0788052b2a592c378e9719f1f6de1 |
| hovercard-subject-tag | issue:1992157551 |
| 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/16485/issue_layout |
| twitter:image | https://opengraph.githubassets.com/60ce09439995658f2fbadebf8c23016101ea7ff41af77b6ff0bdd715833de7c3/python/mypy/issues/16485 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/60ce09439995658f2fbadebf8c23016101ea7ff41af77b6ff0bdd715833de7c3/python/mypy/issues/16485 |
| og:image:alt | Bug Report The issues with ParamSpec inference for pytypest first appeared in mypy 1.6.0, see #16301. In 1.7.0, it was fixed for some cases but not all. This specific issue happens when a function ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | orsinium |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1e805b832df235bb21305db712c3b6432920019dfc12cb25b9cb8d3b0c9403cf |
| 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 | 8fa4a54e6871c7908eda1c246ad5972982c0b59d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width