Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion fsspec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ def glob(self, path, maxdepth=None, **kwargs):
min_idx = min(idx_star, idx_qmark, idx_brace)

detail = kwargs.pop("detail", False)
withdirs = kwargs.pop("withdirs", True)

if not has_magic(path):
if self.exists(path, **kwargs):
Expand Down Expand Up @@ -639,7 +640,9 @@ def glob(self, path, maxdepth=None, **kwargs):
else:
depth = None

allpaths = self.find(root, maxdepth=depth, withdirs=True, detail=True, **kwargs)
allpaths = self.find(
root, maxdepth=depth, withdirs=withdirs, detail=True, **kwargs
)

pattern = glob_translate(path + ("/" if ends_with_sep else ""))
pattern = re.compile(pattern)
Expand Down
9 changes: 9 additions & 0 deletions fsspec/tests/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,15 @@ def test_glob_posix_rules(path, expected, glob_fs):
for name, info in _clean_paths(detailed_output).items():
assert info == glob_fs[name]

withdirs_output = glob_fs.glob(path=f"mock://{path}", detail=True, withdirs=False)
path_output = _clean_paths(withdirs_output)
for name, info in path_output.items():
# withdirs only respected when path has magic
# otherwise glob returns the path regardless of the type of the path
if glob.has_magic(path):
assert info["type"] == "file"
assert info == glob_fs[name]


@pytest.fixture(scope="function")
def tmpfs(tmpdir):
Expand Down
Loading