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()`?

Discussion:

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)