mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Fix Ruff UP034 (extraneous-parentheses)
https://docs.astral.sh/ruff/rules/extraneous-parentheses/
This commit is contained in:
@@ -1134,7 +1134,7 @@ def the_object_name_should_display_as_mode(name, mode):
|
||||
def the_object_name_is_voided_by_void(name, void):
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(tool.Blender.get_ifc_definition_id(the_object_name_exists(name)))
|
||||
assert any((rel for rel in element.HasOpenings if rel.RelatedOpeningElement.Name == void)), "No void found"
|
||||
assert any(rel for rel in element.HasOpenings if rel.RelatedOpeningElement.Name == void), "No void found"
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" is not voided by "{void}"'))
|
||||
@@ -1158,7 +1158,7 @@ def the_object_name_is_a_void(name):
|
||||
ifc = tool.Ifc.get()
|
||||
obj = the_object_name_exists(name)
|
||||
element = ifc.by_id(tool.Blender.get_ifc_definition_id(obj))
|
||||
assert any((element.VoidsElements)), "No void was found"
|
||||
assert any(element.VoidsElements), "No void was found"
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" is not a void'))
|
||||
@@ -1282,7 +1282,7 @@ def the_object_name_is_filled_by_filling(name, name2):
|
||||
def the_void_name_is_filled_by_filling(name, filling):
|
||||
ifc = tool.Ifc.get()
|
||||
element = ifc.by_id(tool.Blender.get_ifc_definition_id(the_object_name_exists(name)))
|
||||
assert any((rel.RelatedBuildingElement.Name == filling for rel in element.HasFillings)), "No filling found"
|
||||
assert any(rel.RelatedBuildingElement.Name == filling for rel in element.HasFillings), "No filling found"
|
||||
|
||||
|
||||
@then(parsers.parse('the void "{name}" is not filled by "{filling}"'))
|
||||
@@ -1468,7 +1468,7 @@ def the_object_name_has_a_vertex_at_location(name, location):
|
||||
target = Vector([float(co) for co in location.split(",")])
|
||||
verts = []
|
||||
for v in obj.data.vertices:
|
||||
verts.append((obj.matrix_world @ v.co))
|
||||
verts.append(obj.matrix_world @ v.co)
|
||||
if (verts[-1] - target).length < 0.001:
|
||||
is_pass = True
|
||||
assert is_pass, f"No verts found at {location}: {verts}"
|
||||
|
||||
@@ -71,7 +71,7 @@ class TestCreatingStyles(NewFile):
|
||||
subject.create_surface_style_with_textures(material, style_data, texture_data)
|
||||
|
||||
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
||||
assert used_node_types == set((["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"]))
|
||||
assert used_node_types == set(["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"])
|
||||
|
||||
bsdf = tool.Blender.get_material_node(material, "BSDF_PRINCIPLED")
|
||||
alpha = 1 - style_data["Transparency"]
|
||||
@@ -137,7 +137,7 @@ class TestCreatingStyles(NewFile):
|
||||
subject.create_surface_style_with_textures(material, rendering_style, texture_style)
|
||||
|
||||
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
||||
assert used_node_types == set((["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"]))
|
||||
assert used_node_types == set(["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"])
|
||||
|
||||
color_to_tuple = lambda x: (x.Red, x.Green, x.Blue)
|
||||
bsdf = tool.Blender.get_material_node(material, "BSDF_PRINCIPLED")
|
||||
@@ -250,7 +250,7 @@ class TestCreatingStyles(NewFile):
|
||||
subject.create_surface_style_with_textures(material, rendering_style, texture_style)
|
||||
|
||||
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
||||
assert used_node_types == set((["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"]))
|
||||
assert used_node_types == set(["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"])
|
||||
|
||||
image_node = tool.Blender.get_material_node(material, "TEX_IMAGE")
|
||||
assert image_node.outputs["Color"].links[0].to_socket.name == "Base Color"
|
||||
@@ -385,7 +385,7 @@ class TestCreatingStyles(NewFile):
|
||||
subject.create_surface_style_with_textures(material, rendering_style, texture_style)
|
||||
|
||||
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
||||
assert used_node_types == set((["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"]))
|
||||
assert used_node_types == set(["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"])
|
||||
|
||||
image_node = tool.Blender.get_material_node(material, "TEX_IMAGE")
|
||||
assert image_node.outputs["Color"].links[0].to_socket.name == "Base Color"
|
||||
|
||||
@@ -489,14 +489,14 @@ class TestApplyIfcMaterialChanges(NewFile):
|
||||
sprops = tool.Style.get_style_props()
|
||||
sprops.style_name = "Red"
|
||||
bpy.ops.bim.add_presentation_style()
|
||||
red_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Red"))
|
||||
red_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Red")
|
||||
ifcopenshell.api.style.assign_material_style(ifc_file, red_material, red_style, context)
|
||||
|
||||
blue_material = ifcopenshell.api.material.add_material(ifc_file, "Blue Material")
|
||||
bpy.ops.bim.enable_adding_presentation_style()
|
||||
sprops.style_name = "Blue"
|
||||
bpy.ops.bim.add_presentation_style()
|
||||
blue_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Blue"))
|
||||
blue_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Blue")
|
||||
ifcopenshell.api.style.assign_material_style(ifc_file, blue_material, blue_style, context)
|
||||
|
||||
bpy.ops.bim.enable_adding_presentation_style()
|
||||
@@ -508,7 +508,7 @@ class TestApplyIfcMaterialChanges(NewFile):
|
||||
|
||||
def setup_elements(self) -> None:
|
||||
ifc_file = tool.Ifc.get()
|
||||
blue_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Blue Material"))
|
||||
blue_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Blue Material")
|
||||
blue_style = tool.Material.get_style(blue_material)
|
||||
|
||||
# Element type.
|
||||
@@ -552,9 +552,9 @@ class TestApplyIfcMaterialChanges(NewFile):
|
||||
self.setup_test()
|
||||
ifc_file = tool.Ifc.get()
|
||||
element_type = next(ifc_file.by_type("IfcActuatorType").__iter__())
|
||||
red_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material"))
|
||||
red_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material")
|
||||
red_style = tool.Material.get_style(red_material)
|
||||
blue_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Blue"))
|
||||
blue_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Blue")
|
||||
|
||||
ifcopenshell.api.material.assign_material(ifc_file, material=red_material, products=[element_type])
|
||||
tool.Material.ensure_material_assigned([element_type], material=red_material)
|
||||
@@ -576,8 +576,8 @@ class TestApplyIfcMaterialChanges(NewFile):
|
||||
self.setup_test()
|
||||
ifc_file = tool.Ifc.get()
|
||||
element_type = next(ifc_file.by_type("IfcActuatorType").__iter__())
|
||||
red_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material"))
|
||||
green_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Green"))
|
||||
red_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material")
|
||||
green_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Green")
|
||||
|
||||
# Occurrence with a style.
|
||||
element_type_obj = tool.Ifc.get_object(element_type)
|
||||
@@ -601,9 +601,9 @@ class TestApplyIfcMaterialChanges(NewFile):
|
||||
def test_assign_material_to_representation_that_has_2_items_and_1_item_has_a_style(self):
|
||||
self.setup_test(and_elements=False)
|
||||
ifc_file = tool.Ifc.get()
|
||||
red_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material"))
|
||||
red_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material")
|
||||
red_style = tool.Material.get_style(red_material)
|
||||
green_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Green"))
|
||||
green_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Green")
|
||||
|
||||
bpy.ops.mesh.primitive_cube_add(size=10, location=(0, 0, 4))
|
||||
obj = bpy.data.objects["Cube"]
|
||||
@@ -664,7 +664,7 @@ class TestApplyIfcMaterialChanges(NewFile):
|
||||
self.setup_test(and_elements=True)
|
||||
ifc_file = tool.Ifc.get()
|
||||
element_type = next(ifc_file.by_type("IfcActuatorType").__iter__())
|
||||
red_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material"))
|
||||
red_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material")
|
||||
no_style_material = ifcopenshell.api.material.add_material(ifc_file, "No Style")
|
||||
obj = bpy.data.objects["Simple"]
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
|
||||
Reference in New Issue
Block a user