-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
acceptedReady for implementationReady for implementationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Motivation
There was a bug in archinstall because a dataclass decorator was incorrectly applied to an Enum:
@dataclass
class Audio(Enum):
NoAudio = 'No audio server'
Pipewire = 'pipewire'
...The Python docs warn about such usage, but I am not aware of any linter that currently catches the error:
Adding dataclass() decorator to Enum and its subclasses is not supported. It will not raise any errors, but it will produce very strange results at runtime, such as members being equal to each other
Note: The docs mention that dataclass mixins can be used with enums, so there are some valid combinations of the constructs.
Related discussions
- Match on Enum with dataclass decorator python/cpython#114803
- gh-114803: Mention that
@dataclassshould not be applied on enums python/cpython#114891
Documentation
Real world bugs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
acceptedReady for implementationReady for implementationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule