cattrs icon indicating copy to clipboard operation
cattrs copied to clipboard

An initial implementation of unstructuring and structuring enums with complex values

Open reversefold opened this issue 1 month ago • 2 comments

Fixes #699. The values of an Enum are unstructured and structured. Structuring is only done when the Enum class has a type defined for the _value_ attribute as per the Python typing standard.

I've added two very simple tests which show that this works. I'm attempting to add tests which use hypothesis like the rest but the magic chains of incantations in tests/typed.py are throwing me a bit and it's taking a while to understand what they're doing and how to use it to generate random dynamic Enum classes. Any pointers there would be appreciated.

reversefold avatar Dec 02 '25 11:12 reversefold

Thanks for working on this, I will review within a couple days when I get some time. Don't worry about Hypothesis, I'm kind of moving away from it, since it bloats the test times and can turn out to be very complex to use properly, so the cost/benefit ratio is usually in favor of just normal unit tests. :)

Tinche avatar Dec 02 '25 12:12 Tinche

Sorry for the delay, I'm a little under the weather.

Looks like good work, left some comments.

No worries on the delay. Comments should be addressed in the additional commits.

reversefold avatar Dec 10 '25 01:12 reversefold

LGTM, thanks.

I might work on this a little more before releasing the next version, to see if I can convert this code into a hook factory for more speed. I also might not, time-depending.

Tinche avatar Dec 14 '25 13:12 Tinche