From 857b27579968dfb947d0cedb19480e5472336a84 Mon Sep 17 00:00:00 2001 From: ANIS <119749586+assinscreedFC@users.noreply.github.com> Date: Sat, 6 Jun 2026 01:12:11 +0200 Subject: [PATCH] Forward kwargs from cat_ranges to cat_file AbstractFileSystem.cat_ranges accepts **kwargs but dropped them when calling cat_file, so parameters such as a cache's block_size were silently ignored and every range read bypassed the cache. The async AsyncFileSystem._cat_ranges already forwards them. Pass **kwargs through to cat_file, matching the async implementation. Fixes #2016 --- fsspec/spec.py | 2 +- fsspec/tests/test_spec.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/fsspec/spec.py b/fsspec/spec.py index 3a71b2227..a390bf060 100644 --- a/fsspec/spec.py +++ b/fsspec/spec.py @@ -874,7 +874,7 @@ def cat_ranges( out = [] for p, s, e in zip(paths, starts, ends): try: - out.append(self.cat_file(p, s, e)) + out.append(self.cat_file(p, s, e, **kwargs)) except Exception as e: if on_error == "return": out.append(e) diff --git a/fsspec/tests/test_spec.py b/fsspec/tests/test_spec.py index 8880c255c..7fc828243 100644 --- a/fsspec/tests/test_spec.py +++ b/fsspec/tests/test_spec.py @@ -1456,3 +1456,21 @@ def test_expand_path_with_magic_input(): "bucket/file?.txt", ] assert sorted(paths) == sorted(expected) + + +def test_cat_ranges_forwards_kwargs(): + # See GH#2016: cat_ranges must forward **kwargs to cat_file, otherwise + # parameters such as a cache's block_size are silently dropped. + received = [] + + class RecordingFS(AbstractFileSystem): + cachable = False + + def cat_file(self, path, start=None, end=None, **kwargs): + received.append(kwargs) + return b"" + + fs = RecordingFS() + fs.cat_ranges(["a", "b"], [0, 0], [1, 1], block_size=42) + + assert received == [{"block_size": 42}, {"block_size": 42}]