Title: mypy's inference gets confused about unions with typevartuple · Issue #18407 · python/mypy · GitHub
Open Graph Title: mypy's inference gets confused about unions with typevartuple · Issue #18407 · python/mypy
X Title: mypy's inference gets confused about unions with typevartuple · Issue #18407 · python/mypy
Description: Bug Report In some cases involving matching an argument against a union with type var tuples, mypy infers Never instead of something better. To Reproduce from typing import TypeVarTuple, Unpack, Generic from collections.abc import Callab...
Open Graph Description: Bug Report In some cases involving matching an argument against a union with type var tuples, mypy infers Never instead of something better. To Reproduce from typing import TypeVarTuple, Unpack, Ge...
X Description: Bug Report In some cases involving matching an argument against a union with type var tuples, mypy infers Never instead of something better. To Reproduce from typing import TypeVarTuple, Unpack, Ge...
Opengraph URL: https://github.com/python/mypy/issues/18407
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy's inference gets confused about unions with typevartuple","articleBody":"\u003c!--\r\nIf you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form instead.\r\nPlease 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 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\nIf you're reporting a problem with a specific library function, the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues\r\n\r\nIf the project you encountered the issue in is open source, please provide a link to the project.\r\n-->\r\n\r\nIn some cases involving matching an argument against a union with type var tuples, mypy infers `Never` instead of something better.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import TypeVarTuple, Unpack, Generic\r\nfrom collections.abc import Callable\r\n\r\nArgs = TypeVarTuple(\"Args\")\r\n\r\nclass Built(Generic[Unpack[Args]]):\r\n pass\r\n\r\ndef example(n: Built[Unpack[Args]] | Callable[[Unpack[Args]], None]) -> Built[Unpack[Args]]: ...\r\n\r\nreveal_type(example) # N: Revealed type is \"def [Args] (n: Union[__main__.Built[Unpack[Args`-1]], def (*Unpack[Args`-1])]) -> __main__.Built[Unpack[Args`-1]]\"\r\n\r\n@example # E: Argument 1 to \"example\" has incompatible type \"Callable[[], None]\"; expected \"Built[*tuple[Never, ...]] | Callable[[VarArg(Never)], None]\"\r\ndef command1() -> None:\r\n return\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nI expect no error.\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\nChecked in mypy playground.\r\n\r\n- Mypy version used: v1.14\r\n- Mypy command-line flags: none\r\n- Mypy configuration options from `mypy.ini` (and other config files): N/A\r\n- Python version used: 3.12\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/A5rocks","@type":"Person","name":"A5rocks"},"datePublished":"2025-01-02T06:32:34Z","url":"https://github.com/python/mypy/issues/18407"}
| 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:a950c132-d9e0-4ecc-5566-4b251b0a4a5b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F64:251AC0:420259:5820F9:6B002AB0 |
| html-safe-nonce | 63a3698aafcc10c0b2184b7f04a8307e654fd2ec2b9afe37885e432a2accd487 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjY0OjI1MUFDMDo0MjAyNTk6NTgyMEY5OjZCMDAyQUIwIiwidmlzaXRvcl9pZCI6IjIyMjIyMjYzNTQzMDczNDUwNzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b3a162d3c53c95378f3de518b81df1ec543d1541c8f3b4a281f8ecd8444f8ca2 |
| hovercard-subject-tag | issue:2765511369 |
| 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/18407/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e9e9e7163dad651765009b3ff9312b16dd1bd72b43ec94973bb110c11fdb8827/python/mypy/issues/18407 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e9e9e7163dad651765009b3ff9312b16dd1bd72b43ec94973bb110c11fdb8827/python/mypy/issues/18407 |
| og:image:alt | Bug Report In some cases involving matching an argument against a union with type var tuples, mypy infers Never instead of something better. To Reproduce from typing import TypeVarTuple, Unpack, Ge... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | A5rocks |
| 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