basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

Missing autocomplete for multi Literal param of function overload

Open STofone opened this issue 10 months ago • 2 comments

Description

from __future__ import annotations
from functools import wraps
from typing import Any, Callable, Generic, Literal, TypeVar, overload


if __name__ == "__main__":
    
    class Test():
        @overload
        def sendcmd(self, cmd: Literal["a"]): ...
        @overload
        def sendcmd(
            self, cmd: Literal["b"], x: int = 2
        ): ...

        def sendcmd(
            self, cmd, *args, **kwargs
        ):
            pass
    Test().sendcmd("a")

Image

Image

And it doesn't select to the specific overload. Image This appears on pylance too

STofone avatar Apr 21 '25 06:04 STofone

i guess since it doesn't know what overload you want, it just picks one for the completions. i agree this isn't ideal and it should just merge the completions from all potentially matching overloads

DetachHead avatar Apr 23 '25 12:04 DetachHead

i guess since it doesn't know what overload you want, it just picks one for the completions. i agree this isn't ideal and it should just merge the completions from all potentially matching overloads

https://github.com/microsoft/pylance-release/issues/4428

STofone avatar Apr 24 '25 01:04 STofone