Skip to content

Commit 7cde962

Browse files
committed
Fix Ruff UP034 (extraneous-parentheses)
https://docs.astral.sh/ruff/rules/extraneous-parentheses/
1 parent 5f5ba72 commit 7cde962

File tree

23 files changed

+45
-47
lines changed

23 files changed

+45
-47
lines changed

src/bcf/bcf/v2/bcfxml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def extensions(self) -> Optional[mdl_extensions.Extensions]:
100100
extensions = mdl_extensions.Extensions()
101101

102102
xs = "{http://www.w3.org/2001/XMLSchema}"
103-
root = etree.parse(io.BytesIO((self.extension_schema)))
103+
root = etree.parse(io.BytesIO(self.extension_schema))
104104

105105
attrs = bcf.agnostic.extensions.get_extensions_attributes(extensions)
106106
xsd_to_attrs = {v.subattr_xsd_name: k for k, v in attrs.items()}

src/bonsai/bonsai/bim/module/bcf/operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class AddBcfBimSnippet(bpy.types.Operator):
397397
def poll(cls, context):
398398
props = tool.Bcf.get_bcf_props()
399399
props_are_filled = all(
400-
(getattr(props, attr) for attr in ("bim_snippet_reference", "bim_snippet_schema", "bim_snippet_type"))
400+
getattr(props, attr) for attr in ("bim_snippet_reference", "bim_snippet_schema", "bim_snippet_type")
401401
)
402402
if not props_are_filled:
403403
cls.poll_message_set("Some BIM snippet fields are empty.")

src/bonsai/bonsai/bim/module/geometry/operator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ class GetRepresentationIfcParameters(bpy.types.Operator, tool.Ifc.Operator):
724724

