Skip to main content

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

legacy_api_wrap-1.3.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

legacy_api_wrap-1.3-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

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

Hashes for legacy_api_wrap-1.3.tar.gz
Algorithm Hash digest
SHA256 175b7b8af157eedb5b3dbc941e2fbff7cc9da2880382cbb8ea3a01c73404b81e
MD5 04d568a37e800a3415f7ad3e6965fb22
BLAKE2b-256 8a9e7698b21b73fed0a91ed8cdc9e6b5623e071a7bc05aac1946056dce30ea5f

See more details on using hashes here.

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

Hashes for legacy_api_wrap-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d22db26b7db2be3a83011d9f7efc7e09075ce5bee20556cd4daae47632f96978
MD5 72ea84cb4041a41a18183b5d4d9104a7
BLAKE2b-256 2f9d876a80e25965194e82278ebf531a2388ddb5c02f33f88f8f16952362b631

See more details on using hashes here.

Supported by

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