Repository navigation
Honor depth limits and include directories in recursive find - #411
shcheklein wants to merge 55 commits into
Conversation
shcheklein
left a comment
There was a problem hiding this comment.
AI-generated review of 31de6118ae3e7d21aeb05d7e3a83bdadbfdf1720.
Good fix for maxdepth, withdirs, glob, and expand_path (including fsspec>=2021.07.0 maxdepth=0 and positional find(path, True) compatibility). Inline comments focus on simplifying find() (it doubled from ~48 to ~99 lines mainly due to duplicated self.info(path) fallbacks for untyped mount IDs), avoiding extra info() calls on directories with only subdirectories, and a key-vs-entry["name"] trailing-slash mismatch when detail=True, withdirs=True.
shcheklein
left a comment
There was a problem hiding this comment.
AI-generated re-review of 1dc810a85e2268d42dad294c541740083ae99102 (from scratch).
Big improvement—the duplicated self.info() fallback is gone, key == entry["name"] is now consistent via _directory_entry, known_dir = True in the loop avoids extra stat calls on subdirs-only mounts, and the unit + live tests are thorough.
No standalone bugs found; two small cross-PR alignment notes with #409 inline.
There was a problem hiding this comment.
🟡 Changes recommended
A cached named directory deleted or trashed externally can still appear in find results because its existence and trash status are not revalidated before inclusion.
1 open issue
What changed in this PR
This PR improves the Drive filesystem’s recursive discovery, building on the directory-cache and creation work to support fsspec traversal options.
Changes:
- Adds depth limits, optional directory inclusion, sorted results, and a warning for legacy positional
detail. - Uses cached folder IDs to batch traversal while deriving paths from current parent links.
- Expands traversal and request-count tests, and raises the minimum fsspec version to 2024.2.0.
| File | Description |
|---|---|
pyproject.toml |
Raises the minimum fsspec dependency. |
pydrive2/test/test_fs.py |
Adds live depth, directory, glob, and expansion checks. |
pydrive2/test/test_fs_unit.py |
Adds traversal, mount, sorting, and request-count coverage. |
pydrive2/test/test_fs_listing.py |
Removes the wide-directory test replaced by HTTP-level coverage. |
pydrive2/fs/spec.py |
Implements bounded traversal, directory results, and positional compatibility. |
docs/fsspec.rst |
Documents the dependency minimum and traversal conventions. |
.github/workflows/test.yml |
Tests minimum fsspec on Ubuntu with Python 3.11. |
Review effort: Balanced
# Conflicts: # pydrive2/fs/spec.py
# Conflicts: # pydrive2/fs/spec.py


Fixes #325. This PR builds on #409 and #408.
find()honorsmaxdepthandwithdirs, sorts both output formats, and warns callers using the deprecated positional booleandetail. Cached folder IDs allow warm traversal across multiple levels in one Drive request. Current parent links determine the returned paths.The filesystem extra requires fsspec 2024.2.0 or newer. The Ubuntu Python 3.11 job tests that minimum. Bounded glob expansion delegates to fsspec. The tests cover depth 1 through 3, glob expansion, sorting, file and directory mounts, and exact cold and warm request counts. The wide fixture takes seven requests cold and six warm.