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 invalid-overridden-method when overridding Enum.value #9905

Open
e-gebes opened this issue Sep 2, 2024 · 0 comments
Open
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@e-gebes
Copy link

e-gebes commented Sep 2, 2024

Bug description

import enum


class Thing(enum.Enum):
    A = enum.auto()

    @property
    def value(self):
        return "thing"

Configuration

No response

Command used

pylint a.py

Pylint output

************* Module a
8:4: W0236: Method 'value' was expected to be 'method', found it instead as 'property' (invalid-overridden-method)

Expected behavior

I tried to lint some legacy code and thought this might be a false positive.
I would expect no warning, or how could I otherwise override value from the Enum class? (not saying this is a good idea in general)

Maybe this is related to decorators: #8939 and the CPython implementation also has a decorator which is similar to a property:

https://github.com/python/cpython/blob/3.10/Lib/enum.py#L802

    @DynamicClassAttribute
    def value(self):
        """The value of the Enum member."""
        return self._value_

Pylint version

pylint 2.17.7
astroid 2.15.8
Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]

OS / Environment

No response

Additional dependencies

No response

@e-gebes e-gebes added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

1 participant