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: method-hidden with @functools.cached_property #8753

Closed
Gidgidonihah opened this issue Jun 7, 2023 · 1 comment · Fixed by #8758 or #9093
Closed

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

Gidgidonihah opened this issue Jun 7, 2023 · 1 comment · Fixed by #8758 or #9093
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Good first issue Friendly and approachable by new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@Gidgidonihah
Copy link

Gidgidonihah commented Jun 7, 2023

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

@Gidgidonihah Gidgidonihah added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jun 7, 2023
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jun 8, 2023
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue. It still affects pylint 3.0.0b1, I think it's fair to also exclude cached_property from this check.

@jacobtylerwalls jacobtylerwalls added the Good first issue Friendly and approachable by new contributors label Jun 8, 2023
kyoto7250 added a commit to kyoto7250/pylint that referenced this issue Jun 10, 2023
kyoto7250 added a commit to kyoto7250/pylint that referenced this issue Jun 10, 2023
@jacobtylerwalls jacobtylerwalls added this to the 2.17.5 milestone Jun 10, 2023
kyoto7250 added a commit to kyoto7250/pylint that referenced this issue Jun 13, 2023
github-actions bot pushed a commit that referenced this issue Jun 22, 2023
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 Good first issue Friendly and approachable by new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
3 participants