Open
Description
Current problem
import random
enter_first = True
while enter_first or (some_walrus := random.random()) < 0.9:
print(some_walrus)
enter_first = False
This code will fail, because enter_first
short circuits, and the variable some_walrus
isn't set.
Traceback (most recent call last):
File "/path/to/a.py", line 5, in <module>
print(some_walrus)
NameError: name 'some_walrus' is not defined
Desired solution
It would be pretty cool if pylint
could flag this vulnerabiltity. Basically, the idea is warning if a short circuit can lead to a local variable not being present.
Additional context
No response