On 7/6/22 17:01, Steve Jorgensen wrote:
> Perhaps, this has already been addressed in a newer release (?) but in Python
3.9, making
> `@dataclass` work with `Enum` is a bit awkward.
>
> Currently, it order to make it work, I have to:
> 1. Pass `init=False` to `@dataclass` and hand-write the `__i
On 7/7/22 09:01, Steve Jorgensen wrote:
> Actually, maybe these are fundamentally incompatible? `@dataclass` is a
decorator, so it
> acts on the class after it was already defined, but `Enum` acts before that
when `@dataclass`
> cannot have not generated the `__init__` yet. Right?
Correct.
--
On 7/7/22 18:22, Steve Jorgensen wrote:
> After some playing around, I figured out a pattern that works without any
changes to the
> implementations of `dataclass` or `Enum`, and I like this because it keeps
the 2 kinds of
> concern separate. Maybe I'll try submitting an MR to add an example li
On 7/8/22 19:50, Ethan Furman wrote:
> The repr from a combined dataclass/enum looks like a dataclass, giving no
clue that the
> object is an enum, and omitting any information about which enum member it is
and which
> enum it is from.
Fixed in 3.11: ``
--
~Ethan~
___
On 7/9/22 12:19, Steve Jorgensen wrote:
> [...] It works great to combine them by defining the dataclass as a mixin for
the Enum class. Why would
> it not be good to include that as an example in the official docs, assuming
(as I believe) that it is a
> particularly useful combination?
Do you