Metadata-Version: 2.1
Name: legacy-api-wrap
Version: 1.1
Summary: Legacy API wrapper.
Home-page: https://github.com/flying-sheep/legacy-api-wrap
License: UNKNOWN
Author: Philipp A.
Author-email: flying-sheep@web.de
Requires-Python: >=3.5
Description-Content-Type: text/x-rst
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Requires-Dist: get-version >=2.0.4
Requires-Dist: setuptools
Requires-Dist: future-fstrings
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-black; extra == "test" and ( python_version != "3.5")
Provides-Extra: .none
Provides-Extra: test

Legacy API Wrapper |b-pypi| |b-travis| |b-codecov|
==================================================

.. |b-pypi| image:: https://img.shields.io/pypi/v/legacy-api-wrap.svg
   :target: https://pypi.org/project/legacy-api-wrap
.. |b-travis| image:: https://travis-ci.com/flying-sheep/legacy-api-wrap.svg?branch=master
   :target: https://travis-ci.com/flying-sheep/legacy-api-wrap
.. |b-codecov| image:: https://codecov.io/gh/flying-sheep/legacy-api-wrap/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/flying-sheep/legacy-api-wrap

This module defines a decorator to wrap legacy APIs.
The primary use case is APIs defined before keyword-only parameters existed.

>>> from legacy_api_wrap import legacy_api

We have a function with many positional parameters lying around:

>>> def fn(a, b=None, d=1, c=2):
...     return c, d, e

We want to convert the positional parameters ``d`` and ``c`` to keyword-only,
change their order and add a parameter. For this we only need to specify name
and order of the old positional parameters in the decorator.

>>> @legacy_api('d', 'c')
... def fn(a, b=None, *, c=2, d=1, e=3):
...     return c, d, e

After adding the decorator, users can keep calling the old API and get a
``DeprecationWarning``:

>>> fn(12, 13, 14) == (2, 14, 3)
True

