-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PEP 692 (kwargs TypedDict) tracker #9710
Comments
Thanks for opening this! What would be the effect if someone uses a stub with mypy that uses this feature without |
Since |
Here is what mypy reports: from typing import TypedDict
from typing_extensions import Unpack
class Foo(TypedDict, total=False):
a: int
b: str
def f(**kwargs: Unpack[Foo]) -> None: # E: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
reveal_type(kwargs) # N: Revealed type is "builtins.dict[builtins.str, Any]"
reveal_type(f) # N: Revealed type is "def (**kwargs: Any)"
# (no error in any of the following)
f(a=1, b="2")
f(a=1, b=2)
f(a=1, b="2", c=3) |
Sounds reasonable to wait for mypy to enable it by default. I can open up a mypy issue later today. |
I wanted to provide an update based on the current state of the different tools:
As a result, it appears 1 of the remaining 3 type checkers have added support and 1 of the 2 that have not implemented it have an open tracking issue. |
Thanks @kkirsche, I updated the tracker comment |
Pyre's latest release (https://github.com/facebook/pyre-check/releases/tag/v0.9.23) supports |
Test example I'm using for support,
pytype and pyre both produce 1 error on
f(**kwargs: Unpack[Foo])
. Pytype producestyping_extensions.Unpack not supported yet [not-supported-yet]
while pyre producespep_692.py:11:16 Undefined or invalid type [11]: Annotation Unpack is not defined as a type.
Unsure if typeshed usage for this should wait til pyre/pytype fully support pep 692 or if current status of them not checking lines reliant on 692 is enough (similar to Self type status). pytype/pyre still detect errors normally for other parts of the file.
For mypy side we would also need to adjust line with mypy flags to include --enable-incomplete-feature=Unpack (maybe other incomplete features should be considered too).
Motivation for issue was yesterday I hit some lines in tensorflow stub where 692 would be helpful. Minor though and being explicit on arguments works fine (just adds a couple stubtest allowlist lines).
The text was updated successfully, but these errors were encountered: