def structure_attrs_fromdict(self, obj, cl):
# type: (Mapping, Type) -> Any
"""Instantiate an attrs class from a mapping (dict)."""
# For public use.
conv_obj = obj.copy() # Dict of converted parameters.
for a in cl.__attrs_attrs__:
name = a.name
# We detect the type by metadata.
converted = self._structure_attr_from_dict(a, name, obj)
if converted is not NOTHING:
conv_obj[name] = converted
return cl(**conv_obj)
评论列表
文章目录