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 `Path` as a field type #40

Closed mthuurne closed 1 year ago

mthuurne commented 1 year ago

Services might want to configure paths, such as logging directories or locations of certificates. By supporting pathlib.Path as a field type:

mthuurne commented 1 year ago

I was thinking of whether there could also be a way to have the binder perform additional checks, such as whether a referenced path exists. However, there are a lot of problems with that:

So I think it's better not to do anything beyond constructing the Path object. If the developer wants to do more, __post_init__() can be used.