Skip to main content

A nice interface to context variables

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

contextclass

Alternative interface to context variables for practical scenarios.

>>> from contextclass import ContextLocal, enter
>>> from dataclasses import dataclass

>>> @dataclass
... class Foo(ContextLocal):
...     x: int | None = None

>>> @enter(Foo, x=1)
... def f() -> None:
...     print(Foo.current.x)
>>> f()
1

>>> with Foo.context(x=2):
...     print(Foo.current.x)
2

>>> @Foo.context(x=3)
... def f() -> None:
...     print(Foo.current.x)
>>> f()
3

Works with type hints:

image image image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contextclass-0.2.2.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contextclass-0.2.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file contextclass-0.2.2.tar.gz.

File metadata

  • Download URL: contextclass-0.2.2.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for contextclass-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a1c8a230cb4a346615384bc41cd4b448fe8882d7410459b849c52cdcfa516088
MD5 881f02c606d501ed78a91ebb7f55a7ac
BLAKE2b-256 effe9f07c1276b92b74438584720d6cd8835e8664c3da9a6e6c3bcc9c1ed18e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextclass-0.2.2.tar.gz:

Publisher: ci.yml on johnslavik/contextclass

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contextclass-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: contextclass-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for contextclass-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cad8ab49f3f3a2b2141a2f99e26ec20bb6c91035b1bf79ccfd83dc3cef859f44
MD5 790cad016810cb7f3dbc2bb7e54b22d2
BLAKE2b-256 1af050f6876dc97fd5c11b4f64a4fa60c669dbf88041ddf89ceb34e813a9716e

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextclass-0.2.2-py3-none-any.whl:

Publisher: ci.yml on johnslavik/contextclass

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page