Skip to content

Commit 4256c5d

Browse files
R1717: Consider using a dictionary comprehension
Emitted when we detect the creation of a dictionary using the dict() callable and a transient list. Although there is nothing syntactically wrong with this code, it is hard to read and can be simplified to a dict comprehension. Also it is faster since you don't need to create another transient list.
1 parent 057e6f6 commit 4256c5d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

tests/test_group.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,14 +1567,12 @@ async def test_create_hierarchy(
15671567
sync_group.create_hierarchy(store=store, nodes=hierarchy_spec, overwrite=overwrite)
15681568
)
15691569
elif impl == "async":
1570-
created = dict(
1571-
[
1572-
a
1573-
async for a in create_hierarchy(
1574-
store=store, nodes=hierarchy_spec, overwrite=overwrite
1575-
)
1576-
]
1577-
)
1570+
created = {
1571+
k: v
1572+
async for k, v in create_hierarchy(
1573+
store=store, nodes=hierarchy_spec, overwrite=overwrite
1574+
)
1575+
}
15781576
else:
15791577
raise ValueError(f"Invalid impl: {impl}")
15801578
if not overwrite:

0 commit comments

Comments
 (0)