-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Hi UPath maintainers 🫡
Just came across this package this morning after having the same need for a pathlib-style API backed by fsspec - nice to see its already an OS package 🥇
I was wondering how keen you would be to enabling (or accepting a PR for) pydantic v1 type compatibility? I believe it would be as simple as adding in:
class UPath(...):
...
@classmethod
def __get_validators__(cls) -> Iterator[Callable]:
yield cls._validate
@classmethod
def _validate(cls, v: Any) -> UPath:
return cls(v)
or perhaps with a try/except catch around cls(v) to ensure a ValidationError is thrown if an exception is thrown during cls(v).
I noticed you recently added pydantic v2 support, so was wondering whether this small adjustment would enable the UPath to be used in both pydantic v1 and v2 models.
I note that whilst supporting v1 is potentially not a long term solution, I imagine there are still a number of use cases that could benefit from v1 support and I don't believe it will interfere with any v2 support since they use different validation mechanisms.
What are your thoughts on this? Would you be receptive to a v1 validation PR? 🙏 Thanks in advance!