From 1d87d49f7ab4aa0b48929dbb4fc13ebd45cf46c9 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 6 May 2025 22:19:25 +0200 Subject: [PATCH 1/2] Replace redundant list comprehension with generator --- tests/test_group.py | 10 ++++------ tests/test_store/test_core.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/test_group.py b/tests/test_group.py index b4dace2568..20f87a8307 100644 --- a/tests/test_group.py +++ b/tests/test_group.py @@ -1641,12 +1641,10 @@ async def test_create_hierarchy_existing_nodes( elif impl == "async": with pytest.raises(err_cls, match=re.escape(msg)): tuple( - [ - x - async for x in create_hierarchy( - store=store, nodes={"node": new_metadata}, overwrite=False - ) - ] + x + async for x in create_hierarchy( + store=store, nodes={"node": new_metadata}, overwrite=False + ) ) else: raise ValueError(f"Invalid impl: {impl}") diff --git a/tests/test_store/test_core.py b/tests/test_store/test_core.py index 87d0e6e40d..ca350c9236 100644 --- a/tests/test_store/test_core.py +++ b/tests/test_store/test_core.py @@ -197,7 +197,7 @@ def test_valid() -> None: Test that path normalization works as expected """ paths = ["a", "b", "c", "d", "", "//a///b//"] - assert _normalize_paths(paths) == tuple([normalize_path(p) for p in paths]) + assert _normalize_paths(paths) == tuple(normalize_path(p) for p in paths) @staticmethod @pytest.mark.parametrize("paths", [("", "/"), ("///a", "a")]) From 9341f6e3c83a37088727bb07b26119b170ad073b Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Thu, 8 May 2025 14:10:17 +0200 Subject: [PATCH 2/2] Partially revert There is no such thing as a "tuple comprehension": https://stackoverflow.com/questions/52285419/aggregating-an-async-generator-to-a-tuple#52285420 Fixes CI error: FAILED tests/test_group.py::test_create_hierarchy_existing_nodes[zarr2-async-array-memory] - TypeError: 'async_generator' object is not iterable --- tests/test_group.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_group.py b/tests/test_group.py index 20f87a8307..b4dace2568 100644 --- a/tests/test_group.py +++ b/tests/test_group.py @@ -1641,10 +1641,12 @@ async def test_create_hierarchy_existing_nodes( elif impl == "async": with pytest.raises(err_cls, match=re.escape(msg)): tuple( - x - async for x in create_hierarchy( - store=store, nodes={"node": new_metadata}, overwrite=False - ) + [ + x + async for x in create_hierarchy( + store=store, nodes={"node": new_metadata}, overwrite=False + ) + ] ) else: raise ValueError(f"Invalid impl: {impl}")