chore: ruff check - fix flake8-comprensions

This commit is contained in:
psychedelicious
2023-11-11 10:44:43 +11:00
parent 43f2398e14
commit 3a136420d5
60 changed files with 489 additions and 512 deletions

View File

@ -149,8 +149,8 @@ def test_graph_state_expands_iterator(mock_services):
invoke_next(g, mock_services)
prepared_add_nodes = g.source_prepared_mapping["3"]
results = set([g.results[n].value for n in prepared_add_nodes])
expected = set([1, 11, 21])
results = {g.results[n].value for n in prepared_add_nodes}
expected = {1, 11, 21}
assert results == expected
@ -229,7 +229,7 @@ def test_graph_executes_depth_first(mock_services):
# Because ordering is not guaranteed, we cannot compare results directly.
# Instead, we must count the number of results.
def get_completed_count(g, id):
ids = [i for i in g.source_prepared_mapping[id]]
ids = list(g.source_prepared_mapping[id])
completed_ids = [i for i in g.executed if i in ids]
return len(completed_ids)

View File

@ -503,8 +503,8 @@ def test_graph_expands_subgraph():
g.add_edge(create_edge("1.2", "value", "2", "a"))
dg = g.nx_graph_flat()
assert set(dg.nodes) == set(["1.1", "1.2", "2"])
assert set(dg.edges) == set([("1.1", "1.2"), ("1.2", "2")])
assert set(dg.nodes) == {"1.1", "1.2", "2"}
assert set(dg.edges) == {("1.1", "1.2"), ("1.2", "2")}
def test_graph_subgraph_t2i():
@ -532,9 +532,7 @@ def test_graph_subgraph_t2i():
# Validate
dg = g.nx_graph_flat()
assert set(dg.nodes) == set(
["1.width", "1.height", "1.seed", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "2", "3", "4"]
)
assert set(dg.nodes) == {"1.width", "1.height", "1.seed", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "2", "3", "4"}
expected_edges = [(f"1.{e.source.node_id}", f"1.{e.destination.node_id}") for e in lg.graph.edges]
expected_edges.extend([("2", "1.width"), ("3", "1.height"), ("1.8", "4")])
print(expected_edges)

View File

@ -130,7 +130,7 @@ class TestEventService(EventServiceBase):
def __init__(self):
super().__init__()
self.events = list()
self.events = []
def dispatch(self, event_name: str, payload: Any) -> None:
pass