konradhalas / dacite

Simple creation of data classes from dictionaries.
MIT License
1.72k stars 106 forks source link

subclassing support for type_hooks #255

Open maticus opened 4 months ago

maticus commented 4 months ago

The 'cast' option has subclassing support:

It also works with base classes - if T is a base class of type S, all fields of type S will be also "casted".

I'd love to see this in type_hooks as well.

One concrete use case that I have is I'd like to create Enums using their members' names (not values).

tiagobonetti commented 3 months ago

I second that.

I currently use a decorator to register enums to the hooks individually but that adds unnecessary shared state that could be removed.