basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

`reportPossiblyUnboundVariable` false negative on assignments to instance attribute

Open DetachHead opened this issue 1 year ago • 1 comments

Code sample in basedpyright playground

class Foo:
    def __init__(self) -> None:
        if bool():
            a = 1
        a # "a" is possibly unbound  (reportPossiblyUnboundVariable)
        if bool():
            self.a = 1
        self.a # no error

DetachHead avatar Sep 02 '24 01:09 DetachHead

maybe related?: #682

DetachHead avatar Sep 21 '24 05:09 DetachHead