DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
https://docs.basedpyright.com
Other
1.02k stars 19 forks source link

`reportUnusedParameter` false positive on overloads that are decorated with a class decorator #604

Open DetachHead opened 1 month ago

DetachHead commented 1 month ago

Code sample in basedpyright playground

from typing import overload, Callable

class Foo[**P, T]:

    def __init__(self, function: Callable[P, T]):
        ...

    def __call__(self, *args: P.args, **kwds: P.kwargs) -> T:
        ...

class Bar:
    @Foo
    @overload
    def foo(self, asdf: int) -> str:... # reportUnusedParameter
    @Foo
    @overload
    def foo(self, asdf: str) -> int:... # reportUnusedParameter

    def foo(self, asdf: object) -> object:
        print(asdf)

the same issue also occurs upstream, but it's more of an issue in basedpyright because we support reporting it as an error instead of just an IDE hint