Skip to content

Commit 073aac8

Browse files
Forward kwargs from cat_ranges to cat_file (#2044)
Fixes #2016
1 parent 2818611 commit 073aac8

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

fsspec/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ def cat_ranges(
874874
out = []
875875
for p, s, e in zip(paths, starts, ends):
876876
try:
877-
out.append(self.cat_file(p, s, e))
877+
out.append(self.cat_file(p, s, e, **kwargs))
878878
except Exception as e:
879879
if on_error == "return":
880880
out.append(e)

fsspec/tests/test_spec.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,3 +1456,21 @@ def test_expand_path_with_magic_input():
14561456
"bucket/file?.txt",
14571457
]
14581458
assert sorted(paths) == sorted(expected)
1459+
1460+
1461+
def test_cat_ranges_forwards_kwargs():
1462+
# See GH#2016: cat_ranges must forward **kwargs to cat_file, otherwise
1463+
# parameters such as a cache's block_size are silently dropped.
1464+
received = []
1465+
1466+
class RecordingFS(AbstractFileSystem):
1467+
cachable = False
1468+
1469+
def cat_file(self, path, start=None, end=None, **kwargs):
1470+
received.append(kwargs)
1471+
return b""
1472+
1473+
fs = RecordingFS()
1474+
fs.cat_ranges(["a", "b"], [0, 0], [1, 1], block_size=42)
1475+
1476+
assert received == [{"block_size": 42}, {"block_size": 42}]

0 commit comments

Comments
 (0)