Skip to content

Commit e2a0c38

Browse files
authored
Enable PERF401 ruff rule (#1538)
1 parent 2fc795f commit e2a0c38

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

fsspec/caching.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,17 @@ def _read_cache(
345345

346346
else:
347347
# read from the initial
348-
out = []
349-
out.append(self._fetch_block_cached(start_block_number)[start_pos:])
348+
out = [self._fetch_block_cached(start_block_number)[start_pos:]]
350349

351350
# intermediate blocks
352351
# Note: it'd be nice to combine these into one big request. However
353352
# that doesn't play nicely with our LRU cache.
354-
for block_number in range(start_block_number + 1, end_block_number):
355-
out.append(self._fetch_block_cached(block_number))
353+
out.extend(
354+
map(
355+
self._fetch_block_cached,
356+
range(start_block_number + 1, end_block_number),
357+
)
358+
)
356359

357360
# final block
358361
out.append(self._fetch_block_cached(end_block_number)[:end_pos])
@@ -821,14 +824,17 @@ def _read_cache(
821824

822825
else:
823826
# read from the initial
824-
out = []
825-
out.append(self._fetch_block_cached(start_block_number)[start_pos:])
827+
out = [self._fetch_block_cached(start_block_number)[start_pos:]]
826828

827829
# intermediate blocks
828830
# Note: it'd be nice to combine these into one big request. However
829831
# that doesn't play nicely with our LRU cache.
830-
for block_number in range(start_block_number + 1, end_block_number):
831-
out.append(self._fetch_block_cached(block_number))
832+
out.extend(
833+
map(
834+
self._fetch_block_cached,
835+
range(start_block_number + 1, end_block_number),
836+
)
837+
)
832838

833839
# final block
834840
out.append(self._fetch_block_cached(end_block_number)[:end_pos])

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ ignore = [
7575
# Fix these codes later
7676
"G004",
7777
"PERF203",
78-
"PERF401",
7978
]
8079

8180
[tool.pytest.ini_options]

0 commit comments

Comments
 (0)