syncopy.shared.kwarg_decorators._append_signature#

syncopy.shared.kwarg_decorators._append_signature(func, kwname, kwdefault=None)[source]#

Local helper to automate keyword argument insertions in function signatures

Parameters:
  • func (callable) – Typically a (wrapped) Syncopy metafunction such as freqanalysis()

  • kwname (str) – Name of keyword argument to be added to func’s signature

  • kwdefault (None or any valid type) – Default value of keyword argument specified by kwname

Returns:

newSignature – A copy of func’s signature with kwname=kwdefault included as last named keyword argument (before **kwargs). If kwname already exists in func’s named keyword arguments, newSignature is an identical copy of func’s signature.

Return type:

inspect.Signature

Notes

This function does not change func’s byte-code, that is, it does not actually add a new keyword argument to func but just appends a named parameter to func’s signature. As a consequence, func must accept “anonymous” keywords via a **kwargs dictionary for this manipulation to work as intended. If func does not support a kwargs parameter dictionary, kwname with default value kwdefault will be listed in func’s signature but trying to use it will trigger a “unexpected keyword argument”-TypeError.

This routine is a local auxiliary method that is purely intended for internal use. Thus, no error checking is performed.

See also

_append_docstring

extend a function’s signature