725725
def _execute(self, context):
726726
obj = context.active_object
727-
assert obj and tool.Geometry.has_mesh_properties((data := obj.data))
727+
assert obj and tool.Geometry.has_mesh_properties(data := obj.data)
728728
core.get_representation_ifc_parameters(tool.Geometry, obj=obj)
729729
parameters = tool.Geometry.get_mesh_props(data).ifc_parameters
730730
self.report({"INFO"}, f"{len(parameters)} parameters found.")
@@ -1691,7 +1691,7 @@ def apply_placement(
16911691
if obj == self.target:
16921692
continue
16931693
if obj.type != self.target_type:
1694-
obj.select_set((False))
1694+
obj.select_set(False)
16951695
continue
16961696
element = tool.Ifc.get_entity(obj)
16971697

@@ -1752,7 +1752,7 @@ def validate_item(item: ifcopenshell.entity_instance) -> bool:
17521752
copied_item = ifcopenshell.util.element.copy_deep(
17531753
ifc_file, item, exclude=("IfcCartesianPointList",)
17541754
)
1755-
new_points = processed_point_lists.get((points := item.Points))
1755+
new_points = processed_point_lists.get(points := item.Points)
17561756
if new_points is None:
17571757
new_points = ifcopenshell.util.element.copy_deep(ifc_file, points)
17581758
dim = item.Dim
@@ -2365,7 +2365,7 @@ def add_tag(item, tag: str) -> None:
23652365
item.tags += ","
23662366
item.tags += tag
23672367

2368-
if tool.Geometry.has_mesh_properties((data := obj.data)):
2368+
if tool.Geometry.has_mesh_properties(data := obj.data):
23692369
representation = tool.Geometry.get_data_representation(data)
23702370
assert representation
23712371

src/bonsai/bonsai/bim/module/project/prop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def add_library_asset_class(self, name: str, asset_count: int) -> LibraryElement
435435
return new
436436

437437
def get_library_element_index(self, lib_element: LibraryElement) -> int:
438-
return next((i for i in range(len(self.library_elements)) if self.library_elements[i] == lib_element))
438+
return next(i for i in range(len(self.library_elements)) if self.library_elements[i] == lib_element)
439439

440440
if TYPE_CHECKING:
441441
is_editing: bool

src/bonsai/bonsai/bim/module/qto/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ def calculate_height(obj: bpy.types.Object) -> float:
2727

2828

2929
def calculate_edges_lengths(objs: list[bpy.types.Object], context: bpy.types.Context):
30-
return calculate_mesh_quantity(objs, context, lambda bm: sum((e.calc_length() for e in bm.edges if e.select)))
30+
return calculate_mesh_quantity(objs, context, lambda bm: sum(e.calc_length() for e in bm.edges if e.select))
3131

3232

3333
def calculate_faces_areas(objs: list[bpy.types.Object], context: bpy.types.Context) -> float:
34-
return calculate_mesh_quantity(objs, context, lambda bm: sum((f.calc_area() for f in bm.faces if f.select)))
34+
return calculate_mesh_quantity(objs, context, lambda bm: sum(f.calc_area() for f in bm.faces if f.select))
3535

3636

3737
def calculate_volumes(objs: list[bpy.types.Object], context: bpy.types.Context) -> float:

src/bonsai/bonsai/bim/module/structural/load_decoration_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,12 @@ def get_planar_loads_values(
398398
returns a numpy array with the sum of the values of structural activities
399399
applied loads in each direction, multiplied by the factors in load combinations
400400
"""
401-
values = np.zeros((3))
401+
values = np.zeros(3)
402402
for item in activity_list:
403403
activity = item[0]
404404
factor = item[1]
405405
load = activity.AppliedLoad
406-
temp = np.zeros((3))
406+
temp = np.zeros(3)
407407
if load is not None and load.is_a("IfcStructuralLoadPlanarForce"):
408408
temp[0] = load.PlanarForceX if load.PlanarForceX is not None else 0
409409
temp[1] = load.PlanarForceY if load.PlanarForceY is not None else 0

src/bonsai/bonsai/tool/cad.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ def angle_3_vectors(cls, v1, v2, v3, new_angle=None, degrees=False):
103103
d2 = v3 - v2
104104

105105
# Rounding avoids problems when dealing with 180 degrees
106-
d1 = Vector((round(c, 6) for c in d1))
107-
d2 = Vector((round(c, 6) for c in d2))
106+
d1 = Vector(round(c, 6) for c in d1)
107+
d2 = Vector(round(c, 6) for c in d2)
108108

109109
d1.normalize()
110110
d2.normalize()

src/bonsai/bonsai/tool/drawing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ def is_perpendicular(cls, a: bpy.types.Object, b: bpy.types.Object) -> bool:
17091709
a_quaternion = a.matrix_world.to_quaternion()
17101710
b_quaternion = b.matrix_world.to_quaternion()
17111711
for axis in axes:
1712-
if abs((a_quaternion @ axis).angle((b_quaternion @ axis)) - (math.pi / 2)) < 1e-5:
1712+
if abs((a_quaternion @ axis).angle(b_quaternion @ axis) - (math.pi / 2)) < 1e-5:
17131713
return True
17141714
return False
17151715

src/bonsai/bonsai/tool/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def set_object_origin_to_bottom(cls, obj: bpy.types.Object) -> None:
7373
assert isinstance(obj.data, bpy.types.Mesh)
7474
obj.data.transform(
7575
Matrix.Translation(
76-
(obj.matrix_world.inverted().to_quaternion() @ (obj.matrix_world.translation - new_origin))
76+
obj.matrix_world.inverted().to_quaternion() @ (obj.matrix_world.translation - new_origin)
7777
)
7878
)
7979
obj.matrix_world.translation = new_origin

src/bonsai/bonsai/tool/root.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def unlink_object(cls, obj: bpy.types.Object) -> None:
445445
to unlink them.
446446
"""
447447
tool.Ifc.unlink(obj=obj)
448-
if tool.Geometry.has_mesh_properties((data := obj.data)):
448+
if tool.Geometry.has_mesh_properties(data := obj.data):
449449
tool.Geometry.get_mesh_props(data).ifc_definition_id = 0
450450
for material_slot in obj.material_slots:
451451
if material := material_slot.material:

0 commit comments

Comments
 (0)