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

False-positive of unused-private-member with class reference #4849

Closed
yumasheta opened this issue Aug 15, 2021 · 2 comments · Fixed by #4949
Closed

False-positive of unused-private-member with class reference #4849

yumasheta opened this issue Aug 15, 2021 · 2 comments · Fixed by #4949
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@yumasheta
Copy link
Contributor

yumasheta commented Aug 15, 2021

Bug description

Consider the following code snippet:

"""p.py"""

class UnusedPrivateMember:
    """unused-private-member (W0238)"""

    @staticmethod
    def __private_method():
        """Is private and does nothing."""

    @classmethod
    def use_private_method(cls):
        """Calls private method."""
        cls.__private_method()

Configuration

No response

Command used

pylint p.py

Pylint output

W0238: Unused private member `UnusedPrivateMember.__private_method()` (unused-private-member)

Expected behavior

Calling a private static method only on cls (reference to class) in a classmethod produces false positive: unused-private-member.

#4782 recently fixed some issues regarding the usage of private members on the class name. This one seems to have slipped through.

Thanks.

Pylint version

pylint 2.10.0-dev0
astroid 2.6.6
Python 3.9.6 (default, Jun 30 2021, 10:22:16) 
[GCC 11.1.0]


### OS / Environment

_No response_

### Additional dependencies

_No response_
@yumasheta yumasheta added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 15, 2021
@yumasheta yumasheta changed the title False-positive of unused-private-member with class name False-positive of unused-private-member with class reference Aug 15, 2021
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 15, 2021
@cdce8p
Copy link
Member

cdce8p commented Aug 16, 2021

/CC: @yushao2

@yumasheta
Copy link
Contributor Author

I think the fix is easier than I thought. Though, please look at my PR, as I never used astroid before.

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

Successfully merging a pull request may close this issue.

3 participants