ProtixIT / dataclass-binder

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

Compare TOML serialization to default value #32

Closed mthuurne closed 1 year ago

mthuurne commented 1 year ago

If a field is defined with a default sequence, for example:

    allowed_hosts: Sequence[str] = (".localhost", "127.0.0.1", "[::1]")

And the runtime value is a sequence of a different type but with the same contents, like:

    config.allowed_hosts = [".localhost", "127.0.0.1", "[::1]"]

The template output will be:

# Default:
# allowed-hosts = ['.localhost', '127.0.0.1', '[::1]']
allowed-hosts = ['.localhost', '127.0.0.1', '[::1]']

Which goes against the idea of omitting default values from the TOML template.