Title: All instances of `types.GenericAlias` are iterable on Python 3.11+ · Issue #103450 · python/cpython · GitHub
Open Graph Title: All instances of `types.GenericAlias` are iterable on Python 3.11+ · Issue #103450 · python/cpython
X Title: All instances of `types.GenericAlias` are iterable on Python 3.11+ · Issue #103450 · python/cpython
Description: All generic aliases appear to be iterable on Python 3.11+, meaning you can do some fairly bizarre things that don't really make any sense: >>> list(dict[int, int]) [*dict[int, int]] >>> import collections.abc >>> list(collections.abc.Gen...
Open Graph Description: All generic aliases appear to be iterable on Python 3.11+, meaning you can do some fairly bizarre things that don't really make any sense: >>> list(dict[int, int]) [*dict[int, int]] >>> import coll...
X Description: All generic aliases appear to be iterable on Python 3.11+, meaning you can do some fairly bizarre things that don't really make any sense: >>> list(dict[int, int]) [*dict[int, int]] &g...
Opengraph URL: https://github.com/python/cpython/issues/103450
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"All instances of `types.GenericAlias` are iterable on Python 3.11+","articleBody":"All generic aliases appear to be iterable on Python 3.11+, meaning you can do some fairly bizarre things that don't really make any sense:\r\n\r\n```pycon\r\n\u003e\u003e\u003e list(dict[int, int])\r\n[*dict[int, int]]\r\n\u003e\u003e\u003e import collections.abc\r\n\u003e\u003e\u003e list(collections.abc.Generator[int, str, bytes])\r\n[*collections.abc.Generator[int, str, bytes]]\r\n```\r\n\r\nThis is due to the implementation of PEP 646 that was added in #31019 by @mrahtz. It was a deliberate decision at the time: https://github.com/python/cpython/pull/31019/commits/4aa94df3b0766ed971fde990edf7820539555535 is the commit in that PR branch that removes the restriction that only `tuple` can be unpacked (the commit was done in response to a review comment here: https://github.com/python/cpython/pull/31019#discussion_r795208242). However, there wasn't _much_ discussion at the time.\r\n\r\nDo we want to stick with this behaviour, on the basis that the runtime usually prefers to be lenient when it comes to typing constructs, leaving it to type checkers to point out invalid usage? Or should this be considered a bug?","author":{"url":"https://github.com/AlexWaygood","@type":"Person","name":"AlexWaygood"},"datePublished":"2023-04-11T18:11:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/103450/cpython/issues/103450"}
| 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:66ab894b-5197-c0b3-63c0-f3edbc00588d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D36C:2EC266:3E5C8A:558AA7:696A6AC6 |
| html-safe-nonce | a654ba3bba0a832644c08a9d1faabb87a7370b0e640fed4b8265f5985e36d5ea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzZDOjJFQzI2NjozRTVDOEE6NTU4QUE3OjY5NkE2QUM2IiwidmlzaXRvcl9pZCI6IjIyODM4ODYwNzczMDgyMDE2NzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e291abc6474c68eca4fa779679cb56c3a2e65f4b538bbdceaa76f7873982cbb8 |
| hovercard-subject-tag | issue:1662989203 |
| 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/cpython/103450/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b9557e213d48ebba9293729e8428bf04ad3a85efd8dda46e1bf6ecef374d3c08/python/cpython/issues/103450 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b9557e213d48ebba9293729e8428bf04ad3a85efd8dda46e1bf6ecef374d3c08/python/cpython/issues/103450 |
| og:image:alt | All generic aliases appear to be iterable on Python 3.11+, meaning you can do some fairly bizarre things that don't really make any sense: >>> list(dict[int, int]) [*dict[int, int]] >>> import coll... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexWaygood |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6fea32d5b7276b841b7a803796d9715bc6cfb31ed549fdf9de2948ac25d12ba6 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | f2d9f6432a5a115ec709295ae70623f33bb80aee |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width