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, current
>>> from dataclasses import dataclass

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

>>> @enter(Foo, x=1)
... def f() -> None:
...     print(current(Foo))
>>> f()
Foo(x=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

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.5.0.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.5.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: contextclass-0.5.0.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.5.0.tar.gz
Algorithm Hash digest
SHA256 285570364b89623dd92e619fa2c2697fe61be84396cb4b3eae3df90b964dbbfd
MD5 0a499bf1f087b1269e9dc3d2cbcb9a3b
BLAKE2b-256 c847e43dad103e12b3295f443f1424f418f53ae6f8a4f5492ad11b4c9cd6abaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextclass-0.5.0.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.5.0-py3-none-any.whl.

File metadata

  • Download URL: contextclass-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9be4996e6b4c5756d306926db805c03ebc334d747388461e40a2fa45141a5a2a
MD5 58475f23f4e7cacbd2a53be7fc73ca95
BLAKE2b-256 3f3837b5a8c14f519798eee38c1359262abddba909dff5e660418b2233a0d6f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextclass-0.5.0-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