Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
barneygale merged 3 commits intopython:mainfrombarneygale:vfspath
May 12, 2025

Conversation

barneygale
Copy link
Contributor

@barneygalebarneygale commentedMay 5, 2025
edited
Loading

In the abstract interface ofJoinablePath, replace__str__() with__vfspath__(). This frees user implementations ofJoinablePath to implement__str__() however they like (or not at all.)

Also addpathlib._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

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__()`.
Copy link
Member

@jaracojaraco left a 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.

@barneygale
Copy link
ContributorAuthor

Just in case it wasn't obvious, it's apingos.fspath() and__fspath__() by sticking a 'v' in front.

That said, I don't love it either! :P

@jaraco
Copy link
Member

Just in case it wasn't obvious, it's apingos.fspath() and__fspath__() by sticking a 'v' in front.

In that case, perhapsvfspath is better thanvfs_path (for consistency). It's too late to consider__fs_path__ for clarity ;).

@barneygale
Copy link
ContributorAuthor

barneygale commentedMay 7, 2025
edited
Loading

I guessvirtual_path() and__virtual_path__() could work? Might be confused with__path__ though

@barneygale
Copy link
ContributorAuthor

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

@barneygalebarneygale requested a review frompfmooreMay 9, 2025 18:52
@pfmoore
Copy link
Member

"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.

barneygale reacted with thumbs up emojibarneygale reacted with laugh emoji

@encukou
Copy link
Member

Looks good on a cursory look.
I don't think I'll get to do an in-depth review soon.

@barneygale
Copy link
ContributorAuthor

Thanks for the sense check!

@barneygalebarneygale merged commit5dbd27d intopython:mainMay 12, 2025
38 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@encukouencukouencukou left review comments

@jaracojaracojaraco approved these changes

@pfmoorepfmoorepfmoore approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@barneygale@jaraco@pfmoore@encukou

[8]ページ先頭

©2009-2025 Movatter.jp