lisa.utils.kwargs_forwarded_to#

lisa.utils.kwargs_forwarded_to(f, ignore=None)[source]#

Similar to functools.wraps(), except that it will only fixup the signature.

Parameters:

ignore (list(str) or None) – List of parameter to not include in the signature.

The signature is modified in the following way:

  • Variable keyword parameters are removed

  • All the parameters that f take are added as keyword-only in the decorated function’s signature, under the assumption that **kwargs in the decorated function is used to relay the parameters to f.

Example:

def f(x, y, z):
    pass

@kwargs_forwarded_to(f)
def g(z, **kwargs):
    f(**kwargs)
    return z

# The signature of g() is now "(z, *, x, y)", i.e. x and y are
# keyword-only.