envclasses is a library to map fields on dataclass object to environment variables
Project description
envclasses
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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for envclasses-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16026211b60a37a7c4e3702ad150a3584a33dc7bff5273e9b640ac739602c0b7 |
|
MD5 | fc6352e120cd0026c2672716de0b49b1 |
|
BLAKE2b-256 | 0d31c8c5dd38b72eded40df850c6f1a5aa6fec19b9fe1cd209b5385b0a559e15 |