Skip to content

Commit 057e6f6

Browse files
R1728: Redundant list comprehension can be replaced using generator
Removing [] inside calls that can use containers or generators should be considered for performance reasons since a generator will have an upfront cost to pay. The performance will be better if you are working with long lists or sets.
1 parent 64b9a37 commit 057e6f6

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

tests/test_group.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,12 +1627,10 @@ async def test_create_hierarchy_existing_nodes(
16271627
elif impl == "async":
16281628
with pytest.raises(err_cls, match=re.escape(msg)):
16291629
tuple(
1630-
[
1631-
x
1632-
async for x in create_hierarchy(
1633-
store=store, nodes={"node": new_metadata}, overwrite=False
1634-
)
1635-
]
1630+
x
1631+
async for x in create_hierarchy(
1632+
store=store, nodes={"node": new_metadata}, overwrite=False
1633+
)
16361634
)
16371635
else:
16381636
raise ValueError(f"Invalid impl: {impl}")

tests/test_store/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def test_valid() -> None:
195195
Test that path normalization works as expected
196196
"""
197197
paths = ["a", "b", "c", "d", "", "//a///b//"]
198-
assert _normalize_paths(paths) == tuple([normalize_path(p) for p in paths])
198+
assert _normalize_paths(paths) == tuple(normalize_path(p) for p in paths)
199199

200200
@staticmethod
201201
@pytest.mark.parametrize("paths", [("", "/"), ("///a", "a")])

0 commit comments

Comments
 (0)