Skip to content

Commit 03894d9

Browse files
Apply ruff/Perflint rule PERF401
PERF401 Use an async list comprehension to create a transformed list
1 parent 7a6a923 commit 03894d9

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

tests/v3/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def xp(request: pytest.FixtureRequest) -> Iterator[ModuleType]:
105105
if request.param == "cupy":
106106
request.node.add_marker(pytest.mark.gpu)
107107

108-
yield pytest.importorskip(request.param)
108+
return pytest.importorskip(request.param)
109109

110110

111111
@pytest.fixture(autouse=True)

tests/v3/test_indexing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
@pytest.fixture
3838
async def store() -> AsyncGenerator[StorePath]:
39-
yield StorePath(await MemoryStore.open(mode="w"))
39+
return StorePath(await MemoryStore.open(mode="w"))
4040

4141

4242
def zarr_array_from_numpy_array(
@@ -1782,9 +1782,9 @@ async def test_accessed_chunks(
17821782

17831783
# Combine and generate the cartesian product to determine the chunks keys that
17841784
# will be accessed
1785-
chunks_accessed = []
1786-
for comb in itertools.product(*chunks_per_dim):
1787-
chunks_accessed.append(".".join([str(ci) for ci in comb]))
1785+
chunks_accessed = [
1786+
".".join([str(ci) for ci in comb]) for comb in itertools.product(*chunks_per_dim)
1787+
]
17881788

17891789
counts_before = store.counter.copy()
17901790

tests/v3/test_store/test_remote.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ def s3(s3_base: None) -> Generator[s3fs.S3FileSystem, None, None]:
8686

8787

8888
async def alist(it):
89-
out = []
90-
async for a in it:
91-
out.append(a)
92-
return out
89+
return [a async for a in it]
9390

9491

9592
async def test_basic() -> None:

tests/v3/test_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
@pytest.fixture
1111
async def store() -> Iterator[StorePath]:
12-
yield StorePath(await MemoryStore.open(mode="w"))
12+
return StorePath(await MemoryStore.open(mode="w"))
1313

1414

1515
def test_simple(store: StorePath) -> None:

0 commit comments

Comments
 (0)