-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
as designedNot a bug, working as intendedNot a bug, working as intended
Description
So this construct caught my eye:
def x():
y = True
if y:
a = 1
if y:
>> print(a)
"a" is possibly unbound
[Pyright: reportUnboundVariable]
────────────────────────────────────────────────────────────────────
https://github.com/microsoft/pyright/blob/main/docs/configuration.mdI don't think there is a way how a could be unbound ...
curiously, it also complains for x
def x():
y = True
if y:
x = 1
if y:
>> print(x)
"x" is possibly unbound
[Pyright: reportUnboundVariable]
────────────────────────────────────────────────────────────────────
https://github.com/microsoft/pyright/blob/main/docs/configuration.mdbut in this case x is surely at least the function itself, yes?
changing the variable name makes it see that x can be the function itself:
def x():
y = True
if y:
>> a = 1
if y:
print(x)
there is now warning "a" is not accessed, but it no longer complains about x being possibly unbound
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
as designedNot a bug, working as intendedNot a bug, working as intended