pydecorium.class_propagate#

To use the class_propagate function, refer to the documentation How to use a decorator.

pydecorium.class_propagate(decorator: Decorator, methods: List[str] | None = None)[source]#

Applies a given decorator to specific methods of a class.

Note

This decorator is intended to be used on classes. Only methods that are regular functions (of type types.FunctionType) will be targeted. Does not apply the decorator to special methods (e.g., __init__, __str__) unless explicitly listed in methods.

Parameters:
  • decorator (Decorator) – An instance of the pydecorium.Decorator class to apply to the methods.

  • methods (list of str, optional) – A list of method names to which the decorator should be applied. If None, the decorator is applied to all methods of the class. Default value is None.

Returns:

class_decorator – A class decorator that applies the given decorator to specified methods.

Return type:

function

Raises:

TypeError

  • If decorator is not an instance of the pydecorium.Decorator class. - If methods is provided and is not a list of strings.