79368715

Date: 2025-01-19 09:45:13
Score: 1
Natty:
Report link

To add more detail to the answer above,

One can make the situation work (make members of an enum work as fields of enclosing superclass)

class Color2(Enum):
   RED : int = 1
   BLUE : int = 2

Annotating attributes with types, means dataclass will recognize them as fields,

Source :- https://docs.python.org/3/library/dataclasses.html

The @dataclass decorator examines the class to find fields. A field is defined as a class variable that has a type annotation.

Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @dataclass
  • Low reputation (0.5):
Posted by: user3478180