Replies: 1 comment
-
Unpacking a TypeVarTuple within a I implemented support for this in pyright (based on the earlier draft PEP). It was quite difficult to add, so I empathize with the PEP authors who justified the removal based on a lack of use case plus feedback from the pyre team. I'll note that pyre and pytype still don't have support for TypeVarTuple in general, and it has been four years since PEP 646 was finalized. There have been some requests to add back this capability. See here and here. None of these have progressed beyond an initial discussion. Pyright still contains my original implementation (I didn't have the heart to rip it out completely after spending so much time getting it working), but it's enabled only if you set If you'd like to see this added to the typing spec, you could propose an update to the spec. This change is probably sufficiently small that it wouldn't require a full PEP, but there should be a discussion with an opportunity for type checker maintainers to weigh in. |
Beta Was this translation helpful? Give feedback.
-
I have the following function:
My tuples can have any structure.
[int, int, int]
or[str, int, bool, CustomObject]
or whatever.I thought that something like this should be possible:
But, right now it is not possible: https://mypy-play.net/?mypy=latest&python=3.12&gist=5ee956588f2eb33faba76e87902cf59a
# E: Unpack is only valid in a variadic position
Does it make sense to allow
Unpack
inUnion
?Beta Was this translation helpful? Give feedback.
All reactions