-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More convenient pathlib.Path types #149
Labels
Comments
Thanks for the feature request. I'm sure many people would appreciate extended support for these types. The right place for these, though, is in |
Makes sense, thank you! |
13 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Initial Checks
Description
Working with Paths is fairly common and I usually end up writing my own field validator over and over again because the type I want is missing. I would like to see the Path types in pydantic extended with some more potentially useful types:
ExistingPath
-Union[FilePath, DirectoryPath]
ResolvedFilePath
- A file that get's resolved (pathlib.Path.expanduser().resolve()
) by pydantic before returningResolvedDirectoryPath
- A directory that get's resolved (pathlib.Path.expanduser().resolve()
) by pydantic before returningResolvedPath
-Union[ResolvedFilePath, ResolvedDirectoryPath]
My current solution is to just write a field validator:
Affected Components
.model_dump()
and.model_dump_json()
model_construct()
, pickling, private attributes, ORM modeThe text was updated successfully, but these errors were encountered: