MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / wrap

Function wrap

src/licensedcode/_vendor/attr/_make.py:1511–1622  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

1509 on_setattr = setters.pipe(*on_setattr)
1510
1511 def wrap(cls):
1512
1513 if getattr(cls, "__class__", None) is None:
1514 raise TypeError("attrs only works with new-style classes.")
1515
1516 is_frozen = frozen or _has_frozen_base_class(cls)
1517 is_exc = auto_exc is True and issubclass(cls, BaseException)
1518 has_own_setattr = auto_detect and _has_own_attribute(
1519 cls, "__setattr__"
1520 )
1521
1522 if has_own_setattr and is_frozen:
1523 raise ValueError("Can't freeze a class with a custom __setattr__.")
1524
1525 builder = _ClassBuilder(
1526 cls,
1527 these,
1528 slots,
1529 is_frozen,
1530 weakref_slot,
1531 _determine_whether_to_implement(
1532 cls,
1533 getstate_setstate,
1534 auto_detect,
1535 ("__getstate__", "__setstate__"),
1536 default=slots,
1537 ),
1538 auto_attribs,
1539 kw_only,
1540 cache_hash,
1541 is_exc,
1542 collect_by_mro,
1543 on_setattr,
1544 has_own_setattr,
1545 field_transformer,
1546 )
1547 if _determine_whether_to_implement(
1548 cls, repr, auto_detect, ("__repr__",)
1549 ):
1550 builder.add_repr(repr_ns)
1551 if str is True:
1552 builder.add_str()
1553
1554 eq = _determine_whether_to_implement(
1555 cls, eq_, auto_detect, ("__eq__", "__ne__")
1556 )
1557 if not is_exc and eq is True:
1558 builder.add_eq()
1559 if not is_exc and _determine_whether_to_implement(
1560 cls, order_, auto_detect, ("__lt__", "__le__", "__gt__", "__ge__")
1561 ):
1562 builder.add_order()
1563
1564 builder.add_setattr()
1565
1566 if (
1567 hash_ is None
1568 and auto_detect is True

Callers 2

attrsFunction · 0.70
format_textFunction · 0.50

Calls 15

_has_frozen_base_classFunction · 0.85
_has_own_attributeFunction · 0.85
_ClassBuilderClass · 0.85
add_reprMethod · 0.80
add_strMethod · 0.80
add_eqMethod · 0.80
add_orderMethod · 0.80
add_setattrMethod · 0.80
add_hashMethod · 0.80
make_unhashableMethod · 0.80
add_initMethod · 0.80

Tested by

no test coverage detected