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

>>> @dataclass
... class Foo(ContextClass):
...     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.0.tar.gz (43.1 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.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: contextclass-0.2.0.tar.gz
  • Upload date:
  • Size: 43.1 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.0.tar.gz
Algorithm Hash digest
SHA256 3f2b0f49979782a67081ef16e98452b92342e60320ad70562d87aebdb146c07f
MD5 a26e81b1e3551d8634dfd7789d8bf240
BLAKE2b-256 d6c604195483681bd16fd925512ac71b6f87fd6bf49dba0dd9cad06136c6cb18

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: contextclass-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 53efe48a83893b251dd2b4dfb36df87fee74c42a24d63765368508636ad9e94b
MD5 f057d5d54026c54d55849829e25de647
BLAKE2b-256 0564899dd2a7ca18a7a842c2cedfa9c6791cd74eb6d5c5ed9763cbccd7169e53

See more details on using hashes here.

Provenance

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