Skip to content

Commit 534ea8d

Browse files
authored
feat: allow empty get_mapper calls (#930)
Instead of requiring `""` or `"/"`, use `""` in both `get_mapper` implementations.
1 parent dcd8b22 commit 534ea8d

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

fsspec/implementations/tests/test_archive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def test_glob(self, scenario: ArchiveTestScenario):
249249
def test_mapping(self, scenario: ArchiveTestScenario):
250250
with scenario.provider(archive_data) as archive:
251251
fs = fsspec.filesystem(scenario.protocol, fo=archive)
252-
m = fs.get_mapper("")
252+
m = fs.get_mapper()
253253
assert list(m) == ["a", "b", "deeply/nested/path"]
254254
assert m["b"] == archive_data["b"]
255255

fsspec/implementations/tests/test_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def test_1(m):
99
files = m.find("")
1010
assert files == ["/afiles/and/another", "/somefile"]
1111

12-
files = sorted(m.get_mapper("/"))
12+
files = sorted(m.get_mapper())
1313
assert files == ["afiles/and/another", "somefile"]
1414

1515

fsspec/mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def maybe_convert(value):
187187

188188

189189
def get_mapper(
190-
url,
190+
url="",
191191
check=False,
192192
create=False,
193193
missing_exceptions=None,

fsspec/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ def _get_pyarrow_filesystem(self):
11531153
# all instances already also derive from pyarrow
11541154
return self
11551155

1156-
def get_mapper(self, root, check=False, create=False):
1156+
def get_mapper(self, root="", check=False, create=False):
11571157
"""Create key/value store based on this file-system
11581158
11591159
Makes a MutableMapping interface to the FS at the given root path.

fsspec/tests/test_mapping.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
import fsspec
8+
from fsspec.implementations.local import LocalFileSystem
89
from fsspec.implementations.memory import MemoryFileSystem
910

1011

@@ -143,3 +144,8 @@ def test_setitem_numpy():
143144
dtype="<m8[ns]",
144145
) # timedelta64 scalar
145146
assert m["c"] == b',M"\x9e\xc6\x99A\x065\x1c\xf0Rn4\xcb+'
147+
148+
149+
def test_empty_url():
150+
m = fsspec.get_mapper()
151+
assert isinstance(m.fs, LocalFileSystem)

0 commit comments

Comments
 (0)