skillfed

legacy-api-wrap

Legacy API wrapper.

legacy-api-wrap v1.5 1.2M downloads/30d#4,231 on PyPI1
Copyleft license MPL-2.0 Active released

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-wrap

uv

uv add legacy-api-wrap

poetry

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 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

legacy api wrapper decoratorconvert positional to keyword-only parametersbackward compatible function signaturedeprecation warning for old api callsreorder function parameters safelypython function api migrationkeyword-only parameter decorator
api-migrationdeprecation-handling

More Python Modules packages