New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

legacy-api-wrap

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

legacy-api-wrap

  • 1.4.1
  • Source
  • PyPI
  • Socket score

Maintainers
1

Legacy API Wrapper |b-pypi| |b-codecov|

.. |b-pypi| image:: https://img.shields.io/pypi/v/legacy-api-wrap.svg :target: https://pypi.org/project/legacy-api-wrap .. |b-codecov| image:: https://codecov.io/gh/flying-sheep/legacy-api-wrap/graph/badge.svg :target: https://codecov.io/gh/flying-sheep/legacy-api-wrap

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc