Skip to main content

envclasses is a library to map fields on dataclass object to environment variables

Project description

envclasses

image image Test

envclasses is a library to map fields on dataclass object to environment variables.

Installation

pip install envclasses

Usage

Declare a class with dataclass and envclass decorators.

from envclasses import envclass, load_env
from dataclasses import dataclass

@envclass
@dataclass
class Foo:
    v: int

foo = Foo(v=10)
load_env(foo, prefix='foo')
print(foo)

Run the script

$ python foo.py
Foo(v=10)

Run with environment variable

$ FOO_V=100 python foo.py
Foo(v=100)

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

envclasses-0.3.1.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

envclasses-0.3.1-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

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