-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
GH-89812: Add pathlib._PurePathExt
#104810
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
Conversation
This internal class excludes the `__fspath__()`, `__bytes__()` and `as_uri()` methods, which must not be inherited by a future `tarfile.TarPath` class.
pathlib._LexicalPathpathlib._BasePurePath
|
The test naming is pretty janky. #104829 will help. |
Co-authored-by: Éric <[email protected]>
This reverts commit d1b23c8.
Co-authored-by: Alex Waygood <[email protected]>
|
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._BasePurePathpathlib._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 fromPurePathto a new_PurePathExtsubclass. This new subclass is inherited byPurePosixPath,PureWindowsPathandPath.Because
PurePathisn't directly instantiatable (you get aPurePosixPathorPureWindowsPathinstance back), this shouldn't change user-facing behaviour.The methods must not be inherited future
tarfile.TarPathandpathlib.AbstractPathclasses, which will subclassPurePath.