Skip to content

False positives invalid-enum-extension #6887

@Bibo-Joshi

Description

@Bibo-Joshi

Bug description

That check doesn't seem to check if the parent class actually defines enumeration members. This happens only if the parent class is defined in a differen module. MWE:

bar.py

import Enum

class StringEnum(str, Enum):
    def __repr__(self) -> str:
        return f"<{self.__class__.__name__}.{self.name}>"

foo.py

from bar import StringEnum


class ChatType(StringEnum):

    SENDER = "sender"
    PRIVATE = "private"

Configuration

No response

Command used

`pylint foo.py`

Pylint output

************* Module foo
foo.py:1:0: C0114: Missing module docstring (missing-module-docstring)
foo.py:1:0: C0104: Disallowed name "foo" (disallowed-name)
foo.py:4:0: E0244: Extending inherited Enum class "StringEnum" (invalid-enum-extension)

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

Expected behavior

pylint either checks the parent class for enum members or does enable this warning by default

Pylint version

pylint 2.14.1
astroid 2.11.5
Python 3.8.5

OS / Environment

Windows

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds astroid updateNeeds an astroid update (probably a release too) before being mergableenum

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions