Skip to content

Support for **kwargs autocompletion when using Unpack[T] #2541

@dgellow

Description

@dgellow

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:

from typing_extensions import Unpack, TypedDict, Literal

class MyKwargs(TypedDict):
    foo: Literal["hello", "nopnop"]
    bar: int

def baz(**kwargs: Unpack[MyKwargs]) -> None:
    pass

baz(foo="hello", bar=3)
baz(|) # 👈 My caret is here

I would expect that when I trigger the autocompletion via ctrl+space I would get suggested foo= and bar=, but instead the only relevant suggestion is kwargs=.

image

When I trigger the autocompletion for MyKwargs() arguments I get something correct, the issue seem to only be when using Unpack[T]:
image

It would be nice to have the list of keys of the unpacked typed dict :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions