-
-
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
New checker unnecessary-list-index-lookup
(#4525)
#5834
New checker unnecessary-list-index-lookup
(#4525)
#5834
Conversation
8fc9d8c
to
7e626dd
Compare
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.
Thank you for opening the pull request, this look goods already. I think we'll be able to add this to 2.14, but we need to release 2.13 at some point and we're lagging behind all the contributions π. Could you move the changelog to 2.14 ? I know the "what's new" page for 2.14 is not created yet, sorry.
tests/functional/u/unnecessary/unnecessary_list_index_lookup.py
Outdated
Show resolved
Hide resolved
9502b59
to
c7c0c51
Compare
Pull Request Test Coverage Report for Build 2042126251
π - 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.
This looks very good already!
I left some comments, let me know if you have any questions about them π
dd8f358
to
7076fe0
Compare
# enumerate() result is being assigned without destructuring | ||
return | ||
|
||
iterating_object_name = node.iter.args[0].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.
I'm wondering if there are edge cases to consider with len(args) > 1
, but I think in those cases using the index is so unnecessarily complicated that most people will have moved to using value
at that point. So I think we can leave those edge cases unconsidered here.
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 a lot @timmartin, this looks good to me!
@Pierre-Sassoulas Depending on your schedule and free time, we might actually get this reviewed and merged before we release 2.11
. No rush though!
Hi @timmartin, I know I already approved this PR, but... |
43dce52
to
0f794ae
Compare
I've rebased and added documentation now. |
4fdb3ba
to
207060d
Compare
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.
Thank you for the two examples, looks great !
Type of Changes
Description
Added a new checker for catching the case of iterating over a list using
enumerate()
:This will now report
Closes #4525