Finalize class based on the accumulated configuration. Builder cannot be used after calling this method.
(self)
| 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 | """ |