:py:mod:`dags.signature` ======================== .. py:module:: dags.signature Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: dags.signature.create_signature dags.signature.with_signature dags.signature._fail_if_too_many_positional_arguments dags.signature._fail_if_duplicated_arguments dags.signature._fail_if_invalid_keyword_arguments dags.signature.rename_arguments .. py:function:: create_signature(args=None, kwargs=None) Create a inspect.Signature object based on args and kwargs. :param args: The names of positional or keyword arguments. :type args: list or None :param kwargs: The keyword only arguments. :type kwargs: list or None :returns: inspect.Signature .. py:function:: with_signature(func=None, *, args=None, kwargs=None, enforce=True) Decorator that adds a signature to a function of type ``f(*args, **kwargs)`` Caveats: The created signature only contains the names of arguments and whether they are keyword only. There is no way of setting default values, type hints or other things. :param func: The function to be decorated. Should take ``*args`` and ``**kwargs`` as only arguments. :type func: callable :param args: The names of positional or keyword arguments. :type args: list or None :param kwargs: The keyword only arguments. :type kwargs: list or None :param enforce: Whether the signature should be enforced or just added to the function for introspection. This creates runtime overhead. :type enforce: bool :returns: The function with signature. :rtype: function .. py:function:: _fail_if_too_many_positional_arguments(present_args, argnames, funcname) .. py:function:: _fail_if_duplicated_arguments(present_args, present_kwargs, funcname) .. py:function:: _fail_if_invalid_keyword_arguments(present_kwargs, valid_kwargs, funcname) .. py:function:: rename_arguments(func=None, *, mapper=None) Rename positional and keyword arguments of func. :param func: The function of which the arguments are renamed. :type func: callable :param mapper: Dict of strings where keys are old names and values are new of arguments. :type mapper: dict :returns: The function with renamed arguments. :rtype: function