You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature
PEP 692 support currently works but is gated behind --enable-incomplete-feature=Unpack. I think that flag includes both kwargs unpacking and variadic generics unpacking. It would be nice to move out just kwargs unpacking and have it available by default. That would enable typeshed/easier library usage of it.
But I currently get (on mypy 1.1.1 on python 3.10.9)
mypy test.py --enable-incomplete-feature=Unpack
test.py:5: error: Incompatible types in assignment (expression has type "Tuple[str, int, int, int]", variable has type "Tuple[str, Unpack[Tuple[int, ...]]]") [assignment]
PEP 692 applies only to annotations on **kwargs parameters. PEP 646 covers other uses of Unpack including variadic type variables (TypeVarTuple). As far as I know, mypy's support for PEP 646 is not yet complete. See this tracking issue for details.
I feel like this could remove many stubtest allowlist lines in TypeShed (where kwargs are manually unpacked) when fully supported.
Ooh, a little off-topic, but I'd be curious if you have any examples @Avasam! Stubtest actually already has some special-case logic to specifically allow kwargs to be manually unpacked in a stub if the runtime just has **kwargs. Most times I've seen this kind of thing being allowlisted in typeshed, it's because contributors forgot to make all the "manually unpacked" parameters keyword-only in the stub (bcd4ff2 should help a bit with the error messages here, hopefully :)
Most times I've seen this kind of thing being allowlisted in typeshed, it's because contributors forgot to make all the "manually unpacked" parameters keyword-only in the stub
Now that you mention it... I'll double check and come back to you (other here or in typeshed PRs). That might be it.
Activity
PhilReinhold commentedon Mar 21, 2023
Is all of 692 supported? According to https://peps.python.org/pep-0646/#unpacking-unbounded-tuple-types I think the following should work
But I currently get (on mypy 1.1.1 on python 3.10.9)
erictraut commentedon Mar 21, 2023
PEP 692 applies only to annotations on
**kwargsparameters. PEP 646 covers other uses ofUnpackincluding variadic type variables (TypeVarTuple). As far as I know, mypy's support for PEP 646 is not yet complete. See this tracking issue for details.Avasam commentedon Oct 2, 2023
I feel like this could remove many stubtest allowlist lines in TypeShed (where kwargs are manually unpacked) when fully supported.
AlexWaygood commentedon Oct 3, 2023
Ooh, a little off-topic, but I'd be curious if you have any examples @Avasam! Stubtest actually already has some special-case logic to specifically allow kwargs to be manually unpacked in a stub if the runtime just has
**kwargs. Most times I've seen this kind of thing being allowlisted in typeshed, it's because contributors forgot to make all the "manually unpacked" parameters keyword-only in the stub (bcd4ff2 should help a bit with the error messages here, hopefully :)Avasam commentedon Oct 3, 2023
Now that you mention it... I'll double check and come back to you (other here or in typeshed PRs). That might be it.
Enable Unpack/TypeVarTuple support (#16354)