Mutators

Note

Private module

Mutators package of ispec.

Module containing functions used to mutate methods and classes.

ispec._mutators.add_metaclass(cls: type[object], metaclass: type[type]) type[object][source]

Dynamically add metaclass to class.

..note: From six library, six.add_metaclass decorator

Parameters:
  • cls (type[object]) –

  • metaclass (type[type]) –

Return type:

type[object]

ispec._mutators.make_method_abstract(method: collections.abc.Callable[[...], Any]) collections.abc.Callable[[...], Any][source]

Return given method after applying abc.abstractmethod.

Parameters:

method (Callable[..., Any]) –

Return type:

Callable[..., Any]

ispec._mutators.set_methods_abstract(cls: type[object]) None[source]

Apply abc.abstractmethod to the methods of a class.

This function make the direct methods of a class abstract. It means that if class B inherit class A, using this function on class B will only set abstract the methods declared in class B.

Parameters:

cls (type[object]) –

Return type:

None