ProtixIT / dataclass-binder

Python library to bind TOML data to dataclasses in a type-safe way
MIT License
13 stars 2 forks source link

Support binding from/to environment variables #33

Open mthuurne opened 1 year ago

mthuurne commented 1 year ago

For simple configurations, environment variables can be an easy and flexible mechanism. Therefore it would be useful to support binding from/to environment variables.

More complex configurations, in particular nested dataclasses, don't map to environment variables very well. In fact, that was one of the motivations for creating this library in the first place, as TOML can deal with complex configurations. But that shouldn't prevent us from supporting simple configurations.

I think the implementation shouldn't be hardcoded for environment variables and instead operate with any Mapping[str, str] data structure, with either a convenience method or a default that uses the environment.