From cb736a25fb1482527867397f59ad20455aeb9d02 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 6 Mar 2024 15:01:46 -0500 Subject: [PATCH] Enable PERF401 ruff rule --- fsspec/caching.py | 22 ++++++++++++++-------- pyproject.toml | 1 - 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/fsspec/caching.py b/fsspec/caching.py index 8d441fe46..b1a51f1e2 100644 --- a/fsspec/caching.py +++ b/fsspec/caching.py @@ -345,14 +345,17 @@ def _read_cache( else: # read from the initial - out = [] - out.append(self._fetch_block_cached(start_block_number)[start_pos:]) + out = [self._fetch_block_cached(start_block_number)[start_pos:]] # intermediate blocks # Note: it'd be nice to combine these into one big request. However # that doesn't play nicely with our LRU cache. - for block_number in range(start_block_number + 1, end_block_number): - out.append(self._fetch_block_cached(block_number)) + out.extend( + map( + self._fetch_block_cached, + range(start_block_number + 1, end_block_number), + ) + ) # final block out.append(self._fetch_block_cached(end_block_number)[:end_pos]) @@ -821,14 +824,17 @@ def _read_cache( else: # read from the initial - out = [] - out.append(self._fetch_block_cached(start_block_number)[start_pos:]) + out = [self._fetch_block_cached(start_block_number)[start_pos:]] # intermediate blocks # Note: it'd be nice to combine these into one big request. However # that doesn't play nicely with our LRU cache. - for block_number in range(start_block_number + 1, end_block_number): - out.append(self._fetch_block_cached(block_number)) + out.extend( + map( + self._fetch_block_cached, + range(start_block_number + 1, end_block_number), + ) + ) # final block out.append(self._fetch_block_cached(end_block_number)[:end_pos]) diff --git a/pyproject.toml b/pyproject.toml index e0b21db0b..327a51f32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,7 +75,6 @@ ignore = [ # Fix these codes later "G004", "PERF203", - "PERF401", ] [tool.pytest.ini_options]