def _structure_attr_from_dict(self, a, name, mapping):
"""Handle an individual attrs attribute structuring."""
val = mapping.get(name, NOTHING)
if val is NOTHING:
return NOTHING
type_ = a.type
if type_ is None:
# No type.
return val
if _is_union_type(type_):
if NoneType in type_.__args__ and val is None:
return None
return self._structure_union(val, type_)
return self._structure.dispatch(type_)(val, type_)
评论列表
文章目录