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.

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

Uploaded Source

Built Distribution

legacy_api_wrap-0.1-py2.py3-none-any.whl (36.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

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

File hashes

Hashes for legacy-api-wrap-0.1.tar.gz
Algorithm Hash digest
SHA256 273d96e83317bae4495b2fcf12f2594dea3ccbc3d45cfdca3e6d056551380aac
MD5 e1ec39217b4399c82ac6e51ef046bea7
BLAKE2b-256 6bfa0c0e87c319544eec579cacd68f6ade1a7b6d5eb87867eaa3eb44ae254a32

See more details on using hashes here.

File details

Details for the file legacy_api_wrap-0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for legacy_api_wrap-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e13ab280415ae862260e23478414f0578e3488e0dd073337b9766213304fbcfb
MD5 9e84f8f2c592aad784a99336e87701c4
BLAKE2b-256 25b4f9d61e817a897434a5ed32c9344d00b0d0f427a7e49a436eb52f0716a140

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