-
Notifications
You must be signed in to change notification settings - Fork 68
Re-implement glob logic #202
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #202 +/- ##
========================================
+ Coverage 94.3% 94.7% +0.4%
========================================
Files 21 21
Lines 1198 1247 +49
========================================
+ Hits 1130 1182 +52
+ Misses 68 65 -3
|
jayqi
requested changes
Feb 5, 2022
@jayqi review comments implemented, thanks! |
jayqi
approved these changes
Feb 5, 2022
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.
I'm still pretty amazed that we got this to work. Exciting stuff!
This was referenced Feb 5, 2022
Merged
jayqi
requested changes
Feb 6, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
glob
,rglob
, anditerdir
did not work as their pathlib counterparts did.In order to align our implementation with the
pathlib
versions, we adaptedCloudPaths
to work in the same way that the CPython implementation ofglob
does, which is relatively complex in order to handle all of the glob scenarios. This is based on the_Selector
class.This change introduces two internal classes,
_CloudPathSelectable
and_CloudPathSelectableAccessor
that wrap aCloudPath
to expose the methods expected by_Selector
and its children.The change also changes the internal
Client._list_dir
API to return a tuple of the form (entry, is_dir), which could help address #181 and #176. Internal code where we useiterdir
can be replaced with_list_dir
if knowing if something is a file or directory is done within the method.In order to close #15, this also makes sure that
iterdir
does not includeself
.In order to make the tests pass, this also closes #186, which drops support for Python 3.6
Tests for all of these changes are included. The test suite is created to mirror the tests for
glob
andrglob
in the CPython codebase. Note:test_glob_many_open_files
, which emulates a CPython tests is pretty slow. We may consider not matching to the same depth and range to speed that up if it becomes frustrating.Note: This does leverage some internals of CPython to work correctly. It's possible that implementations without the
_make_selector, _posix_flavour
private apis will not work. If this is a problem, we may need to re-implement or vendor_Selector
and its child classes. It seems to at least work fine onpypy
not sure about anything else:Closes #154
Closes #15
Closes #186