Skip to main content

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.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

legacy_api_wrap-1.0-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

Details for the file legacy-api-wrap-1.0.tar.gz.

File metadata

  • Download URL: legacy-api-wrap-1.0.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.21.0

File hashes

Hashes for legacy-api-wrap-1.0.tar.gz
Algorithm Hash digest
SHA256 dcc2cf5440bd321523514c050a3bca152e3686ebd6919be98dd27eda6aef1ca8
MD5 f566b1573a3cc51e78efa76fe9d81fb6
BLAKE2b-256 324e8ab2c405c14a6aa154ae2ab99861152106593d094ef27d5a0fac4c04476d

See more details on using hashes here.

File details

Details for the file legacy_api_wrap-1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for legacy_api_wrap-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 629cc2e1b8bd73e998e13e196d80eb1dc679170166300b24aa70c732c35efa62
MD5 b25a00514c3082f7e92df5b348c701b8
BLAKE2b-256 3ea54a0911195962cdacb0e36113118ba3f49fed94c352953edd1b11f1e6f4ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page