-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeenum
Milestone
Description
Bug description
Pylint incorrectly flags an Enum inherited from a parent Enum which has annotations. This is useful when overriding __new__
or __init__
on the parent Enum to add extra data to the Enum members while also keeping the codebase typed. Example:
example.py
from enum import Enum
class ColorEnum(Enum):
red: int
green: int
blue: int
def __init__(self, red: int, green: int, blue: int) -> None:
self.red = red
self.green = green
self.blue = blue
class Pastel(ColorEnum):
SAGE = (170, 200, 167)
Configuration
No response
Command used
pylint example.py
Pylint output
************* Module example
example.py:14:0: E0244: Extending inherited Enum class "ColorEnum" (invalid-enum-extension)
Expected behavior
No output
Pylint version
pylint 2.17.4
astroid 2.15.5
Python 3.8.16 (default, Mar 15 2023, 13:36:46)
[Clang 14.0.0 (clang-1400.0.29.202)]
OS / Environment
macOS Ventura 13.2.1
Additional dependencies
No response
jacobtylerwalls
Metadata
Metadata
Assignees
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeenum