A configuration template is useful as a starting point for a manually crafted configuration. However, in some cases we want to automatically produce a full configuration that doesn't require manual editing. In those cases, we want just the given data to end up in the output and no examples for optional elements that could have been configured but weren't.
This PR adds a format_toml() method, which operates similar to format_toml_template() but leaves out optional elements unless there is data present for them.
The output of format_toml() when called on a Binder that wraps a dataclass instance is guaranteed to be valid TOML. That guarantee doesn't hold when a dataclass itself is wrapped, because there is no data to put into mandatory fields then.
A configuration template is useful as a starting point for a manually crafted configuration. However, in some cases we want to automatically produce a full configuration that doesn't require manual editing. In those cases, we want just the given data to end up in the output and no examples for optional elements that could have been configured but weren't.
This PR adds a
format_toml()
method, which operates similar toformat_toml_template()
but leaves out optional elements unless there is data present for them.The output of
format_toml()
when called on aBinder
that wraps a dataclass instance is guaranteed to be valid TOML. That guarantee doesn't hold when a dataclass itself is wrapped, because there is no data to put into mandatory fields then.