Apply ruff flake8-comprehensions (#21694)
This commit is contained in:
@@ -78,13 +78,11 @@ def get_all_tests():
|
||||
|
||||
# test folders/files directly under `tests` folder
|
||||
tests = os.listdir(test_root_dir)
|
||||
tests = sorted(
|
||||
list(filter(lambda x: os.path.isdir(x) or x.startswith("tests/test_"), [f"tests/{x}" for x in tests]))
|
||||
)
|
||||
tests = sorted(filter(lambda x: os.path.isdir(x) or x.startswith("tests/test_"), [f"tests/{x}" for x in tests]))
|
||||
|
||||
# model specific test folders
|
||||
model_tests_folders = os.listdir(os.path.join(test_root_dir, "models"))
|
||||
model_test_folders = sorted(list(filter(os.path.isdir, [f"tests/models/{x}" for x in model_tests_folders])))
|
||||
model_test_folders = sorted(filter(os.path.isdir, [f"tests/models/{x}" for x in model_tests_folders]))
|
||||
|
||||
tests.remove("tests/models")
|
||||
tests = model_test_folders + tests
|
||||
@@ -265,7 +263,7 @@ def get_tree_starting_at(module, edges):
|
||||
tree = [module]
|
||||
while len(new_edges) > 0:
|
||||
tree.append(new_edges)
|
||||
final_vertices = list(set(edge[1] for edge in new_edges))
|
||||
final_vertices = list({edge[1] for edge in new_edges})
|
||||
vertices_seen.extend(final_vertices)
|
||||
new_edges = [edge for edge in edges if edge[0] in final_vertices and edge[1] not in vertices_seen]
|
||||
|
||||
@@ -285,10 +283,10 @@ def print_tree_deps_of(module, all_edges=None):
|
||||
lines = [(tree[0], tree[0])]
|
||||
for index in range(1, len(tree)):
|
||||
edges = tree[index]
|
||||
start_edges = set([edge[0] for edge in edges])
|
||||
start_edges = {edge[0] for edge in edges}
|
||||
|
||||
for start in start_edges:
|
||||
end_edges = set([edge[1] for edge in edges if edge[0] == start])
|
||||
end_edges = {edge[1] for edge in edges if edge[0] == start}
|
||||
# We will insert all those edges just after the line showing start.
|
||||
pos = 0
|
||||
while lines[pos][1] != start:
|
||||
@@ -547,7 +545,7 @@ def infer_tests_to_run(output_file, diff_with_last_commit=False, filters=None, j
|
||||
impacted_files.extend(impacted_modules_map[f])
|
||||
|
||||
# Remove duplicates
|
||||
impacted_files = sorted(list(set(impacted_files)))
|
||||
impacted_files = sorted(set(impacted_files))
|
||||
print(f"\n### IMPACTED FILES ###\n{_print_list(impacted_files)}")
|
||||
|
||||
# Grab the corresponding test files:
|
||||
@@ -578,7 +576,7 @@ def infer_tests_to_run(output_file, diff_with_last_commit=False, filters=None, j
|
||||
test_files_to_run.extend(new_tests)
|
||||
|
||||
# Remove duplicates
|
||||
test_files_to_run = sorted(list(set(test_files_to_run)))
|
||||
test_files_to_run = sorted(set(test_files_to_run))
|
||||
# Make sure we did not end up with a test file that was removed
|
||||
test_files_to_run = [f for f in test_files_to_run if os.path.isfile(f) or os.path.isdir(f)]
|
||||
if filters is not None:
|
||||
|
||||
Reference in New Issue
Block a user