Open dlwh opened 1 year ago
Hey @dlwh , encoding = dc->dict (via the encode
function) and decoding = dict->dc
Therefore asdict is more about encoding, and therefore I dont understand why calling asdict on the dataclass would be wrong if it has a custom decoding function registered.
I dont completely understand the test in the issue atm. I'll take a better look a bit later today.
When parsing with a config file, the custom decoding function isnt being used?
Would you mind helping me out @dlwh ? I'm still having trouble understanding what the issue is here.
Yes, dataclasses that have custom decode functions (like Id
in the example) don't use that custom decode function when parsing from a "json dict", or when using argparse. I had a mostly complete fix in #267.
(FWIW, I ended up forking Pyrallis so I'm going it alone, so happy to just close this.)
Describe the bug
The default parsing logic seems to want to call asdict on a dataclass field even if it has a registered decoding function:
To Reproduce
Expected behavior Test should pass.
Actual behavior
Last assertion fails:
Desktop (please complete the following information):
Additional context