-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 false-positives of unnecessary-dict-index-lookup
and consider-using-dict-items
#4640
Fix false-positives of unnecessary-dict-index-lookup
and consider-using-dict-items
#4640
Conversation
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 for taking the time to look at this issue! I left a few comments, mostly minor stuff.
3dae100
to
10bdef1
Compare
tests/functional/u/unnecessary/unnecessary_dict_index_lookup.py
Outdated
Show resolved
Hide resolved
tests/functional/u/unnecessary/unnecessary_dict_index_lookup.py
Outdated
Show resolved
Hide resolved
078bd9c
to
0714703
Compare
@Pierre-Sassoulas seems like assigning 0 to a var makes it a constant, and naming convention is to be UPPERCASE. I assigned an empty list to it instead, and changed += to .append. |
0714703
to
f6e1f85
Compare
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
f6e1f85
to
6e6c3a3
Compare
Oups, I did not see that, I disabled the invalid-name and force pushed. Sorry ! |
that's fine! i think both ways work 😆 thanks! |
Steps
doc/whatsnew/<current release.rst>
.Description
Fix for false-positives described in #4630, when an dict index lookup has been reassigned.
dict index lookup after the reassignment are necessary
example:
output:
Therefore, using
d[k]
after reassignment should be ignoredThis is implemented by returning after encountering an
astroid.AugAssign
orastroid.Assign
and ignorenodes occurring after this.
Type of Changes
Related Issue
Closes #4630