Closed ljnsn closed 3 months ago
Hi,
if you're overriding the entire attrs hook you'll need to pass in _cattrs_prefer_attrib_converter
yourself, like this:
def _to_alias_structure(
cls: type[Any],
) -> Callable[[Mapping[str, Any], Any], Callable[[Any, Any], Any]]:
"""Structure hook using alias."""
return make_dict_structure_fn(
cls, converter, _cattrs_use_alias=True, _cattrs_prefer_attrib_converters=True
)
That said, I realize it'd be better if make_dict_structure_fn
took the value of that parameter from the converter itself, so I've created https://github.com/python-attrs/cattrs/pull/528 to address this for the next version.
Ah makes sense, thanks for the quick response and explanation :slightly_smiling_face:
Description
I want to use the converter set on a field of an
attrs
model of mine. The field also has an alias. Trying to structure withcattrs
doesn't work in this case.What I Did