Skip to content

Commit 50c9db7

Browse files
committed
Ensure cached filesystems' protocol is preserved
Since `protocol` is a class attribute, it was not caught in `__getattribute__`'s call to `__dict__`, leading to the target protocol being used instead.
1 parent 81a5fd5 commit 50c9db7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

fsspec/implementations/cached.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ def __getattribute__(self, item):
483483
return getattr(type(self), item)
484484
if item == "__class__":
485485
return type(self)
486+
if item == "protocol":
487+
return type(self).protocol
486488
d = object.__getattribute__(self, "__dict__")
487489
fs = d.get("fs", None) # fs is not immediately defined
488490
if item in d:

fsspec/implementations/tests/test_cached.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,3 +1337,8 @@ def test_filecache_write(tmpdir, m):
13371337

13381338
assert m.cat(fn) == data.encode()
13391339
assert fs.cat(fn) == data.encode()
1340+
1341+
1342+
def test_cache_protocol_is_preserved():
1343+
fs = fsspec.filesystem("filecache", target_protocol="file")
1344+
assert fs.protocol == "filecache"

0 commit comments

Comments
 (0)