--- id: legacy-api-wrap version: "1.5" license: MPL-2.0 license_treatment: copyleft maintenance: active --- # legacy-api-wrap — Legacy API wrapper. License: copyleft · Maintenance: active · Downloads: 1.2M/mo ## 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 above — 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 pip install legacy-api-wrap uv add legacy-api-wrap poetry add legacy-api-wrap ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 1.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags legacy api wrapper decorator, convert positional to keyword-only parameters, backward compatible function signature, deprecation warning for old api calls, reorder function parameters safely, python function api migration, keyword-only parameter decorator, api-migration, deprecation-handling [View on SkillFed](https://skillfed.io/packages/legacy-api-wrap) · [View on PyPI](https://pypi.org/project/legacy-api-wrap/)