forked from pylint-dev/pylint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix false negative for used-before-assignment (ExceptHandler)
Closes pylint-dev#626.
- Loading branch information
1 parent
9ae559d
commit 0de8400
Showing
6 changed files
with
100 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# pylint: disable=missing-docstring,invalid-name | ||
def main1(): | ||
try: | ||
raise ValueError | ||
except ValueError as e: # [unused-variable] | ||
pass | ||
|
||
print(e) # [used-before-assignment] | ||
|
||
|
||
def main2(): | ||
try: | ||
raise ValueError | ||
except ValueError as e: | ||
print(e) | ||
|
||
|
||
def main3(): | ||
try: | ||
raise ValueError | ||
except ValueError as e: # [unused-variable] | ||
pass | ||
|
||
e = 10 | ||
print(e) | ||
|
||
|
||
def main4(): | ||
try: | ||
raise ValueError | ||
except ValueError as e: # [unused-variable] | ||
pass | ||
|
||
try: | ||
raise ValueError | ||
except ValueError as e: | ||
pass | ||
|
||
try: | ||
raise ValueError | ||
except ValueError as e: | ||
pass | ||
|
||
print(e) # [used-before-assignment] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
unused-variable:5:4:main1:Unused variable 'e' | ||
used-before-assignment:8:10:main1:Using variable 'e' before assignment | ||
unused-variable:21:4:main3:Unused variable 'e' | ||
unused-variable:31:4:main4:Unused variable 'e' | ||
used-before-assignment:44:10:main4:Using variable 'e' before assignment |