diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a3998023a..c00ef57f3 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -155,5 +155,5 @@ jobs: run: | cd ${{ matrix.FRIEND }} pip install -e . --no-deps - pytest -v -W ignore::pytest.PytestRemovedIn9Warning --ignore=gcsfs/tests/perf + pytest -v -W ignore::pytest.PytestRemovedIn10Warning --ignore=gcsfs/tests/perf cd .. diff --git a/fsspec/asyn.py b/fsspec/asyn.py index f6a58fc2a..32ad3d35d 100644 --- a/fsspec/asyn.py +++ b/fsspec/asyn.py @@ -745,7 +745,7 @@ async def _info(self, path, **kwargs): async def _ls(self, path, detail=True, **kwargs): raise NotImplementedError - async def _walk(self, path, maxdepth=None, on_error="omit", **kwargs): + async def _walk(self, path, maxdepth=None, topdown=True, on_error="omit", **kwargs): if maxdepth is not None and maxdepth < 1: raise ValueError("maxdepth must be at least 1") @@ -783,22 +783,35 @@ async def _walk(self, path, maxdepth=None, on_error="omit", **kwargs): else: files[name] = info - if detail: + if not detail: + dirs = list(dirs) + files = list(files) + + if topdown: + # Yield before recursion if walking top down yield path, dirs, files - else: - yield path, list(dirs), list(files) if maxdepth is not None: maxdepth -= 1 if maxdepth < 1: + if not topdown: + yield path, dirs, files return for d in dirs: async for _ in self._walk( - full_dirs[d], maxdepth=maxdepth, detail=detail, **kwargs + full_dirs[d], + maxdepth=maxdepth, + detail=detail, + topdown=topdown, + **kwargs, ): yield _ + if not topdown: + # Yield after recursion if walking bottom up + yield path, dirs, files + async def _glob(self, path, maxdepth=None, **kwargs): if maxdepth is not None and maxdepth < 1: raise ValueError("maxdepth must be at least 1")