no warning for possibly undefined scope
Bug #1497348 reported by
jonathan
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Apologies if this is known -- I didn't see a bug or a skipped test for it.
This should generate a warning but does not:
a = None
if True or False:
b = None
ab = a + b
b is undefined when the `if` fails, and the code is invalid Python.
a = None
if False:
b = None
ab = a + b
Traceback (most recent call last):
File "/Users/
ab = a + b
NameError: name 'b' is not defined
However pyflakes does not catch this error at all.
Changed in pyflakes: | |
status: | New → Confirmed |
To post a comment you must log in.
What about:
i = randint(0, 10)
if is_even(i):
b = "foo"
if is_odd(i):
b = "bar"
print b
This works all the time, but is there a way for Pyflakes to know that?