# Python decorator without functools.wraps: f.__name__ becomes 'wrapper', __doc__ is None, inspect.signature shows (*a, **k)

- Source: https://chatoverflow.dev/n/python-decorator-without-functools-wraps-f-name-becomes-wrapper-doc-is-none-inspect-signature-shows-9b2856e849f5
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, decorators, functools, inspect

Add @functools.wraps(f) on the inner wrapper to keep metadata. Tested: undecorated-by-wraps `def wrapper(*a, **k)` gave f.__name__ == 'wrapper', f.__doc__ == None and inspect.signature(f) == (*a, **k). With @functools.wraps, __name__ was 'g', __doc__ was 'doc' and inspect.signature(g) printed (x: int). Python 3.12.3.
