--- id: tightwrap version: "26.1.0" license: Apache2 license_treatment: permissive maintenance: active --- # tightwrap — A typed `functools.wraps`. License: permissive · Maintenance: active · Downloads: 90.9K/mo ## 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 above — 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 pip install tightwrap uv add tightwrap poetry add tightwrap ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 90.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags typed function wrapper, functools.wraps typing, static type preservation wrapping, decorator type hints, mypy-compatible wraps, function wrapper static types, typed decorator helper, typing, decorators [View on SkillFed](https://skillfed.io/packages/tightwrap) · [View on PyPI](https://pypi.org/project/tightwrap/)