Tin Tvrtković wrote:
I propose adding some magic, so we get this instead: ``` class Message(Enum): QUIT = "quit" @dataclass class Move: x: int y: int @dataclass class Write: msg: str @dataclass class ChangeColor: r: int g: int b: int ```
I am sympathetic to this design. Right now, `Enum` rewrites that `"quit"` value so that `Message.QUIT` is not actually equal to `"quit"`, but is actually an instance of `Message`. If the syntax of `Enum` was expanded to allow not just values, but classes, then `Move`, `Write`, and `ChangeColor` would have to be rebuilt to be subclasses of `Message`. I am not sure what all the implications of that would be. I remember there was hesitation toward having dataclasses add `__slots__` because it required rebuilding each class from scratch [1], but that was ultimately resolved in favor of rebuilding [2]. I have not heard any horror stories about dataclass slots, so maybe it's ok. [1] https://bugs.python.org/issue42269 [2] https://github.com/python/cpython/blob/859250cc55711f4d62b65922d3f7537826c38...