Closed nickjmiller closed 1 year ago
@nickjmiller thank you for reporting this issue.
Your dataclass is frozen=True
and your field is init=True
. There is no way to setup this field via dacite
so you shouldn't pass {'y': 'value'}
in your data.
On the other hand I fixed #195 - it's very similar issue but with empty data. I hope it works in your case too.
I have a usecase where I am loading and dumping dataclasses to json. Some dataclasses have a field that should not change, but I'd still like this field to show up in
asdict
, since the classes are indistinguishable otherwise as JSON. Usingfield(init=False, default="value")
, I can get the behavior I want, but dacite is not able to parse this into its original dataclass.Minimal example:
Without
init=False
:Can
from_dict
be modified to respect default values wheninit=False
?