Fix RUF015 (next() instead of list comprehensions[0])

https://docs.astral.sh/ruff/rules/-iterable-allocation-for-first-element/
This commit is contained in:
Andrej730
2025-06-16 12:29:41 +05:00
parent b486b32c8d
commit a12bb343ca
29 changed files with 64 additions and 61 deletions
@@ -55,7 +55,7 @@ class COMMANDFILE:
conn["relatedElements"] = []
for el in elements:
for rel in el["connections"]:
conn = [c for c in connections if c["referenceName"] == rel["relatedConnection"]][0]
conn = next(c for c in connections if c["referenceName"] == rel["relatedConnection"])
conn["relatedElements"].append(rel)
# End <--
+1 -1
View File
@@ -192,7 +192,7 @@ class MODEL:
el["linkObjs"] = [None for _ in el["connections"]]
for j, rel in enumerate(el["connections"]):
conn = [c for c in connections if c["referenceName"] == rel["relatedConnection"]][0]
conn = next(c for c in connections if c["referenceName"] == rel["relatedConnection"])
if rel["eccentricity"]:
rel["index"] = len(conn["relatedElements"]) + 1
+1 -1
View File
@@ -164,7 +164,7 @@ class CommandFileConstructor:
self.calculateRestraints(conn)
for el in elements:
for rel in el["connections"]:
conn = [c for c in connections if c["ref_id"] == rel["related_connection"]][0]
conn = next(c for c in connections if c["ref_id"] == rel["related_connection"])
rel["conn_string"] = None
if conn["geometry_type"] == "Vertex":
rel["conn_string"] = "_0DC_"