Skip to content

Fix false-positive for unused-import on class keyword arguments #4207

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

Merged
merged 2 commits into from
Mar 28, 2021
Merged

Fix false-positive for unused-import on class keyword arguments #4207

merged 2 commits into from
Mar 28, 2021

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Mar 7, 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

Fix a false-positive the occurs after pylint-dev/astroid#919 is merged.

from const import DOMAIN_2  # would be (falsely) flagged as unused-import

class Child:
    def __init_subclass__(cls, **kwargs):
        pass
class Parent_2(Child, domain=DOMAIN_2):
    DOMAIN_2 = DOMAIN_2

Furthermore, I added some test cases for #3202.

This MR depends on pylint-dev/astroid#919

Type of Changes

Type
🐛 Bug fix

Related Issue

Closes #3202

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.

Great work !

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code Work in progress labels Mar 14, 2021
@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 91.429% when pulling e97a975 on cdce8p:fix-unused-import into 12acc43 on PyCQA:master.

@cdce8p
Copy link
Member Author

cdce8p commented Mar 28, 2021

@Pierre-Sassoulas This MR is ready now. I've included the astroid version bump to 2.5.2 in the last commit.

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.

👍

@Pierre-Sassoulas Pierre-Sassoulas merged commit 95daeca into pylint-dev:master Mar 28, 2021
@cdce8p cdce8p deleted the fix-unused-import branch March 28, 2021 18:30
@KapJI
Copy link

KapJI commented Mar 30, 2021

@cdce8p Huge thanks for driving this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive for unused-import on class keyword arguments
4 participants