Skip to content

False Positive: method-hidden with @functools.cached_property #8753

@Gidgidonihah

Description

@Gidgidonihah

Bug description

When decorating a method with @functools.cached_property pylint produces the error method-hidden whereas decorating it with @property does not.

example.py:

# pylint: disable=too-few-public-methods
"""A bug report example."""
import functools


class Base:
    """Generic base class."""

    def __init__(self, example):
        self.example = example


class Extended(Base):
    """Class showing the method-hidden error."""

    @functools.cached_property
    def example(self):
        """
        This is a property and should be cached, but should not product method-hidden.
        """
        return "expensive function"

Configuration

No response

Command used

pylint example.py

Pylint output

************* Module example
example.py:17:4: E0202: An attribute defined in example line 10 hides this method (method-hidden)

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

Expected behavior

The method-hidden error should not be emitted.

Pylint version

pylint 2.15.8
astroid 2.12.13
Python 3.10.6 (main, Aug 31 2022, 16:28:02) [Clang 13.1.6 (clang-1316.0.21.2.5)]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeGood first issueFriendly and approachable by new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions