-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed as not planned
Closed as not planned
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
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.Generator[int, str, bytes])
[*collections.abc.Generator[int, str, bytes]]
This is due to the implementation of PEP 646 that was added in #31019 by @mrahtz. It was a deliberate decision at the time: 4aa94df 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: #31019 (comment)). However, there wasn't much discussion at the time.
Do 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?
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error