You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I was surprised to learn that deepfreeze(Enum.VALUE) produced a frozendict(Enum.VALUE.__dict__). I expected it to return the enum. E.g.:
>>> from enum import Enum
>>> from frozendict import deepfreeze
>>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])
>>> deepfreeze(Color.RED)
frozendict.frozendict({'_value_': 1, '_name_': 'RED', '__objclass__': <enum 'Color'>})
Describe the solution you'd like
Consider making Enum.VALUE an immutable scalar by default.
Describe alternatives you've considered
I know I can register a custom conversion:
>>> from enum import Enum
>>> from frozendict import deepfreeze
>>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])
>>> deepfreeze(Color.RED, custom_converters={Enum: lambdax: x})
Color.RED
or
>>> from enum import Enum
>>> from frozendict import deepfreeze, register
>>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])
>>> register(Enum, lambdax: x)
>>> deepfreeze(Color.RED)
Color.RED
Additional context
While I understand this can be easily configured on my end via the register function I'm wondering if it makes more sense to treat enums as immutable scalars by default.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I was surprised to learn that
deepfreeze(Enum.VALUE)
produced afrozendict(Enum.VALUE.__dict__)
. I expected it to return the enum. E.g.:Describe the solution you'd like
Consider making
Enum.VALUE
an immutable scalar by default.Describe alternatives you've considered
I know I can register a custom conversion:
or
Additional context
While I understand this can be easily configured on my end via the
register
function I'm wondering if it makes more sense to treat enums as immutable scalars by default.The text was updated successfully, but these errors were encountered: