Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
GH-128520: pathlib ABCs: addJoinablePath.__vfspath__()
#133437
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
In the abstract interface of `JoinablePath`, replace `__str__()` with`__vfspath__()`. This frees user implementations of `JoinablePath` toimplement `__str__()` however they like (or not at all.)Also add `pathlib._os.vfspath()`, which calls `__fspath__()` and/or`__vfspath__()`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This sounds like the right solution for decoupling the use of__str__
for casual user use and for the specific API purpose required byJoinablePath
. I don'tlove the namevfspath
. If that's the phrasing, I like to see at leastvfs_path
(separate the two terms). Even better would be to come up with a name that's a single word (__moniker__
,__location__
,__traversal__
, ...), but I'm not coming up right now with any word I love. Regardless, I'll be happy with whatever property name you settle on.
Just in case it wasn't obvious, it's aping That said, I don't love it either! :P |
In that case, perhaps |
barneygale commentedMay 7, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I guess |
Thanks for the review btw, much appreciated! I'll wait to see what Petr thinks before I go any further. I should add Mr Moore too, actually |
"Mr. Moore" - how grand 🙂 (If it's because you didn't know my first name, it's Paul 👋). This seems like a reasonable enough change, and I agree with the basic idea that we should separate "the string representation" from "the representation as a path string". It's a very subtle distinction, though, and I think that before we can expect users to work with the new API, it'll need some pretty good documentation. I'm happy to defer that for now, but I don't think we can say user-defined path subclasses are ready for general use without it. In practical terms, this feels like a small step, with a lot of compatibility and design questions to follow, but I'm fine with a small starting step. |
Uh oh!
There was an error while loading.Please reload this page.
Looks good on a cursory look. |
Thanks for the sense check! |
5dbd27d
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
In the abstract interface of
JoinablePath
, replace__str__()
with__vfspath__()
. This frees user implementations ofJoinablePath
to implement__str__()
however they like (or not at all.)Also add
pathlib._os.vfspath()
, which calls__fspath__()
or__vfspath__()
. This will be exported as a public function in the pathlib-abc PyPI package.Some related discussion here:https://discuss.python.org/t/protocol-for-virtual-filesystem-paths/82753