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.1.tar.gz
(14.8 kB
view details)
Built Distribution
File details
Details for the file legacy-api-wrap-1.1.tar.gz
.
File metadata
- Download URL: legacy-api-wrap-1.1.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.21.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a6caef826d781d84d80ac61dc06bad826c965386aa1319fde41b831eca998b6 |
|
MD5 | ef9b1ce92e95877ed49f37fcbd8e5f92 |
|
BLAKE2b-256 | 7a2a2bdadd22528fea36b88f5f44a87ca916d2ed272eb08c8b120fb0343cda15 |
File details
Details for the file legacy_api_wrap-1.1-py3-none-any.whl
.
File metadata
- Download URL: legacy_api_wrap-1.1-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.21.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ba149887f07c5748eb8c793a0cab53ff16ce3cce1b4efe372fbd103e7c03826 |
|
MD5 | 8f03ade5a77ed7a72dd2988d6239f5cc |
|
BLAKE2b-256 | 845fc400f9094ea8c3ef83184126bea6f5cdfb19bdd0fe048c57a1d697e70f2c |