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 on Unused-private-member for nested function #4673

Closed
WoollyMammal opened this issue Jul 5, 2021 · 1 comment · Fixed by #4709
Closed

False Positive on Unused-private-member for nested function #4673

WoollyMammal opened this issue Jul 5, 2021 · 1 comment · Fixed by #4709
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@WoollyMammal
Copy link

WoollyMammal commented Jul 5, 2021

Looks like the unused-private-member warning is getting a false positive for nested functions.
E.g: testthing.py

""" Testing for false positive of the unused-private-member pylint test. """

class TestNest:
    """ The testing class """

    def __init__(self, in_thing):
        self.thing = False
        self.do_thing(in_thing)

    def do_thing(self, in_thing):
        """ Checks the false-positive condition, sets a property. """
        def __false_positive(in_thing):
            print(in_thing)
        __false_positive(in_thing)
        self.thing = True

    def undo_thing(self):
        """ Unsets a property. """
        self.thing = False

And turns out that even for test-cases I can't bring myself to get a bad pylint score.
Oh well.

************* Module testthing
testthing.py:12:8: W0238: Unused private member `TestNest.__false_positive(in_thing)` (unused-private-member)

------------------------------------------------------------------
Your code has been rated at 9.09/10 (previous run: 9.09/10, +0.00)

Currently running:

# pylint --version
pylint 2.9.1
astroid 2.6.2
Python 3.7.5 (default, Nov  7 2019, 10:50:52)
[GCC 8.3.0]
@Pierre-Sassoulas Pierre-Sassoulas added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Jul 5, 2021
@Pierre-Sassoulas
Copy link
Member

@yushao2 , here's another use case for unused-private-member :)

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 a pull request may close this issue.

3 participants