contextvars-extras
Project Moved
The project was renamed to `contextvars-registry` and moved to:
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.
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:
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.
Check out the full documentation
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/
Metadata
Release files for contextvars-extras 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| contextvars_extras-0.7.0.tar.gz | 24.4 kB | Without provenance | Details for contextvars_extras-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| contextvars_extras-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for contextvars_extras-0.7.0-py3-none-any.whl |
Total release size: 52.1 kB
Release files / contextvars_extras-0.7.0.tar.gz
| Download URL | contextvars_extras-0.7.0.tar.gz |
|---|---|
| Size | 24.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4823d1f3b0e8ef863d5a622b9effbdd3a34b6bb11a6d6ab0fbcb6579d59aad6
|
|
BLAKE2b-256 checksum How to use checksums |
8c1b82ce324fd283a1083e5a9b1eaba07cb1748486caf953bc26d142d0da39c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.8.10 Linux/5.4.0-172-generic
|
Release files / contextvars_extras-0.7.0-py3-none-any.whl
| Download URL | contextvars_extras-0.7.0-py3-none-any.whl |
|---|---|
| Size | 27.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e82956b206d5fd28650d37fb869cee743aad62f3cf54ed607a85107713da944
|
|
BLAKE2b-256 checksum How to use checksums |
200ad3116413f9ca488cb72c5cee8e6077ddb8014fb2b6aabd2d634cd355923e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.8.10 Linux/5.4.0-172-generic
|
Security for contextvars-extras 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.