envclasses
envclasses copied to clipboard
envclasses is a library to map fields on dataclass object to environment variables.
It would be nice if we could automate publishing the package with Github Actions
I've set up a dataclass envclass, with the following attribute: ``` RETRIES: tuple[float, ...] = (0.1, 0.5, 2) ``` my `.env.local` file contains: ``` RETRIES="[1.0, 1.0]" ``` When I load...
```python @envclass @dataclass class Hoge: d: Decimal h = Hoge(d=Decimal(10)) os.environ['ENV_D'] = '20' assert isinstance(h.d, Decimal) assert h.d == Decimal(20) ```
Currently `load_env` function takes an instance of dataclass. ```python foo = Foo() load_env(foo, ...) ``` This feature extends `load_env` to accept a class as the first argument and create an...