No project description provided
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
Built Distribution
File details
Details for the file legacy_api_wrap-1.3.tar.gz
.
File metadata
- Download URL: legacy_api_wrap-1.3.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 175b7b8af157eedb5b3dbc941e2fbff7cc9da2880382cbb8ea3a01c73404b81e |
|
MD5 | 04d568a37e800a3415f7ad3e6965fb22 |
|
BLAKE2b-256 | 8a9e7698b21b73fed0a91ed8cdc9e6b5623e071a7bc05aac1946056dce30ea5f |
File details
Details for the file legacy_api_wrap-1.3-py3-none-any.whl
.
File metadata
- Download URL: legacy_api_wrap-1.3-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d22db26b7db2be3a83011d9f7efc7e09075ce5bee20556cd4daae47632f96978 |
|
MD5 | 72ea84cb4041a41a18183b5d4d9104a7 |
|
BLAKE2b-256 | 2f9d876a80e25965194e82278ebf531a2388ddb5c02f33f88f8f16952362b631 |