Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
GH-127456: pathlib ABCs: add protocol for path parser#127494
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
`posixpath`. As a result, user subclasses of `PurePathBase` and `PathBase`use POSIX path syntax by default, which is very often desirable.
…t itto a runtime-checkable protocol.
…ies.Objects of this type provide a subset of the `os.DirEntry` API,specifically those methods and attributes needed to implement `glob()` and`walk()`.
Objects of this type provide a small subset of the `os.stat_result` API,specifically attributes for the file type, permissions and location/offset.
Uh oh!
There was an error while loading.Please reload this page.
This looks reasonable, but
Also, I guess typing has no way to say that e.g. if It seems that for your goal of supporting virtual filesystems, it might be better to rely on
|
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
barneygale commentedDec 3, 2024 • 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.
Thank you for the feedback and reviews.
I've occasionally thought about adding a I don't think |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
|
I'm not a fan of the I'm not sure what such an API should look like, apart from I want it to have the |
Brainstorming: A downside is that this breaks the rule that touching the filesystem is done by methods, not attributes. (Can we say rule was for getting “fresh” information, and we can use something else here?) |
This all sounds great to me.
Why would accessing |
barneygale commentedDec 5, 2024 • 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.
Oh, I suppose you might want to |
(Process note - we should probably move the API design discussion off this PR)
What we need to design is the way for a user to discover that they've got cached values, and reset it. A |
Following up on the forum:https://discuss.python.org/t/ergonomics-of-new-pathlib-path-scandir/71721/30 |
I've removed |
Uh oh!
There was an error while loading.Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
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.
The reduced PR to just the parser changes LGTM
Thanks both, very much appreciate the feedback :-) |
5c89adf
intopython:mainUh oh!
There was an error while loading.Please reload this page.
…27494)Change the default value of `PurePathBase.parser` from `ParserBase()` to`posixpath`. As a result, user subclasses of `PurePathBase` and `PathBase`use POSIX path syntax by default, which is very often desirable.Move `pathlib._abc.ParserBase` to `pathlib._types.Parser`, and convert itto a runtime-checkable protocol.Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
Change the default value of
PurePathBase.parser
fromParserBase()
toposixpath
. As a result, user subclasses ofPurePathBase
andPathBase
use POSIX path syntax by default, which is very often desirable.Move
pathlib._abc.ParserBase
topathlib._types.Parser
, and convert it to a runtime-checkable protocol.No user-facing changes as the pathlib ABCs are still private.