polymerist.genutils.decorators.classmod ======================================= .. py:module:: polymerist.genutils.decorators.classmod .. autoapi-nested-parse:: Decorators for modifying classes Attributes ---------- .. autoapisummary:: polymerist.genutils.decorators.classmod.C Functions --------- .. autoapisummary:: polymerist.genutils.decorators.classmod.generate_repr polymerist.genutils.decorators.classmod.register_subclasses polymerist.genutils.decorators.classmod.register_abstract_class_attrs Module Contents --------------- .. py:data:: C .. py:function:: generate_repr(cls: Optional[C] = None, disp_attrs: Optional[Iterable[str]] = None, lookup_attr: Optional[str] = None) -> Union[C, Callable[[C], C]] Class decorator for auto-generating __repr__ methods By default (i.e. with no arguments), generated repr simply returns the name of the class If collection of "disp_attrs" is provided, will display the values of for the object instance being represented in series If "disp_attrs" is NOT provided but "lookup_attr" is, disp_attrs will be looked up from the modified parent class .. py:function:: register_subclasses(cls: Optional[C] = None, key_attr: str = '__name__', reg_attr: str = 'subclass_registry') -> Union[C, Callable[[C], C]] Parametric class decorator for automatically generating a registry of subclasses of a target class Binds registry to the "registry" class property in the target class Subclasses are keyed by lookup of a target attribute in the child classes (by default just the name of the subclass), while the resulting registry class property is bound to the attribute of the parent class .. py:function:: register_abstract_class_attrs(*attr_names: list[str]) -> Callable[[C], C] Register a list of string attribute names as abstract class attributes, which MUST be implemented by child classes of the wrapped class