diff --git a/fsspec/implementations/local.py b/fsspec/implementations/local.py index 900773f6a..619ea1d00 100644 --- a/fsspec/implementations/local.py +++ b/fsspec/implementations/local.py @@ -63,8 +63,9 @@ def ls(self, path, detail=False, **kwargs): with os.scandir(path) as it: for f in it: try: - # Only get the info if requested since it is a bit expensive - info = self.info(f) if detail else f.path + # Only get the info if requested since it is a bit expensive (the stat call inside) + # The strip_protocol is also used in info() and calls make_path_posix to always return posix paths + info = self.info(f) if detail else self._strip_protocol(f.path) infos.append(info) except FileNotFoundError: pass diff --git a/fsspec/implementations/tests/test_local.py b/fsspec/implementations/tests/test_local.py index f33541088..2820c14f5 100644 --- a/fsspec/implementations/tests/test_local.py +++ b/fsspec/implementations/tests/test_local.py @@ -397,7 +397,7 @@ def test_directories(tmpdir): def test_ls_on_file(tmpdir): tmpdir = make_path_posix(str(tmpdir)) fs = LocalFileSystem() - resource = str(Path(tmpdir) / "a.json") + resource = tmpdir + "/a.json" fs.touch(resource) assert fs.exists(resource) assert fs.ls(tmpdir) == fs.ls(resource) @@ -408,7 +408,7 @@ def test_ls_on_file(tmpdir): def test_ls_on_files(tmpdir): tmpdir = make_path_posix(str(tmpdir)) fs = LocalFileSystem() - resources = [str(Path(tmpdir)/f) for f in ["file_1.json", "file_2.json"]] + resources = [f"{tmpdir}/{file}" for file in ["file_1.json", "file_2.json"]] for r in resources: fs.touch(r)