tightwrap
A typed `functools.wraps`.
What it is and what it does
tightwrap is a minimal library that solves a specific typing problem: when you use `functools.wraps` to decorate a function, static type checkers like mypy lose the original function's signature and see only `*args, **kwargs`. This breaks type safety—a caller can pass the wrong types and the checker won't catch it. tightwrap.wraps has the same runtime behavior as `functools.wraps` but preserves the wrapped function's type signature for static analysis, so type checkers correctly report signature mismatches.
The package is intentionally small and has only one runtime dependency (`typing-extensions`). It applies `functools.wraps` under the hood to maintain runtime introspection compatibility, and it handles cases where the wrapper has a different return type than the wrapped function. Recent versions add support for wrapping methods and modern Python versions (3.13, 3.14).
Use it for:
- Wrapping functions in decorators while maintaining type safety for static analysis.
- Building decorator libraries where callers should see the original function's signature in their IDE and type checker.
- Ensuring runtime function metadata (name, docstring, annotations) stays accurate while preserving type hints.
- Wrapping methods in classes with correct typing for both static checkers and runtime introspection.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A drop-in replacement for `functools.wraps` that preserves static type information when wrapping functions, so type checkers see the wrapped function's actual signature instead of `*args, **kwargs`.
Yes. If you write decorators or function wrappers and use a static type checker, this is a straightforward win: it fixes a real gap in `functools.wraps` with zero complexity, no security issues, active maintenance, and a permissive license. If you don't use type checking or don't write wrappers, you don't need it.
Install
tightwrap on PyPI
pip
pip install tightwrapuv
uv add tightwrappoetry
poetry add tightwrapInstalling tightwrap
Before you install
Low friction: pure Python wheel with only `typing-extensions` as a runtime dependency. Actively maintained with recent releases supporting Python 3.13 and 3.14.
License in practice
Apache 2.0 (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install tightwrap
from tightwrap import wraps
def original(a: int) -> int:
return a + 1
@wraps(original)
def wrapper(*args, **kwargs) -> int:
return original(*args, **kwargs)
Verify before relying
- Whether the package is suitable for all decorator patterns (e.g., class decorators, async functions, partial application).
- Performance characteristics compared to `functools.wraps` for high-frequency wrapping scenarios.
Package facts
| License | Apache2 (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | actively maintained — 163 days since the last release |
| First released | |
| Downloads | 90,943/month — #13,554 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tightwrap-26.1.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
wrapsProvides type-safe wrapper types for…
permissive · top 15,000 on PyPI
wraptwrapt provides a Python module for building…
permissive · top 100 on PyPI
decopatchDecopatch simplifies writing decorators in…
permissive · top 5,000 on PyPI
singleton-decoratorProvides a decorator that enforces singleton…
copyleft · top 15,000 on PyPI
django-typesProvides type stubs for Django to enable static…
permissive · top 5,000 on PyPI
undecoratedStrips decorators from Python functions,…
permissive · top 15,000 on PyPI
singledispatchProvides single-dispatch generic functions—a…
permissive · top 5,000 on PyPI
types-decoratorProvides type stubs for the `decorator`…
permissive · top 5,000 on PyPI
joblib-stubsProvides type stubs for joblib, enabling static…
permissive · top 15,000 on PyPI
mo-kwargsProvides an `@override` decorator that lets you…
copyleft · top 15,000 on PyPI