Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
GH-110109: Add pathlib._PurePathBase#110670
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
barneygale commented Oct 11, 2023 • 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.
Add private `pathlib._PurePathBase` class: a private superclass of both `PurePath` and `_PathBase`. Unlike `PurePath`, it does not define any of these special methods: `__fspath__`, `__bytes__`, `__reduce__`, `__hash__`, `__eq__`, `__lt__`, `__le__`, `__gt__`, `__ge__`. This is important for supporting *virtual paths*: user subclasses of `_PathBase` that provide access to archive files, FTP servers, etc. In these classes, the above methods should be implemented by users only as appropriate, with due consideration for the hash/equality of any backing objects, such as file objects or sockets.
barneygale commented Oct 11, 2023
FYI @AlexWaygood. We avoided adding this class previously with your clever suggestion to set But I'm increasingly convinced that this extra class is needed after all - there are too many |
barneygale commented Oct 11, 2023
barneygale commented Nov 13, 2023 • 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.
Quite a lot of this patch is re-ordering methods. I've split that stuff off into a preparatory PR, which will help make this PR easier to review: |
barneygale commented Nov 28, 2023
Once this lands, I plan to:
It's going to be a while before |
barneygale commented Dec 8, 2023
Given that this change is blocking work on pathlib ABCs, and should have no observable effects on any public APIs, I'm going to merge it without waiting any longer for review. If that doesn't seem right to anyone, please let me know and I can revert it. I'm never quite sure where to draw the line on these things. |
Add private `pathlib._PurePathBase` class: a private superclass of both `PurePath` and `_PathBase`. Unlike `PurePath`, it does not define any of these special methods: `__fspath__`, `__bytes__`, `__reduce__`, `__hash__`, `__eq__`, `__lt__`, `__le__`, `__gt__`, `__ge__`. Its initializer and path joining methods accept only strings, not os.PathLike objects more broadly. This is important for supporting *virtual paths*: user subclasses of `_PathBase` that provide access to archive files, FTP servers, etc. In these classes, the above methods should be implemented by users only as appropriate, with due consideration for the hash/equality of any backing objects, such as file objects or sockets.
Add private `pathlib._PurePathBase` class: a private superclass of both `PurePath` and `_PathBase`. Unlike `PurePath`, it does not define any of these special methods: `__fspath__`, `__bytes__`, `__reduce__`, `__hash__`, `__eq__`, `__lt__`, `__le__`, `__gt__`, `__ge__`. Its initializer and path joining methods accept only strings, not os.PathLike objects more broadly. This is important for supporting *virtual paths*: user subclasses of `_PathBase` that provide access to archive files, FTP servers, etc. In these classes, the above methods should be implemented by users only as appropriate, with due consideration for the hash/equality of any backing objects, such as file objects or sockets.

Add private
pathlib._PurePathBaseclass: a private superclass of bothPurePathand_PathBase. UnlikePurePath, it does not define any of these special methods:__fspath__,__bytes__,__reduce__,__hash__,__eq__,__lt__,__le__,__gt__,__ge__. Its initializer and path joining methods accept only strings, not os.PathLike objects more broadly.This is important for supporting virtual paths: user subclasses of
_PathBasethat provide access to archive files, FTP servers, etc. In these classes, the above methods should be implemented by users only as appropriate, with due consideration for the hash/equality of any backing objects, such as file objects or sockets.