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

Added suggestion in helptext for unnecessary-comprehension checker #4500

Merged
merged 5 commits into from
May 25, 2021

Conversation

yushao2
Copy link
Collaborator

@yushao2 yushao2 commented May 24, 2021

Steps

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • 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

Improved help text for unnecessary-comprehension -- now provides suggestion of what could be used instead.

E.g:

a_dict = dict()
[(k, v) for k, v in a_dict.items()]  # [unnecessary-comprehension]

Help text:

unnecessary-comprehension:17:0::Unnecessary use of a comprehension, use list(a_dict.items()) instead.

Type of Changes

Type
📝 Documentation
🔨 Refactoring

Related Issue

Closes #4499

@coveralls
Copy link

coveralls commented May 24, 2021

Coverage Status

Coverage increased (+0.002%) to 91.827% when pulling 0912d67 on yushao2:refactoring-4499 into 44eab78 on PyCQA:master.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Looks good, maybe we could also advise "use my_list" instead of "use list(my_list) if it's already a set/list/dict ? :) (Yes, I've seen this this in a real code base 😄)

@Pierre-Sassoulas Pierre-Sassoulas added the Enhancement ✨ Improvement to a component label May 24, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.8.3 milestone May 24, 2021
@yushao2
Copy link
Collaborator Author

yushao2 commented May 24, 2021

Looks good, maybe we could also advise "use my_list" instead of "use list(my_list) if it's already a set/list/dict ? :) (Yes, I've seen this this in a real code base )

oops -- my bad. I'll try to incorporate those in

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Nice work again ! :)

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 comments

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
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.

LGTM

@Pierre-Sassoulas Pierre-Sassoulas merged commit d7c904f into pylint-dev:master May 25, 2021
@yushao2 yushao2 deleted the refactoring-4499 branch May 25, 2021 13:38
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.8.3, 2.9.0 May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive unnecessary-comprehension when modifying a dict to a list of tuples
4 participants