ProtixIT / dataclass-binder

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

Allow instantiating a `Binder` from a dataclass instance #17

Closed mthuurne closed 1 year ago

mthuurne commented 1 year ago

The format_template() function can take either a dataclass or a dataclass instance as its argument. If the Binder class could do the same, we could make format_template() a method on Binder.

Additionally, this would allow for layered configurations:

system_config = Binder(Config).parse_toml(system_config_file)
config = Binder(system_config).parse_toml(user_config_file)