(fn, kwargs)
return fn(**kwargs)
Calls the function ``fn`` with the keyword arguments from ``kwargs`` it expects

    If the kwargs argument is defined, pass all arguments, else provide exactly
    the arguments wanted.

    If one of the arguments of ``fn`` are not contained in kwargs, ``fn`` will not
    be called and ``None`` will be returned.
Calls the function ``fn`` with the keyword arguments from ``kwargs`` it expects
Calls the function fn with the keyword arguments from kwargs it expects
def call_with_appropriate(fn, kwargs):
    """
    Calls the function ``fn`` with the keyword arguments from ``kwargs`` it expects

    If the kwargs argument is defined, pass all arguments, else provide exactly
    the arguments wanted.

    If one of the arguments of ``fn`` are not contained in kwargs, ``fn`` will not
    be called and ``None`` will be returned.
    """
    args, kwargs_name = signature(fn)
    # no catch-all defined, we need to exactly pass the arguments specified.
    if not kwargs_name:
        kwargs = {key: kwargs[key] for key in kwargs if key in args}

        # if any argument of fn is not in kwargs, just return None
        if any(arg not in kwargs for arg in args):
            return None

    return fn(**kwargs)
def call_with_appropriate ( fn , kwargs ) : args , kwargs_name = signature ( fn ) # no catch-all defined, we need to exactly pass the arguments specified. if not kwargs_name : kwargs = { key : kwargs [ key ] for key in kwargs if key in args } # if any argument of fn is not in kwargs, just return None if any ( arg not in kwargs for arg in args ) : return None return fn ( * * kwargs )