You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
we'd need new syntax to specify the additional checks to perform, which goes against the idea of using plain dataclasses as much as possible; while I see this as more of a guideline than a hard rule, there would have to be strong advantages to breaking it
it doesn't save the developer much work: rejecting a non-existing or non-accessible path on startup doesn't release the code using it from the obligation to handle non-existing or non-accessible paths, as the file system could have changed between the initial check and the path actually being used
for some situations, like logging directories, the desired behavior could be to attempt to create the directory if it doesn't exist yet, but doing that as a side effect of data binding feels like overreach
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.
Services might want to configure paths, such as logging directories or locations of certificates. By supporting
pathlib.Path
as a field type:Path
The text was updated successfully, but these errors were encountered: