Name | legacy-api-wrap JSON |
Version |
1.4.1
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-11-22 13:40:06 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MPL-2.0 |
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": null,
"name": "legacy-api-wrap",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "\"Philipp A.\" <flying-sheep@web.de>",
"download_url": "https://files.pythonhosted.org/packages/a4/07/fbc3cf8cf3759c5f234af9d94761f09f41e6d0aa912b2a9dfda19a48855a/legacy_api_wrap-1.4.1.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": "MPL-2.0",
"summary": null,
"version": "1.4.1",
"project_urls": {
"Source": "https://github.com/flying-sheep/legacy-api-wrap"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3c1d9324c70629dfe4395f9122ab331cf245d3cce6ded851aa8a0a8ae264c4e6",
"md5": "a59fb115936676fef3e2bebd8e3c2d61",
"sha256": "8ba214242e836cebfd3b64c1a1653fce955abb0f9e4c7dffb51f2ad014def0eb"
},
"downloads": -1,
"filename": "legacy_api_wrap-1.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a59fb115936676fef3e2bebd8e3c2d61",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9986,
"upload_time": "2024-11-22T13:40:05",
"upload_time_iso_8601": "2024-11-22T13:40:05.265977Z",
"url": "https://files.pythonhosted.org/packages/3c/1d/9324c70629dfe4395f9122ab331cf245d3cce6ded851aa8a0a8ae264c4e6/legacy_api_wrap-1.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a407fbc3cf8cf3759c5f234af9d94761f09f41e6d0aa912b2a9dfda19a48855a",
"md5": "022c86706d5edce95e0a46ecefe5ed43",
"sha256": "9c40d67aa8312fec8763e87cbf28fea4b67710c79ca7a18137b573d150f3b2b4"
},
"downloads": -1,
"filename": "legacy_api_wrap-1.4.1.tar.gz",
"has_sig": false,
"md5_digest": "022c86706d5edce95e0a46ecefe5ed43",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11003,
"upload_time": "2024-11-22T13:40:06",
"upload_time_iso_8601": "2024-11-22T13:40:06.911807Z",
"url": "https://files.pythonhosted.org/packages/a4/07/fbc3cf8cf3759c5f234af9d94761f09f41e6d0aa912b2a9dfda19a48855a/legacy_api_wrap-1.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-22 13:40: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"
}