save and to_dict now have a save_dc_types argument.
When set, this saves the types of dataclass attributes in a new
entry in the dict. By default, this is saved in "_type_".
load has been improved:
When loading, if the "_type_" key is present, returns an
instance of that type.
When drop_extra_fields is False, tries to use subclasses of
the annotated type, rather than subclasses of Serializable.
This means that dataclasses that don't subclass Serializable can
still be dynamically found and used when loading a dataclass.
get_decoding_fn's lru_cache has been disabled. If this causes
significant performance drops, let me know.
Unit tests are no longer run twice (using the regular and 'simple'
APIs). This was causing a lot of weird bugs, as some unit tests
were leaking from one run to the other, particularly tests involving
deserialization of dataclasses.
Improve
load
/save
functions (see desc.)Fixes #173
save
andto_dict
now have asave_dc_types
argument."_type_"
.load
has been improved:"_type_"
key is present, returns an instance of that type.When
drop_extra_fields
is False, tries to use subclasses of the annotated type, rather than subclasses of Serializable.This means that dataclasses that don't subclass Serializable can still be dynamically found and used when loading a dataclass.
get_decoding_fn
'slru_cache
has been disabled. If this causes significant performance drops, let me know.Unit tests are no longer run twice (using the regular and 'simple' APIs). This was causing a lot of weird bugs, as some unit tests were leaking from one run to the other, particularly tests involving deserialization of dataclasses.
Signed-off-by: Fabrice Normandin normandf@mila.quebec