Save an indentation level and make code more clear
This commit is contained in:
parent
048c2666c6
commit
d3ca25550d
|
@ -412,15 +412,17 @@ def _transform_attrs(cls, these, auto_attribs, kw_only):
|
||||||
# Traverse the MRO and collect attributes.
|
# Traverse the MRO and collect attributes.
|
||||||
for base_cls in cls.__mro__[1:-1]:
|
for base_cls in cls.__mro__[1:-1]:
|
||||||
sub_attrs = getattr(base_cls, "__attrs_attrs__", None)
|
sub_attrs = getattr(base_cls, "__attrs_attrs__", None)
|
||||||
if sub_attrs is not None:
|
if sub_attrs is None:
|
||||||
for a in sub_attrs:
|
continue
|
||||||
prev_a = taken_attr_names.get(a.name)
|
|
||||||
# Only add an attribute if it hasn't been defined before. This
|
for a in sub_attrs:
|
||||||
# allows for overwriting attribute definitions by subclassing.
|
prev_a = taken_attr_names.get(a.name)
|
||||||
if prev_a is None:
|
# Only add an attribute if it hasn't been defined before. This
|
||||||
base_attrs.append(a)
|
# allows for overwriting attribute definitions by subclassing.
|
||||||
taken_attr_names[a.name] = a
|
if prev_a is None:
|
||||||
base_attr_map[a.name] = base_cls
|
base_attrs.append(a)
|
||||||
|
taken_attr_names[a.name] = a
|
||||||
|
base_attr_map[a.name] = base_cls
|
||||||
|
|
||||||
attr_names = [a.name for a in base_attrs + own_attrs]
|
attr_names = [a.name for a in base_attrs + own_attrs]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue