Skip to content

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

@WoollyMammal

Description

@WoollyMammal

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]

Metadata

Metadata

Assignees

Labels

False Positive 🦟A message is emitted but nothing is wrong with the code

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions