lisa.utils.newtype#

lisa.utils.newtype(cls, name, doc=None, module=None, stacklevel=1)[source]#

Make a new class inheriting from cls with the given name.

Parameters:
  • cls (type) – Class to inherit from.

  • name (str) – Qualified name of the new type.

  • doc (str or None) – Content of docstring to assign to the new type.

  • module (str or None) – Module name to assign to __module__ attribute of the new type. By default, it’s inferred from the caller of newtype().

The instances of cls class will be recognized as instances of the new type as well using isinstance.