get_subclasses

get_subclasses(cls: type[X], exclude_private: bool = True, exclude_external: bool = True, main_is_private: bool = True) Iterable[type[X]][source]

Get all subclasses.

Parameters:
  • cls – The ancestor class

  • exclude_private – 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 – If true, will exclude any class that does not originate from the same package as the base class.

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

Yields:

Descendant classes of the ancestor class