nebius/SWE-bench-extra huggingface dataset:
Repository: fsspec/filesystem_spec

Issue:
`LocalFileSystem.ls()` does not work on filenames
Repro:

```
fs = LocalFileSystem()

fs.touch("a.json")
fs.ls("a.json")
```

I expected this to return a single-entry list with the stat object for `a.json`, but instead it raises a `NotADirectoryError` because `os.scandir()` does not allow file-like inputs:

https://github.com/fsspec/filesystem_spec/blob/069e107fa056166fd4e7db75e909ebac85f372fd/fsspec/implementations/local.py#L63-L64

In contrast, a subsequent `ls -la a.json` behaves as expected, showing the single file stat result.

Comments:

Patch:
diff --git a/fsspec/implementations/local.py b/fsspec/implementations/local.py
index e7861e2..17f96c1 100644
--- a/fsspec/implementations/local.py
+++ b/fsspec/implementations/local.py
@@ -3,7 +3,6 @@ import io
 import logging
 import os
 import os.path as osp
-import posixpath
 import re
 import shutil
 import stat
@@ -59,11 +58,16 @@ class LocalFileSystem(AbstractFileSystem):
 
     def ls(self, path, detail=False, **kwargs):
         path = self._strip_protocol(path)
-        if detail:
+        info = self.info(path)
+        if info["type"] == "directory":
             with os.scandir(path) as it:
-                return [self.info(f) for f in it]
+                infos = [self.info(f) for f in it]
         else:
-            return [posixpath.join(path, f) for f in os.listdir(path)]
+            infos = [info]
+
+        if not detail:
+            return [i["name"] for i in infos]
+        return infos
 
     def info(self, path, **kwargs):
         if isinstance(path, os.DirEntry):


Test patch:
diff --git a/fsspec/implementations/tests/test_local.py b/fsspec/implementations/tests/test_local.py
index 2980eb7..ffa5cbb 100644
--- a/fsspec/implementations/tests/test_local.py
+++ b/fsspec/implementations/tests/test_local.py
@@ -367,6 +367,16 @@ def test_directories(tmpdir):
     assert fs.ls(fs.root_marker)
 
 
+def test_ls_on_file(tmpdir):
+    tmpdir = make_path_posix(str(tmpdir))
+    fs = LocalFileSystem()
+    resource = tmpdir + "/a.json"
+    fs.touch(resource)
+    assert fs.exists(resource)
+    assert fs.ls(tmpdir) == fs.ls(resource)
+    assert fs.ls(resource, detail=True)[0] == fs.info(resource)
+
+
 @pytest.mark.parametrize("file_protocol", ["", "file://"])
 def test_file_ops(tmpdir, file_protocol):
     tmpdir = make_path_posix(str(tmpdir))
Repository: fsspec/filesystem_spec

Issue:
FileNotFoundError [LocalFileSystem] on unix-like root / directory 
Hello,

in case of `LocalFileSystem().ls('/')`, a `FileNotFoundError` is being raised. 

```python
FileNotFoundError: [Errno 2] No such file or directory: ''
```

This looks quite normal as path is stripped right 
https://github.com/fsspec/filesystem_spec/blob/b68be6c57f54a71c6ffc89e669c410da353ebc1f/fsspec/implementations/local.py#L54

Is this an expected behavior?

Comments:

Patch:
diff --git a/ci/environment-win.yml b/ci/environment-win.yml
index 7e847e7..af9671e 100644
--- a/ci/environment-win.yml
+++ b/ci/environment-win.yml
@@ -8,7 +8,7 @@ dependencies:
   - requests
   - zstandard
   - python-snappy
-  - lz4
+  - lz4<3.1.3
   - pyftpdlib
   - cloudpickle
   - pytest
diff --git a/fsspec/dircache.py b/fsspec/dircache.py
index 97a73bc..014e482 100644
--- a/fsspec/dircache.py
+++ b/fsspec/dircache.py
@@ -38,7 +38,7 @@ class DirCache(MutableMapping):
         use_listings_cache: bool
             If False, this cache never returns items, but always reports KeyError,
             and setting items has no effect
