preserve_signature

plasmapy.utils.decorators.helpers.preserve_signature(f)[source]

A decorator for decorators, which preserves the signature of the function being wrapped. This preservation allows IDE function parameter hints to work on the wrapped function. To do this, the __signature__ dunder is defined, or inherited, from the function being wrapped to the resulting wrapped function.

Parameters:

f (callable) – The function being wrapped.

Returns:

Wrapped version of the function.

Return type:

callable

Examples

>>> def a_decorator(f):
...     @preserve_signature
...     @functools.wraps(f)
...     def wrapper(*args, **kwargs):
...         return wrapper(*args, **kwargs)
...
...     return wrapper