-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix #5713: Emit used-before-assignment
instead of undefined-variable
when accessing unused type annotations
#5718
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
Fix #5713: Emit used-before-assignment
instead of undefined-variable
when accessing unused type annotations
#5718
Conversation
β¦ned-variable` when accessing unused type annotations
Pull Request Test Coverage Report for Build 1746877150
π - Coveralls |
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.
It's a nice consistency refactor, thank you π I think we can do it as the number of false positives for those two message is probably low and of disable of those message even lower.
for more information, see https://pre-commit.ci
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.
π
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.
Thanks @jacobtylerwalls for looking into this. I think this makes sense (even though somewhat breaking)!
This fails on |
@DanielNoord actually this failure looks "random" -->
Note the test suite passed on all other runners. π€ |
I came to the same conclusion when looking at it (I'm notified if what I merge fail on main). |
Type of Changes
Description
This one is somewhat pedantic, sorry! I simply noticed that we could attempt to raise more targeted messages so that
undefined-variable
corresponds generally withNameError
andused-before-assignment
corresponds generally withUnboundLocalError
. The only use of the message affected by this PR is new in 2.12, so hopefully not breaking too many existing disables. But I suppose that should be balanced against people suppressingundefined-variable
that would be glad to getused-before-assignment
coming through now.See example shell session drawn from existing unit tests adjusted in this PR:
Closes #5713