-        listings_expiry_time: int (optional)
+        listings_expiry_time: int or float (optional)
             Time in seconds that a listing is considered valid. If None,
             listings do not expire.
         max_paths: int (optional)
diff --git a/fsspec/implementations/local.py b/fsspec/implementations/local.py
index 16eda94..51f86d3 100644
--- a/fsspec/implementations/local.py
+++ b/fsspec/implementations/local.py
@@ -184,7 +184,7 @@ class LocalFileSystem(AbstractFileSystem):
         path = stringify_path(path)
         if path.startswith("file://"):
             path = path[7:]
-        return make_path_posix(path).rstrip("/")
+        return make_path_posix(path).rstrip("/") or cls.root_marker
 
     def _isfilestore(self):
         # Inheriting from DaskFileSystem makes this False (S3, etc. were)


Test patch:
diff --git a/fsspec/implementations/tests/test_local.py b/fsspec/implementations/tests/test_local.py
index 2779018..f3bbad8 100644
--- a/fsspec/implementations/tests/test_local.py
+++ b/fsspec/implementations/tests/test_local.py
@@ -370,6 +370,7 @@ def test_directories(tmpdir):
     assert fs.ls(tmpdir, True)[0]["type"] == "directory"
     fs.rmdir(tmpdir + "/dir")
     assert not fs.ls(tmpdir)
+    assert fs.ls(fs.root_marker)
 
 
 def test_file_ops(tmpdir):
Repository: fsspec/filesystem_spec

Issue:
fs.ls("/") raises error after fs.rm("/", recursive=True) for memory filesystem
To replicate this error, run this:

```python
import fsspec

fs = fsspec.filesystem("memory")
fs.rm("/", recursive=True)
fs.ls("/")
```

Which results in the following traceback:

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../site-packages/fsspec/implementations/memory.py", line 91, in ls
    raise FileNotFoundError(path)
