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.5.tar.gz (11.6 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.5-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file legacy_api_wrap-1.5.tar.gz.

File metadata

  • Download URL: legacy_api_wrap-1.5.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for legacy_api_wrap-1.5.tar.gz
Algorithm Hash digest
SHA256 b41ba6532f3ebfe3a897a35a7f97dec3be04b92a450f6c2bcf89f1b91c9cadf2
MD5 d23c5565b6c3f82fb25007d9fd231d38
BLAKE2b-256 5849f06f94048c8974205730d40beca879e43b6eee08efb0101cfb8623e60f41

See more details on using hashes here.

Provenance

The following attestation bundles were made for legacy_api_wrap-1.5.tar.gz:

Publisher: publish.yml on flying-sheep/legacy-api-wrap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: legacy_api_wrap-1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for legacy_api_wrap-1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5a8ea50e3e3bcbcdec3447b77034fd0d32cb2cf4089db799238708e4d7e0098d
MD5 d7368bbe14a958a6bbd9a30f119b96a2
BLAKE2b-256 415b058db09c45ba58a7321bdf2294cae651b37d6fec68117265af90cde043b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for legacy_api_wrap-1.5-py3-none-any.whl:

Publisher: publish.yml on flying-sheep/legacy-api-wrap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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