Interview Prep/Python for DevOps/Language essentials & functions

Why should every decorator use `functools.wraps`?

IntermediateConceptLanguage essentials & functions
Answer

Without it the wrapper replaces the original's __name__, __doc__, __module__, __qualname__ and signature metadata. Logs then say wrapper failed, help() shows nothing useful, click and FastAPI (which inspect signatures) break, and pytest fixtures or Flask routes collide because every view is named wrapper. @functools.wraps(fn) copies the metadata and sets __wrapped__ so tools can reach the original.

All Python for DevOps questions Roadmap: Python for automation

More on Language essentials & functions