-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix unused-variable
false positive when using same name for multiple exceptions
#10436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #10436 +/- ##
=======================================
Coverage 95.88% 95.88%
=======================================
Files 176 176
Lines 19140 19144 +4
=======================================
+ Hits 18352 18356 +4
Misses 788 788
π New features to boost your workflow:
|
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit a9b2599 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
) -> bool: | ||
return ( | ||
isinstance(stmt.parent, nodes.ExceptHandler) | ||
and stmt is stmt.parent.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand what this is
condition is for? No tests fail when I remove it.
Type of Changes
Description
Somewhat related to #4791. When investigating the issue, I noticed that the false positive is only emitted when checking for global unused variables. It is fine when the try block is nested within a function like:
There seems to be existing logic handling this as a special case, so I extracted it into a function and reused it for the global unused variable check.
Closes #10426