contextvars-extras
==================
Project Moved
-------------
**The project was renamed to `contextvars-registry` and moved to**:
- https://pypi.org/project/contextvars-registry/
- https://github.com/vdmit11/contextvars-registry
**This package is not maintained anymore. Please switch to `contextvars-registry`.**
Description
-----------
``contextvars-extras`` is a set of extensions for the Python's `contextvars`_ module.
In case you are not familiar with the `contextvars`_ module, its `ContextVar`_ objects
work like Thread-Local storage, but better: they are both thread-safe and async task-safe,
and they can be copied (all existing vars copied in O(1) time), and then you can run
a function in the copied and isolated context.
.. _contextvars: https://docs.python.org/3/library/contextvars.html
.. _ContextVar: https://docs.python.org/3/library/contextvars.html#contextvars.ContextVar
The `contextvars`_ is a powerful module, but its API seems too low-level.
So this ``contextvars_extras`` package provides some higher-level additions on top of the
standard API, like, for example, organizing `ContextVar`_ objects into registry classes,
with nice ``@property``-like access:
.. code:: python
from contextvars_extras import ContextVarsRegistry
class CurrentVars(ContextVarsRegistry):
locale: str = 'en'
timezone: str = 'UTC'
current = CurrentVars()
# calls ContextVar.get() under the hood
current.timezone # => 'UTC'
# calls ContextVar.set() under the hood
current.timezone = 'GMT'
# ContextVar() objects can be reached as class members
CurrentVars.timezone.get() # => 'GMT'
That makes your code more readable (no more noisy ``.get()`` calls),
and it is naturally firendly to `typing`_, so static code analysis features
(like type checkers and auto-completion in your IDE) work nicely.
.. _typing: https://docs.python.org/3/library/typing.html
Check out the `full documentation <https://contextvars-extras.readthedocs.io>`_
Links
-----
- Read the Docs: https://contextvars-extras.readthedocs.io
- GitHub repository: https://github.com/vdmit11/contextvars-extras
- Python package: https://pypi.org/project/contextvars-extras/
.. |pypi badge| image:: https://img.shields.io/pypi/v/contextvars-extras.svg
:target: https://pypi.org/project/contextvars-extras/
:alt: Python package version
.. |build badge| image:: https://github.com/vdmit11/contextvars-extras/actions/workflows/build.yml/badge.svg
:target: https://github.com/vdmit11/contextvars-extras/actions/workflows/build.yml
:alt: Tests Status
.. |docs badge| image:: https://readthedocs.org/projects/contextvars-extras/badge/?version=latest
:target: https://contextvars-extras.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
Raw data
{
"_id": null,
"home_page": "https://github.com/vdmit11/contextvars-registry",
"name": "contextvars-extras",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.1,<4.0.0",
"maintainer_email": "",
"keywords": "contextvars,context,async,threading,gevent",
"author": "Dmitry Vasilyanov",
"author_email": "vdmit11@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8c/1b/82ce324fd283a1083e5a9b1eaba07cb1748486caf953bc26d142d0da39c2/contextvars_extras-0.7.0.tar.gz",
"platform": null,
"description": "contextvars-extras\n==================\n\nProject Moved\n-------------\n\n**The project was renamed to `contextvars-registry` and moved to**:\n\n- https://pypi.org/project/contextvars-registry/\n- https://github.com/vdmit11/contextvars-registry\n\n\n**This package is not maintained anymore. Please switch to `contextvars-registry`.**\n\nDescription\n-----------\n\n``contextvars-extras`` is a set of extensions for the Python's `contextvars`_ module.\n\nIn case you are not familiar with the `contextvars`_ module, its `ContextVar`_ objects\nwork like Thread-Local storage, but better: they are both thread-safe and async task-safe,\nand they can be copied (all existing vars copied in O(1) time), and then you can run\na function in the copied and isolated context.\n\n.. _contextvars: https://docs.python.org/3/library/contextvars.html\n.. _ContextVar: https://docs.python.org/3/library/contextvars.html#contextvars.ContextVar\n\nThe `contextvars`_ is a powerful module, but its API seems too low-level.\n\nSo this ``contextvars_extras`` package provides some higher-level additions on top of the\nstandard API, like, for example, organizing `ContextVar`_ objects into registry classes,\nwith nice ``@property``-like access:\n\n.. code:: python\n\n from contextvars_extras import ContextVarsRegistry\n\n class CurrentVars(ContextVarsRegistry):\n locale: str = 'en'\n timezone: str = 'UTC'\n\n current = CurrentVars()\n\n # calls ContextVar.get() under the hood\n current.timezone # => 'UTC'\n\n # calls ContextVar.set() under the hood\n current.timezone = 'GMT'\n\n # ContextVar() objects can be reached as class members\n CurrentVars.timezone.get() # => 'GMT'\n\nThat makes your code more readable (no more noisy ``.get()`` calls),\nand it is naturally firendly to `typing`_, so static code analysis features\n(like type checkers and auto-completion in your IDE) work nicely.\n\n.. _typing: https://docs.python.org/3/library/typing.html\n\nCheck out the `full documentation <https://contextvars-extras.readthedocs.io>`_\n\nLinks\n-----\n\n- Read the Docs: https://contextvars-extras.readthedocs.io\n- GitHub repository: https://github.com/vdmit11/contextvars-extras\n- Python package: https://pypi.org/project/contextvars-extras/\n\n\n.. |pypi badge| image:: https://img.shields.io/pypi/v/contextvars-extras.svg\n :target: https://pypi.org/project/contextvars-extras/\n :alt: Python package version\n\n.. |build badge| image:: https://github.com/vdmit11/contextvars-extras/actions/workflows/build.yml/badge.svg\n :target: https://github.com/vdmit11/contextvars-extras/actions/workflows/build.yml\n :alt: Tests Status\n\n.. |docs badge| image:: https://readthedocs.org/projects/contextvars-extras/badge/?version=latest\n :target: https://contextvars-extras.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "This package is not maintained anymore. Please switch to 'contextvars-registry'.",
"version": "0.7.0",
"project_urls": {
"Documentation": "https://contextvars-registry.readthedocs.io",
"Homepage": "https://github.com/vdmit11/contextvars-registry",
"Repository": "https://github.com/vdmit11/contextvars-registry"
},
"split_keywords": [
"contextvars",
"context",
"async",
"threading",
"gevent"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "200ad3116413f9ca488cb72c5cee8e6077ddb8014fb2b6aabd2d634cd355923e",
"md5": "9181a8832b404b17d682079f09de6809",
"sha256": "6e82956b206d5fd28650d37fb869cee743aad62f3cf54ed607a85107713da944"
},
"downloads": -1,
"filename": "contextvars_extras-0.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9181a8832b404b17d682079f09de6809",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.1,<4.0.0",
"size": 27714,
"upload_time": "2024-03-19T19:34:27",
"upload_time_iso_8601": "2024-03-19T19:34:27.628359Z",
"url": "https://files.pythonhosted.org/packages/20/0a/d3116413f9ca488cb72c5cee8e6077ddb8014fb2b6aabd2d634cd355923e/contextvars_extras-0.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8c1b82ce324fd283a1083e5a9b1eaba07cb1748486caf953bc26d142d0da39c2",
"md5": "5091123cf2abdf77f98ee9ca6542ade8",
"sha256": "c4823d1f3b0e8ef863d5a622b9effbdd3a34b6bb11a6d6ab0fbcb6579d59aad6"
},
"downloads": -1,
"filename": "contextvars_extras-0.7.0.tar.gz",
"has_sig": false,
"md5_digest": "5091123cf2abdf77f98ee9ca6542ade8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.1,<4.0.0",
"size": 24362,
"upload_time": "2024-03-19T19:34:29",
"upload_time_iso_8601": "2024-03-19T19:34:29.173864Z",
"url": "https://files.pythonhosted.org/packages/8c/1b/82ce324fd283a1083e5a9b1eaba07cb1748486caf953bc26d142d0da39c2/contextvars_extras-0.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-19 19:34:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "vdmit11",
"github_project": "contextvars-registry",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "contextvars-extras"
}