microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.69k stars 767 forks source link

Wrong argument provided during auto completion if inside a collection #6066

Open Viicos opened 2 months ago

Viicos commented 2 months ago

Note: if you are reporting a wrong signature of a function or a class in the standard library, then the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues.

If you have a question about typing or a behavior that you’re seeing in Pyright (as opposed to a bug report or enhancement request), consider posting to the Pyright discussion forum.

Describe the bug

When requesting auto completions in the code snippet below, pyright (or Pylance?) will display the commands= argument, which is not valid as we are still in the list of the range argument.

Code or Screenshots

Code sample in pyright playground

class Model:
    def __init__(self, ranges: list[str], commands: list[str]) -> None: ...

m = Model(
    ranges=[
        "a",
        # Request auto completion with the cursor at this position
    ]
)

image

VS Code extension or command-line Are you running pyright as a VS Code extension, a language server in another editor, integrated into Pylance, or the command-line tool? Which version?

erictraut commented 2 months ago

Since this is a language server issue, I'll leave it to the pylance team to investigate.

@rchiodo, @debonte, could one of you please transfer this to pylance-release? Thanks!

heejaechang commented 1 month ago

looks like signature help's context checking is not checking a case where it is nested another expression.