-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add suffix function to the fs module #14802
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
base: master
Are you sure you want to change the base?
Conversation
74acc58
to
6e80fb8
Compare
The corner case of an 'empty-but-present suffix' (e.g. |
Everything looks good to me other than the one very small nit, so this should be good to go. |
Should Meson instead use already os.path.splitext so that it already uses the 3.14 behavior? |
I agree, and also we should have a test for this so the behaviour stays the same regardless of Python version. |
pathlib for concrete paths has a lot of ugly and painful corners (the purepaths are much better), I'd prefer to use |
I'll try to find some time end of next week to redo the module in terms of |
2df195c
to
3fc80eb
Compare
There was a single call to |
The failing checks are due to a bug in I'm not sure what to do. We cannot use |
Maybe but I don't see any alternative. Just use a PurePath and add a link to python/cpython#44626 in a comment. Thanks for looking into the failures! |
3fc80eb
to
02e6de4
Compare
How about this fix? We would otherwise (and currently are) be affected by a related bug where incomplete UNC paths (which are absolute because they don't depend on the current working directory) would not be considered absolute. |
02e6de4
to
9f7fc43
Compare
The previous test failure was due to an implicit assumption that Let me know if we want to reinstate the separator-changing behavior of |
9f7fc43
to
d554cfb
Compare
d554cfb
to
fe36f78
Compare
The CI failures seem unrelated. Before my last push, where I corrected some authorship details, all checks passed. Maybe someone can restart the unsuccessful checks? |
When iterating over a list of files, it can be convenient to check suffixes. You could already do
fs.name(file).endswith('.txt')
, butfs.suffix(file) == '.txt'
is just that tiny bit nicer. We also get the invariantfs.name(file) == fs.stem(file) + fs.suffix(file)
.