Title: Instances of type variables bounded by an iterable type support iteration but not unpacking · Issue #13402 · python/mypy · GitHub
Open Graph Title: Instances of type variables bounded by an iterable type support iteration but not unpacking · Issue #13402 · python/mypy
X Title: Instances of type variables bounded by an iterable type support iteration but not unpacking · Issue #13402 · python/mypy
Description: Bug Report Instances of type variables bounded by an iterable type support iteration but not unpacking. To Reproduce from typing import TypeVar class A: pass ATuple = TypeVar("ATuple", bound=tuple[A, ...]) def f(aa: ATuple) -> None: for ...
Open Graph Description: Bug Report Instances of type variables bounded by an iterable type support iteration but not unpacking. To Reproduce from typing import TypeVar class A: pass ATuple = TypeVar("ATuple", bound=tuple[...
X Description: Bug Report Instances of type variables bounded by an iterable type support iteration but not unpacking. To Reproduce from typing import TypeVar class A: pass ATuple = TypeVar("ATuple", bo...
Opengraph URL: https://github.com/python/mypy/issues/13402
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Instances of type variables bounded by an iterable type support iteration but not unpacking","articleBody":"**Bug Report**\r\n\r\nInstances of type variables bounded by an iterable type support iteration but not unpacking.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import TypeVar\r\n\r\nclass A:\r\n pass\r\n\r\nATuple = TypeVar(\"ATuple\", bound=tuple[A, ...])\r\n\r\ndef f(aa: ATuple) -> None:\r\n for a in aa: # this is ok\r\n print(a)\r\n\r\nf((A(),))\r\n\r\ndef g(aa: ATuple) -> None:\r\n (a,) = aa # \"ATuple\" object is not iterable\r\n print(a)\r\n\r\ng((A(),))\r\n```\r\n\r\nBounding the TypeVar by `list[A]` has the same behaviour as bounding it by `tuple[A, ...]`.\r\n\r\n**Expected Behavior**\r\n\r\nNo error -- an ATuple should support both iteration and unpacking.\r\n\r\n**Actual Behavior**\r\n\r\nf() checks clean.\r\n\r\nIn g(), unpacking fails with:\r\n\r\nerror: \"ATuple\" object is not iterable\r\nerror: Cannot determine type of \"a\"\r\n\r\n**Your Environment**\r\n\r\nThis reproduces in all versions in the playground.","author":{"url":"https://github.com/tdsmith","@type":"Person","name":"tdsmith"},"datePublished":"2022-08-13T01:21:26Z","url":"https://github.com/python/mypy/issues/13402"}
| 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:e1e53465-dae7-85ab-28df-866c1718b68e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DDA6:1DA187:37AD36B:49FFB0A:6B004BC3 |
| html-safe-nonce | 5faa90f7d35e50643c294bd73c500f4dc38f73cd2be28c446196841ee35ee9f9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREE2OjFEQTE4NzozN0FEMzZCOjQ5RkZCMEE6NkIwMDRCQzMiLCJ2aXNpdG9yX2lkIjoiMTc4NzgyMTkzNzM3NjkwNjE3OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f4241e439ac786eaa3e25e9c611c832116f3c28d9275b1f8aec32328e3c202d6 |
| hovercard-subject-tag | issue:1337818015 |
| 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/13402/issue_layout |
| twitter:image | https://opengraph.githubassets.com/544a99c34a3c81077d551e183be8aa5e0ab74e4b1ceec4dbd452a318f93ae265/python/mypy/issues/13402 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/544a99c34a3c81077d551e183be8aa5e0ab74e4b1ceec4dbd452a318f93ae265/python/mypy/issues/13402 |
| og:image:alt | Bug Report Instances of type variables bounded by an iterable type support iteration but not unpacking. To Reproduce from typing import TypeVar class A: pass ATuple = TypeVar("ATuple", bound=tuple[... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tdsmith |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| 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 | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width