functools.wraps
is equivalent to:
def wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES):
def decorator(wrapper):
return update_wrapper(wrapper, wrapped=wrapped, ...)
return decorator
It’s actually implemented using partial
instead of an inner function, but the effect is the same.
The purpose is to allow using it as a decorator:
@wraps(f)
def g():
...
is equivalent to:
def g():
...
g = update_wrapper(g, f)