get_subclasses

get_subclasses(cls, exclude_private=True, exclude_external=True, main_is_private=True)[source]

Get all subclasses.

Parameters:
  • cls (Type[TypeVar(X)]) – The ancestor class

  • exclude_private (bool) – If true, will skip any class that comes from a module starting with an underscore (i.e., a private module). This is typically done when having shadow duplicate classes implemented in C

  • exclude_external (bool) – If true, will exclude any class that does not originate from the same package as the base class.

  • main_is_private (bool) – If true, __main__ is considered a private module.

Yields:

Descendant classes of the ancestor class

Return type:

Iterable[Type[TypeVar(X)]]