def filter_dict(dict_, keys):
    return {k: dict_[k] for k in keys}

def filter_kwargs(func):

    def func_wrapper(**kwargs):
        return func(**filter_dict(kwargs, get_input_names(func)))
return func_wrapper

@filter_kwargs
def foo(a, b):
    return a + b
d = {'a': 1, 'b': 2, 'c': 3}
print(foo(**d))
How to call a function with a dictionary that contains more items than the function has parameters?