Skip to content

Commit 28ca455

Browse files
authored
Disable clobbering of implementations by default (#1237)
1 parent 60dcd8e commit 28ca455

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

fsspec/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ def process_entries():
5151
for spec in specs:
5252
err_msg = f"Unable to load filesystem from {spec}"
5353
register_implementation(
54-
spec.name, spec.value.replace(":", "."), errtxt=err_msg
54+
spec.name,
55+
spec.value.replace(":", "."),
56+
errtxt=err_msg,
57+
# We take our implementations as the ones to overload with if
58+
# for some reason we encounter some, may be the same, already
59+
# registered
60+
clobber=True,
5561
)
5662

5763

fsspec/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
default = "file"
1313

1414

15-
def register_implementation(name, cls, clobber=True, errtxt=None):
15+
def register_implementation(name, cls, clobber=False, errtxt=None):
1616
"""Add implementation class to the registry
1717
1818
Parameters

fsspec/tests/test_registry.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ def test_register_fail(clear_registry):
6969
with pytest.raises(ImportError):
7070
get_filesystem_class("test")
7171

72-
register_implementation("test", "doesntexist.AbstractFileSystem")
7372
with pytest.raises(ValueError):
7473
register_implementation("test", "doesntexist.AbstractFileSystem", clobber=False)
7574

75+
# by default we do not allow clobbering
76+
with pytest.raises(ValueError):
77+
register_implementation("test", "doesntexist.AbstractFileSystem")
78+
7679
register_implementation(
7780
"test", "doesntexist.AbstractFileSystem", errtxt="hiho", clobber=True
7881
)
@@ -82,7 +85,7 @@ def test_register_fail(clear_registry):
8285
register_implementation("test", AbstractFileSystem)
8386

8487
with pytest.raises(ValueError):
85-
register_implementation("test", AbstractFileSystem, clobber=False)
88+
register_implementation("test", AbstractFileSystem)
8689
register_implementation("test", AbstractFileSystem, clobber=True)
8790

8891

0 commit comments

Comments
 (0)