-
Notifications
You must be signed in to change notification settings - Fork 768
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
Support for **kwargs
autocompletion when using Unpack[T]
#2541
Comments
Related issue thread in mypy: python/mypy#4441 |
This feature (using a Since this is not a core type checking issue, I'm going to transfer this request to the pylance-release repo for consideration and tracking. |
Sounds good, thanks for the quick response. Would you accept a pull request, or do you consider the feature too experimental and would prefer to first wait for the feature to become standard? (or at least for a PEP to be accepted) |
We would prefer to wait for it to become standard. If that happens, please reopen if you would still like it. |
In my opinion, this is a must have feature for the future of python. Typescript had this for 10 years and it's an essential feature of the language. I'm happy to see python making progress in supporting better typing. |
The good news is that this proposal is one step closer to becoming standardized in Python. It is now a draft PEP, and if it's accepted, it will become part of Python 3.12. |
@bschnurr it looks like this PEP has now been accepted and is on track to be a standard in Python 3.12. See https://peps.python.org/pep-0692/ Would you be willing to open this issue again? |
@rchiodo Oh sweet! I had just tried this on VSCode but I'm not on any preview versions. Thanks for the quick response. |
Mypy is correct to generate an error here. You'll see the same error if you enable type errors in pylance. If you want the fields in your TypedDict to not be required, they need to be marked as "NotRequired". Alternatively, you can specify class MyDict(TypedDict, total=False):
field_1: int | None or class MyDict(TypedDict):
field_1: NotRequired[int | None] For future bug reports, please include your code in text form rather than (or in addition to) screen shots and open new issues rather than adding to issues that have been closed for a long time. |
@erictraut |
Environment: Pylance version v2022.3.4, from vscode.
I'm not sure if it is a bug or would be considered a new feature. I understood from microsoft/pyright#3002 that typed
**kwargs
are now supported by pylance/pyright. Thank you for this!Now when I try the example mentioned at microsoft/pyright#3002 (comment) I see that while type checking seem to work correctly, the autocompletion doesn't seem to work as I would expect.
Let's say I have this code in vscode, with Pylance enabled:
I would expect that when I trigger the autocompletion via
ctrl+space
I would get suggestedfoo=
andbar=
, but instead the only relevant suggestion iskwargs=
.When I trigger the autocompletion for
MyKwargs()
arguments I get something correct, the issue seem to only be when usingUnpack[T]
:It would be nice to have the list of keys of the unpacked typed dict :)
The text was updated successfully, but these errors were encountered: