Closed BrianPugh closed 3 weeks ago
I think the solution is:
import attrs
import cattrs
converter.register_structure_hook_factory(
attrs.has,
lambda cl: cattrs.gen.make_dict_structure_fn(cl, converter, _cattrs_use_alias=True)
)
would love to have @Tinche to chime in if this is the intended solution (and then close this issue)! Thanks!
You got to it before I did! That's exactly what I would have suggested.
thank you!
In my application, i have several nested structures that have attrs aliases set (e.g.
field(..., alias="foo")
). I am aware that I could individually register a hook for every class with:However, this requires the developer to remember to do that for every new class. Is there a way of applying this setting for the whole converter?