Legacy API wrapper.
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
legacy-api-wrap-1.2.tar.gz
(14.7 kB
view details)
Built Distribution
File details
Details for the file legacy-api-wrap-1.2.tar.gz
.
File metadata
- Download URL: legacy-api-wrap-1.2.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 034a44612da7e9943d3964363a98937ab54d55e3301075374abe0d521eb8101b |
|
MD5 | 2c6e231fc4411d49df56a37c6da14eb1 |
|
BLAKE2b-256 | f7ccfa52ef471dbb6379d129e5571ac4bfbd68ad6468dba97a0f7b18dc2fb561 |
File details
Details for the file legacy_api_wrap-1.2-py3-none-any.whl
.
File metadata
- Download URL: legacy_api_wrap-1.2-py3-none-any.whl
- Upload date:
- Size: 37.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f32cce6dd2f38d666b348c2b5ef8ecb724c23bdb648882eec64d0e0ee2ba9e24 |
|
MD5 | be0af3b7231eaaa772986d27806eb3f0 |
|
BLAKE2b-256 | a468da997bc56bb69dcdcee4054f0bc42266909307b905389fbc54c9158f42da |