MCPcopy Create free account
hub / github.com/ipython/traitlets / setup_class

Method setup_class

traitlets/traitlets.py:991–1007  ·  view source on GitHub ↗

Setup descriptor instance on the class This sets the :attr:`this_class` and :attr:`name` attributes of each BaseDescriptor in the class dict of the newly created ``cls`` before calling their :attr:`class_init` method.

(cls: MetaHasDescriptors, classdict: dict[str, t.Any])

Source from the content-addressed store, hash-verified

989 cls.setup_class(classdict)
990
991 def setup_class(cls: MetaHasDescriptors, classdict: dict[str, t.Any]) -> None:
992 """Setup descriptor instance on the class
993
994 This sets the :attr:`this_class` and :attr:`name` attributes of each
995 BaseDescriptor in the class dict of the newly created ``cls`` before
996 calling their :attr:`class_init` method.
997 """
998 cls._descriptors = []
999 cls._instance_inits: list[t.Any] = []
1000 for k, v in classdict.items():
1001 if isinstance(v, BaseDescriptor):
1002 v.class_init(cls, k) # type:ignore[arg-type]
1003
1004 for _, v in getmembers(cls):
1005 if isinstance(v, BaseDescriptor):
1006 v.subclass_init(cls) # type:ignore[arg-type]
1007 cls._descriptors.append(v)
1008
1009
1010class MetaHasTraits(MetaHasDescriptors):

Callers

nothing calls this directly

Calls 4

getmembersFunction · 0.85
appendMethod · 0.80
class_initMethod · 0.45
subclass_initMethod · 0.45

Tested by

no test coverage detected