Skip to content

Commit

Permalink
Divide into two cases so all that all lines are tested
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Dec 22, 2021
1 parent 30717d8 commit 9f20e2a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions tests/functional/u/use/used_before_assignment_issue2615.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ def main():
res = opened_file.readlines()
except ZeroDivisionError:
print(res) # [used-before-assignment]
print(res)


def nested_except_blocks():
"""Don't confuse except blocks with each other."""
try:
res = 1 / 0
res = 42
if main():
res = None
with open(__file__, encoding="utf-8") as opened_file:
res = opened_file.readlines()
except ZeroDivisionError:
try:
more_bad_division = 1 / 0
except ZeroDivisionError:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
used-before-assignment:12:14:12:17:main:Using variable 'res' before assignment:UNDEFINED
used-before-assignment:16:18:16:35:main:Using variable 'more_bad_division' before assignment:UNDEFINED
used-before-assignment:29:18:29:35:nested_except_blocks:Using variable 'more_bad_division' before assignment:UNDEFINED

0 comments on commit 9f20e2a

Please sign in to comment.