legacy-api-wrap
Legacy API wrapper.
What it is and what it does
Legacy API Wrap is a single-purpose decorator library for managing the migration of function signatures from older Python code to modern conventions. It solves the problem of breaking backward compatibility when you want to convert positional parameters to keyword-only parameters—a common refactoring when updating legacy codebases. The decorator lets you specify which parameters were positional in the old API, then wraps the new function to accept calls using the old signature while emitting a DeprecationWarning to guide users toward the new calling convention.
The package has no runtime dependencies and is designed for library maintainers who need to evolve their APIs gradually. It works by intercepting calls to the decorated function, mapping old positional arguments to their new keyword-only positions, and forwarding them to the updated function signature. This is particularly useful for APIs defined before keyword-only parameters existed in Python, allowing you to reorder parameters and add new ones without immediately breaking existing code.
Use it for:
- Migrate a library function from positional to keyword-only parameters while warning existing users to update their code.
- Reorder function parameters for better API design without breaking code that calls the function with positional arguments.
- Add new parameters to a function signature while maintaining backward compatibility with old calling patterns.
- Gradually deprecate an old function API by wrapping it with warnings before removing it entirely.
- Support both old and new calling conventions during a library version transition period.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a decorator to wrap legacy function APIs, allowing you to convert positional parameters to keyword-only while maintaining backward compatibility with a deprecation warning.
Yes, if you maintain a library with legacy function signatures and need to evolve them safely. The package is actively maintained, has no dependencies, and solves a specific refactoring problem well. The MPL-2.0 copyleft license is straightforward for library use. Install it only if you have functions to migrate; it is not a general-purpose utility.
Install
legacy-api-wrap on PyPI
pip
pip install legacy-api-wrapuv
uv add legacy-api-wrappoetry
poetry add legacy-api-wrapInstalling legacy-api-wrap
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance with recent commits; last release 284 days ago.
License in practice
Licensed under MPL-2.0 (copyleft). You must disclose source and modifications if you distribute the package, but can use it in closed-source projects provided you comply with copyleft obligations for the package itself.
Quickstart
pip install legacy-api-wrap
from legacy_api_wrap import legacy_api
@legacy_api('d', 'c')
def fn(a, b=None, *, c=2, d=1, e=3):
return c, d, e
result = fn(12, 13, 14) # Old API call, emits DeprecationWarning
Requires Python 3.9 or later.
Verify before relying
- Whether the decorator handles *args or **kwargs in the wrapped function signature
- Whether parameter reordering works with type hints or dataclass-like signatures
- Performance overhead of the decorator on function calls
Package facts
| License | MPL-2.0 (copyleft) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 284 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,197,820/month — #4,231 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: legacy_api_wrap-1.5-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
DeprecatedProvides a @deprecated decorator to mark…
permissive · top 1,000 on PyPI
deprecatProvides a Python decorator to mark functions,…
permissive · top 15,000 on PyPI
snowflake._legacyProvides temporary backward compatibility for…
permissive · top 5,000 on PyPI
deprecationProvides decorators to automate deprecation…
permissive · top 1,000 on PyPI
django-deprecate-fieldsProvides a decorator to mark Django model…
permissive · top 5,000 on PyPI
zope.deprecationProvides a decorator and utilities to mark…
unclear · top 5,000 on PyPI
packaging-legacyProvides access to deprecated Python packaging…
permissive · top 15,000 on PyPI
purifyA decorator that makes object-mutating…
permissive · top 15,000 on PyPI
wraptwrapt provides a Python module for building…
permissive · top 100 on PyPI
langchain-classicProvides legacy LangChain chains, community…
permissive · top 1,000 on PyPI