MCPcopy
hub / github.com/python-attrs/attrs / _collect_base_attrs_broken

Function _collect_base_attrs_broken

src/attr/_make.py:351–376  ·  view source on GitHub ↗

Collect attr.ibs from base classes of *cls*, except *taken_attr_names*. N.B. *taken_attr_names* will be mutated. Adhere to the old incorrect behavior. Notably it collects from the front and considers inherited attributes which leads to the buggy behavior reported in #428.

(cls, taken_attr_names)

Source from the content-addressed store, hash-verified

349
350
351def _collect_base_attrs_broken(cls, taken_attr_names):
352 """
353 Collect attr.ibs from base classes of *cls*, except *taken_attr_names*.
354
355 N.B. *taken_attr_names* will be mutated.
356
357 Adhere to the old incorrect behavior.
358
359 Notably it collects from the front and considers inherited attributes which
360 leads to the buggy behavior reported in #428.
361 """
362 base_attrs = []
363 base_attr_map = {} # A dictionary of base attrs to their classes.
364
365 # Traverse the MRO and collect attributes.
366 for base_cls in cls.__mro__[1:-1]:
367 for a in getattr(base_cls, "__attrs_attrs__", []):
368 if a.name in taken_attr_names:
369 continue
370
371 a = a.evolve(inherited=True) # noqa: PLW2901
372 taken_attr_names.add(a.name)
373 base_attrs.append(a)
374 base_attr_map[a.name] = base_cls
375
376 return base_attrs, base_attr_map
377
378
379def _transform_attrs(

Callers 1

_transform_attrsFunction · 0.85

Calls 1

evolveMethod · 0.80

Tested by

no test coverage detected