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
+3 -3
View File
@@ -177,9 +177,9 @@ class TestRemoveRelation(NewFile):
def test_run(self):
TestAddRelation().test_run()
assert BrickStore.graph
source, relation, destination = list(
BrickStore.graph.triples((None, URIRef("https://brickschema.org/schema/Brick#feeds"), None))
)[0]
source, relation, destination = next(
iter(BrickStore.graph.triples((None, URIRef("https://brickschema.org/schema/Brick#feeds"), None)))
)
subject.remove_relation(source, relation, destination)
assert not list(
BrickStore.graph.triples(
+2 -2
View File
@@ -55,7 +55,7 @@ class TestAddClassificationReferenceFromBSDD(NewFile):
bpy.ops.bim.add_classification_reference_from_bsdd(obj="IfcSpace/Cube", obj_type="Object")
refs = ifcopenshell.util.classification.get_references(element)
assert len(refs) == 1
assert list(refs)[0].Location.startswith(uri)
assert next(iter(refs)).Location.startswith(uri)
def test_add_classification_refence_with_props(self):
bpy.ops.bim.create_project()
@@ -92,7 +92,7 @@ class TestAddClassificationReferenceFromBSDD(NewFile):
assert pset and pset["Handicap Accessible"] == True
refs = ifcopenshell.util.classification.get_references(element)
assert len(refs) == 1
assert list(refs)[0].Location.startswith(uri)
assert next(iter(refs)).Location.startswith(uri)
def test_add_clasification_reference_with_object_type(self):
bpy.ops.bim.create_project()
+1 -1
View File
@@ -106,7 +106,7 @@ class TestGetManualBooleans(NewFile):
assert set(subject.get_booleans(element, representation)) == set(bools)
assert len(subject.get_manual_booleans(element, representation)) == 0
bool1 = list(bools)[0]
bool1 = bools[0]
subject.mark_manual_booleans(element, [bool1])
assert set(subject.get_manual_booleans(element, representation)) == {bool1}