-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
GH-89812: Add pathlib._PurePathExt
#104810
Conversation
This internal class excludes the `__fspath__()`, `__bytes__()` and `as_uri()` methods, which must not be inherited by a future `tarfile.TarPath` class.
pathlib._LexicalPath
pathlib._BasePurePath
The test naming is pretty janky. #104829 will help. |
Co-authored-by: Éric <merwok@netwok.org>
This reverts commit d1b23c8.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Would anyone be willing to review #104829? It blocks this PR. (please and thank you!) |
#104829 has landed, so test naming should be much improved! Think this is ready for review again. |
pathlib._BasePurePath
pathlib._PurePathExt
I've revised the implementation such that the methods are actually removed from (Contrast this with the earlier proposed hierarchy where The methods are moved to a new This change will not be visible to users who try to instantiate It will be visible to users who subclass |
Just a note that I’m meditating on https://hynek.me/articles/python-subclassing-redux/ and linked articles at the moment and wondering if controlling subclass explosion in pathlib should be a guideline 🙂 |
Oh I totally agree. I'd prefer to add only And if I were to do pathlib over again, I'd scrap the |
I've converted this back to a draft as I'm still in two minds about how to implement this. It's possible I'll add |
Move
__fspath__()
,__bytes__()
andas_uri()
methods fromPurePath
to a new_PurePathExt
subclass. This new subclass is inherited byPurePosixPath
,PureWindowsPath
andPath
.Because
PurePath
isn't directly instantiatable (you get aPurePosixPath
orPureWindowsPath
instance back), this shouldn't change user-facing behaviour.The methods must not be inherited future
tarfile.TarPath
andpathlib.AbstractPath
classes, which will subclassPurePath
.