Commit e2c0819
authored
* Improve `load`/`save` functions (see desc.)
- Fixes #173
- `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.
- Updated the regression file names due to this
- Update some other test regression files
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
---------
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
1 parent 0059dd7 commit e2c0819
File tree
32 files changed
+325
-355
lines changed- simple_parsing
- helpers
- serialization
- test
- helpers
- test_encoding
- test_subgroups
32 files changed
+325
-355
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
348 | 350 | | |
349 | 351 | | |
350 | 352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| |||
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
87 | | - | |
| 92 | + | |
88 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
89 | 97 | | |
90 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
91 | 103 | | |
92 | 104 | | |
93 | 105 | | |
| |||
0 commit comments