Module peprock.subclasses

Class hierarchy helpers.

Examples

>>> sorted(get(int), key=lambda t: t.__name__)  # doctest: +SKIP
[<enum 'IntEnum'>, <enum 'IntFlag'>, <class 'sre_constants._NamedIntConstant'>, <class 'bool'>]
>>> get_by_name(int, name="bool")
<class 'bool'>
>>> len(get(object))  # doctest: +SKIP
280

Functions

def get(base_class: type[T_co], *, exclude_abstract: bool = False, recursive: bool = False)

Identify subclasses of base_class and return a set.

def get_by_name(base_class: type[T_co], name: str, *, recursive: bool = False)

Identify subclass of base_class with given name.