legacy-api-wrap


Namelegacy-api-wrap JSON
Version 1.4 PyPI version JSON
download
home_page
Summary
upload_time2023-12-07 15:29:06
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "legacy-api-wrap",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "\"Philipp A.\" <flying-sheep@web.de>",
    "download_url": "https://files.pythonhosted.org/packages/d5/de/35984e2270dce9f5895849668c34e4da646b4ac5293f679b23ede3d6d7f0/legacy_api_wrap-1.4.tar.gz",
    "platform": null,
    "description": "Legacy API Wrapper |b-pypi| |b-codecov|\n=======================================\n\n.. |b-pypi| image:: https://img.shields.io/pypi/v/legacy-api-wrap.svg\n   :target: https://pypi.org/project/legacy-api-wrap\n.. |b-codecov| image:: https://codecov.io/gh/flying-sheep/legacy-api-wrap/graph/badge.svg\n   :target: https://codecov.io/gh/flying-sheep/legacy-api-wrap\n\nThis module defines a decorator to wrap legacy APIs.\nThe primary use case is APIs defined before keyword-only parameters existed.\n\n>>> from legacy_api_wrap import legacy_api\n\nWe have a function with many positional parameters lying around:\n\n>>> def fn(a, b=None, d=1, c=2):\n...     return c, d, e\n\nWe want to convert the positional parameters ``d`` and ``c`` to keyword-only,\nchange their order and add a parameter. For this we only need to specify name\nand order of the old positional parameters in the decorator.\n\n>>> @legacy_api('d', 'c')\n... def fn(a, b=None, *, c=2, d=1, e=3):\n...     return c, d, e\n\nAfter adding the decorator, users can keep calling the old API and get a\n``DeprecationWarning``:\n\n>>> fn(12, 13, 14) == (2, 14, 3)\nTrue\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "1.4",
    "project_urls": {
        "Source": "https://github.com/flying-sheep/legacy-api-wrap"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9708eaf39f00542e4181b65617805f116a0d38daec98d0dce36ec94327ca8fc4",
                "md5": "35e78778109214b5b0ab4f6f5b018a54",
                "sha256": "bf81b8ee432d80e7203aa079c26fc3a0f228d158db808868f10c2e36a8f64dbd"
            },
            "downloads": -1,
            "filename": "legacy_api_wrap-1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "35e78778109214b5b0ab4f6f5b018a54",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 15766,
            "upload_time": "2023-12-07T15:29:05",
            "upload_time_iso_8601": "2023-12-07T15:29:05.620638Z",
            "url": "https://files.pythonhosted.org/packages/97/08/eaf39f00542e4181b65617805f116a0d38daec98d0dce36ec94327ca8fc4/legacy_api_wrap-1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d5de35984e2270dce9f5895849668c34e4da646b4ac5293f679b23ede3d6d7f0",
                "md5": "6dc54274aa85013398db1302b7f95b7a",
                "sha256": "92dfa274cedb26d6e6f70fac85c856fbdcc05058066656d76a665fb4bf11b785"
            },
            "downloads": -1,
            "filename": "legacy_api_wrap-1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "6dc54274aa85013398db1302b7f95b7a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 17046,
            "upload_time": "2023-12-07T15:29:06",
            "upload_time_iso_8601": "2023-12-07T15:29:06.656217Z",
            "url": "https://files.pythonhosted.org/packages/d5/de/35984e2270dce9f5895849668c34e4da646b4ac5293f679b23ede3d6d7f0/legacy_api_wrap-1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-07 15:29:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "flying-sheep",
    "github_project": "legacy-api-wrap",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "legacy-api-wrap"
}
        
Elapsed time: 0.15745s