"Dead code" after a return
Bug #1274566 reported by
asmeurer
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
New
|
Wishlist
|
Unassigned |
Bug Description
Is there a reason pyflakes doesn't warn on "dead code", i.e., code that cannot possibly be run because it comes after a return or a raise in the same block, like
def f():
return
g() # cannot be reached
I think return, raise, break, and continue are all such statements.
In a similar vein (should this be a separate issue?), what about unnecessary pass, like
if x:
pass
f()
Inline non-string literals or bare variable names might also fit into this category, although the latter can be a useful way to squash incorrect "unused variable" warnings.
Changed in pyflakes: | |
importance: | Undecided → Wishlist |
To post a comment you must log in.
Also assignments preceding a return/raise, but not used in that branch.
def foo(a):
if a:
x = 10
return a
else:
x = 20
return x