Skip to content
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

Implemented new check unnecessary-dict-index-lookup #4485

Merged
merged 11 commits into from May 23, 2021

Conversation

yushao2
Copy link
Collaborator

@yushao2 yushao2 commented May 21, 2021

Steps

  • Add a ChangeLog entry describing what your PR does
  • If it's a new feature or an important bug fix, add a What's New entry in
    doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

Implemented a new checker, unnecessary-dict-indexing, which detects for instances where index-lookup is used with dict.items().

Type of Changes

Type
✨ New feature

Related Issue

Closes #4470

@coveralls
Copy link

coveralls commented May 21, 2021

Coverage Status

Coverage increased (+0.0005%) to 91.723% when pulling 42a2fde on yushao2:checkers-4470 into be2bf84 on PyCQA:master.

@cdce8p cdce8p self-requested a review May 21, 2021 23:29
@cdce8p

This comment has been minimized.

@cdce8p cdce8p self-assigned this May 22, 2021
@yushao2

This comment has been minimized.

@yushao2

This comment has been minimized.

Copy link
Member

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial comments. This looks pretty good already.

I was thinking about if we maybe should change the name a bit. Something like unnecessary-dict-index-lookup. What do you think?

ChangeLog Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
@yushao2
Copy link
Collaborator Author

yushao2 commented May 23, 2021

Some initial comments. This looks pretty good already.

I was thinking about if we maybe should change the name a bit. Something like unnecessary-dict-index-lookup. What do you think?

sure! I'll make the change

@yushao2 yushao2 changed the title Implemented new check unnecessary-dict-indexing Implemented new check unnecessary-dict-index-lookup May 23, 2021
@yushao2
Copy link
Collaborator Author

yushao2 commented May 23, 2021

sorry about that, was trying to work on some other checker but forgot to switch branches

Copy link
Member

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the refactoring you did! Some more comments

doc/whatsnew/2.9.rst Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
pylint/checkers/refactoring/refactoring_checker.py Outdated Show resolved Hide resolved
@cdce8p cdce8p added Enhancement ✨ Improvement to a component Checkers Related to a checker labels May 23, 2021
@yushao2 yushao2 requested a review from cdce8p May 23, 2021 16:40
Copy link
Member

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one done 🚀

@cdce8p cdce8p merged commit b199fa6 into pylint-dev:master May 23, 2021
@Pierre-Sassoulas
Copy link
Member

You're on fire @yushao2 :) afaik 75% of the new checkers in 2.9, not bad !

@yushao2 yushao2 deleted the checkers-4470 branch May 24, 2021 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Checkers Related to a checker Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New checker for when an index-lookup is used together with dict.items()
4 participants