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 negative on `__new__`, `__init__` and `__init_subclass__` #620

Open DetachHead opened 1 month ago

DetachHead commented 1 month ago

Code sample in basedpyright playground

from typing import Self

class Foo:
    def __init__(self, value: str) -> None: # no error
        pass
    def __new__(cls, value: str) -> Self: # no error
        return cls(value)
    def __init_subclass__(cls, value: str) -> None: # no error
        pass

this is because i special-cased dunders to not report it because in many cases they should be treated the same way as an override, but these three dunders should still report it

also need to account for the fact that the __init__ arguments need to match the __new__ arguments, so for those i guess it should only report the error if it's unused in both?