FileNotFoundError
```
I would expect it to return an empty list as it does before the `ls.rm()` call.


Comments:

Patch:
diff --git a/fsspec/implementations/memory.py b/fsspec/implementations/memory.py
index 334f9db..9356a56 100644
--- a/fsspec/implementations/memory.py
+++ b/fsspec/implementations/memory.py
@@ -116,6 +116,9 @@ class MemoryFileSystem(AbstractFileSystem):
 
     def rmdir(self, path):
         path = self._strip_protocol(path)
+        if path == "":
+            # silently avoid deleting FS root
+            return
         if path in self.pseudo_dirs:
             if not self.ls(path):
                 self.pseudo_dirs.remove(path)
@@ -124,7 +127,7 @@ class MemoryFileSystem(AbstractFileSystem):
         else:
             raise FileNotFoundError(path)
 
-    def exists(self, path):
+    def exists(self, path, **kwargs):
         path = self._strip_protocol(path)
         return path in self.store or path in self.pseudo_dirs
 


Test patch:
diff --git a/fsspec/conftest.py b/fsspec/conftest.py
index 393e4c4..47b49c9 100644
--- a/fsspec/conftest.py
+++ b/fsspec/conftest.py
@@ -17,7 +17,7 @@ def m():
     """
     m = fsspec.filesystem("memory")
     m.store.clear()
-    m.pseudo_dirs.clear()
+    m.pseudo_dirs = [""]
     try:
         yield m
     finally:
diff --git a/fsspec/implementations/tests/test_memory.py b/fsspec/implementations/tests/test_memory.py
index 184c9ee..c647fac 100644
--- a/fsspec/implementations/tests/test_memory.py
+++ b/fsspec/implementations/tests/test_memory.py
@@ -150,3 +150,9 @@ def test_seekable(m):
     f.seek(1)
     assert f.read(1) == "a"
     assert f.tell() == 2
+
+
+def test_remove_all(m):
+    m.touch("afile")
+    m.rm("/", recursive=True)
+    assert not m.ls("/")
Repository: fsspec/filesystem_spec

Issue:
Make `url` in `get_mapper` optional
Currently when using a reference filesystem, users need to always provide an empty string `""` or `/` as the root url. Is there any reason not to set `""` or `/` as the default, so users can just do `fs.get_mapper()`?

Comments:

Patch:
diff --git a/fsspec/mapping.py b/fsspec/mapping.py
index d6346f4..8bad2de 100644
--- a/fsspec/mapping.py
+++ b/fsspec/mapping.py
@@ -187,7 +187,7 @@ def maybe_convert(value):
 
 
 def get_mapper(
-    url,
+    url="",
     check=False,
     create=False,
     missing_exceptions=None,
diff --git a/fsspec/spec.py b/fsspec/spec.py
index fa8feb3..7f9a241 100644
--- a/fsspec/spec.py
+++ b/fsspec/spec.py
@@ -1153,7 +1153,7 @@ class AbstractFileSystem(metaclass=_Cached):
         # all instances already also derive from pyarrow
         return self
 
-    def get_mapper(self, root, check=False, create=False):
+    def get_mapper(self, root="", check=False, create=False):
         """Create key/value store based on this file-system
 
         Makes a MutableMapping interface to the FS at the given root path.


Test patch:
diff --git a/fsspec/implementations/tests/test_archive.py b/fsspec/implementations/tests/test_archive.py
index 816f826..abc6d35 100644
--- a/fsspec/implementations/tests/test_archive.py
+++ b/fsspec/implementations/tests/test_archive.py
@@ -249,7 +249,7 @@ class TestAnyArchive:
     def test_mapping(self, scenario: ArchiveTestScenario):
         with scenario.provider(archive_data) as archive:
             fs = fsspec.filesystem(scenario.protocol, fo=archive)
-            m = fs.get_mapper("")
+            m = fs.get_mapper()
             assert list(m) == ["a", "b", "deeply/nested/path"]
             assert m["b"] == archive_data["b"]
 
diff --git a/fsspec/implementations/tests/test_memory.py b/fsspec/implementations/tests/test_memory.py
index c647fac..7cf29e4 100644
--- a/fsspec/implementations/tests/test_memory.py
+++ b/fsspec/implementations/tests/test_memory.py
@@ -9,7 +9,7 @@ def test_1(m):
     files = m.find("")
     assert files == ["/afiles/and/another", "/somefile"]
 
-    files = sorted(m.get_mapper("/"))
+    files = sorted(m.get_mapper())
     assert files == ["afiles/and/another", "somefile"]
 
 
diff --git a/fsspec/tests/test_mapping.py b/fsspec/tests/test_mapping.py
index 71de1e0..ed5a3b0 100644
--- a/fsspec/tests/test_mapping.py
+++ b/fsspec/tests/test_mapping.py
@@ -5,6 +5,7 @@ import sys
 import pytest
 
 import fsspec
+from fsspec.implementations.local import LocalFileSystem
 from fsspec.implementations.memory import MemoryFileSystem
 
 
@@ -143,3 +144,8 @@ def test_setitem_numpy():
         dtype="<m8[ns]",
     )  # timedelta64 scalar
     assert m["c"] == b',M"\x9e\xc6\x99A\x065\x1c\xf0Rn4\xcb+'
+
+
+def test_empty_url():
+    m = fsspec.get_mapper()
+    assert isinstance(m.fs, LocalFileSystem)
Repository: ftao/python-ifcfg

Issue:
Python 2 syntax in `cli.py`
A `print` statement has entered the codebase!

Comments:

Patch:
diff --git a/src/ifcfg/cli.py b/src/ifcfg/cli.py
index a489f28..fe48138 100644
--- a/src/ifcfg/cli.py
+++ b/src/ifcfg/cli.py
@@ -1,9 +1,12 @@
-import ifcfg
+from __future__ import print_function
+
 import json
 
+import ifcfg
+
 
 def main():
-    print json.dumps(ifcfg.interfaces(), indent=2)
+    print(json.dumps(ifcfg.interfaces(), indent=2))
 
 
 if __name__ == "__main__":


Test patch:
diff --git a/tests/cli_tests.py b/tests/cli_tests.py
new file mode 100644
index 0000000..3146025
--- /dev/null
+++ b/tests/cli_tests.py
@@ -0,0 +1,5 @@
+from ifcfg import cli
+
+
+def test_cli():
+    cli.main()