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

Method build_class

src/attr/_make.py:796–819  ·  view source on GitHub ↗

Finalize class based on the accumulated configuration. Builder cannot be used after calling this method.

(self)

Source from the content-addressed store, hash-verified

794 hook(self._cls_dict, locs)
795
796 def build_class(self):
797 """
798 Finalize class based on the accumulated configuration.
799
800 Builder cannot be used after calling this method.
801 """
802 self._eval_snippets()
803 if self._slots is True:
804 cls = self._create_slots_class()
805 self._cls.__attrs_base_of_slotted__ = weakref.ref(cls)
806 else:
807 cls = self._patch_original_class()
808 if PY_3_10_PLUS:
809 cls = abc.update_abstractmethods(cls)
810
811 # The method gets only called if it's not inherited from a base class.
812 # _has_own_attribute does NOT work properly for classmethods.
813 if (
814 getattr(cls, "__attrs_init_subclass__", None)
815 and "__attrs_init_subclass__" not in cls.__dict__
816 ):
817 cls.__attrs_init_subclass__()
818
819 return cls
820
821 def _patch_original_class(self):
822 """

Callers 2

wrapFunction · 0.80
test_returns_selfMethod · 0.80

Calls 4

_eval_snippetsMethod · 0.95
_create_slots_classMethod · 0.95
_patch_original_classMethod · 0.95

Tested by 1

test_returns_selfMethod · 0.64