basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

`reportUnknownArgumentType` false negative in `__init__` statements

Open DetachHead opened this issue 1 year ago • 1 comments

Code sample in basedpyright playground

class AnyOrUnknown:
    def __init__(self, value):
        print(value) # no error

    def foo(self, value):
        print(value) # error: reportUnknownArgumentType

this seems to be because pyright creates a fake typevar for constructor arguments, no idea why

DetachHead avatar Oct 07 '24 03:10 DetachHead

class Bar:
    asdf: int = 1

class Foo:
    def __init__(self, value):
        self.value = value

reveal_type(Foo(Bar()).value) # Bar

introduced in d29087520b652ed9368fa84c04cf3b107ed99b93

DetachHead avatar Oct 07 '24 04:10 DetachHead