From be66d4884d0c3b352eaf50e2bde224342cbb300b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 15 Sep 2025 09:52:30 +0500 Subject: [PATCH] typing --- src/bonsai/bonsai/bim/module/geometry/data.py | 2 +- src/bonsai/bonsai/bim/module/group/operator.py | 4 ++-- src/bonsai/bonsai/bim/module/group/ui.py | 1 + src/bonsai/bonsai/bim/module/project/ui.py | 1 + src/bonsai/bonsai/tool/system.py | 1 - src/bonsai/test/tool/test_root.py | 1 + .../ifcopenshell/api/alignment/_add_segment_to_curve.py | 2 ++ .../ifcopenshell/api/alignment/_add_segment_to_layout.py | 1 + .../api/alignment/_add_zero_length_segment.py | 2 ++ .../api/alignment/_map_alignment_horizontal_segment.py | 2 ++ .../ifcopenshell/api/alignment/add_stationing_referent.py | 1 + .../ifcopenshell/api/alignment/add_zero_length_segment.py | 2 ++ .../alignment/layout_horizontal_alignment_by_pi_method.py | 3 +++ .../ifcopenshell/ifcopenshell_wrapper.pyi | 3 ++- .../test/api/alignment/test_create_as_offset_curve.py | 2 ++ .../alignment/test_map_alignment_horizontal_segment.py | 1 + .../test/api/alignment/test_update_fallback_position.py | 2 ++ src/ifcopenshell-python/test/typing_tests.py | 3 ++- src/ifcopenshell-python/test/util/test_shape_builder.py | 3 +++ .../ifcpatch/recipes/ResetSpatialElementLocations.py | 5 +++++ src/ifcpatch/test/test_ResetSpatialElementLocations.py | 4 +++- src/ifcpatch/test/test_SetFalseOrigin.py | 8 +++++++- src/ifctester/webapp/public/worker/api.py | 1 + 23 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/geometry/data.py b/src/bonsai/bonsai/bim/module/geometry/data.py index 724b36eb64..2e7d6c4205 100644 --- a/src/bonsai/bonsai/bim/module/geometry/data.py +++ b/src/bonsai/bonsai/bim/module/geometry/data.py @@ -20,7 +20,7 @@ import bpy import ifcopenshell.util.element import ifcopenshell.util.geolocation import ifcopenshell.util.placement -import ifcopenshell.util.schema +import ifcopenshell.util.representation import ifcopenshell.util.unit import bonsai.tool as tool from typing import Any, Union diff --git a/src/bonsai/bonsai/bim/module/group/operator.py b/src/bonsai/bonsai/bim/module/group/operator.py index 2aec8e9201..d742323ee0 100644 --- a/src/bonsai/bonsai/bim/module/group/operator.py +++ b/src/bonsai/bonsai/bim/module/group/operator.py @@ -213,9 +213,9 @@ class UnassignGroup(bpy.types.Operator, tool.Ifc.Operator): def _execute(self, context): products = [ - tool.Ifc.get_entity(o) + element for o in tool.Blender.get_selected_objects(include_active=False) - if tool.Ifc.get_entity(o) + if (element := tool.Ifc.get_entity(o)) ] if not products: return diff --git a/src/bonsai/bonsai/bim/module/group/ui.py b/src/bonsai/bonsai/bim/module/group/ui.py index 74c4dc01cd..926fe76da5 100644 --- a/src/bonsai/bonsai/bim/module/group/ui.py +++ b/src/bonsai/bonsai/bim/module/group/ui.py @@ -45,6 +45,7 @@ class BIM_PT_groups(Panel): if not GroupsData.is_loaded: GroupsData.load() self.props = tool.Blender.get_group_props() + assert self.layout row = self.layout.row(align=True) row.label(text=f"{GroupsData.data['total_groups']} Groups Found", icon="OUTLINER") diff --git a/src/bonsai/bonsai/bim/module/project/ui.py b/src/bonsai/bonsai/bim/module/project/ui.py index 1177f1ff8b..def94cf0f2 100644 --- a/src/bonsai/bonsai/bim/module/project/ui.py +++ b/src/bonsai/bonsai/bim/module/project/ui.py @@ -259,6 +259,7 @@ class BIM_PT_project(Panel): def draw_editable_file_info(self, context): pprops = self.props + assert self.layout if ifc_file := tool.Ifc.get(): row = self.layout.row(align=True) diff --git a/src/bonsai/bonsai/tool/system.py b/src/bonsai/bonsai/tool/system.py index 277c61f44b..41ad127663 100644 --- a/src/bonsai/bonsai/tool/system.py +++ b/src/bonsai/bonsai/tool/system.py @@ -29,7 +29,6 @@ import bonsai.core.tool import bonsai.tool as tool from bonsai.bim import import_ifc import re -from math import pi, cos, sin from mathutils import Matrix, Vector from bonsai.bim.module.system.data import ObjectSystemData, SystemDecorationData from enum import Enum diff --git a/src/bonsai/test/tool/test_root.py b/src/bonsai/test/tool/test_root.py index 6928083c8d..b27b556a03 100644 --- a/src/bonsai/test/tool/test_root.py +++ b/src/bonsai/test/tool/test_root.py @@ -21,6 +21,7 @@ import ifcopenshell import ifcopenshell.api import ifcopenshell.api.feature import ifcopenshell.api.type +import ifcopenshell.util.element import bonsai.core.tool import bonsai.tool as tool from test.bim.bootstrap import NewFile diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_curve.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_curve.py index 2c305079f3..4fcadc176e 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_curve.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_curve.py @@ -17,6 +17,8 @@ # along with IfcOpenShell. If not, see . import ifcopenshell +import ifcopenshell.api +import ifcopenshell.api.alignment import ifcopenshell.geom import ifcopenshell.util.unit import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py index 05a01e8ee2..bb31342efb 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py @@ -19,6 +19,7 @@ import ifcopenshell import ifcopenshell.api.alignment import ifcopenshell.api.nest +import ifcopenshell.api.pset import ifcopenshell.geom import ifcopenshell.util.alignment import ifcopenshell.util.unit diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_zero_length_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_zero_length_segment.py index 1219e35762..17be8ec45c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_zero_length_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_zero_length_segment.py @@ -18,6 +18,8 @@ import ifcopenshell import ifcopenshell.api.alignment +import ifcopenshell.util +import ifcopenshell.util.alignment from ifcopenshell import entity_instance from ifcopenshell.api.alignment._get_segment_start_point_label import _get_segment_start_point_label diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_horizontal_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_horizontal_segment.py index 3e7cd26f3c..73802f2318 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_horizontal_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_horizontal_segment.py @@ -19,6 +19,8 @@ import ifcopenshell from ifcopenshell import entity_instance import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper +import ifcopenshell.util +import ifcopenshell.util.unit from collections.abc import Sequence import math diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_stationing_referent.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_stationing_referent.py index 1534ad9d5d..2ac08a2fbf 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_stationing_referent.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_stationing_referent.py @@ -22,6 +22,7 @@ import ifcopenshell.api.nest import ifcopenshell.api.pset import ifcopenshell.geom import ifcopenshell.guid +import ifcopenshell.util.element import ifcopenshell.util.unit from ifcopenshell import entity_instance from ifcopenshell import ifcopenshell_wrapper diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py index fc2fcb2c0e..5b36cddd75 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py @@ -19,9 +19,11 @@ import ifcopenshell import ifcopenshell.api.alignment import ifcopenshell.api.nest +import ifcopenshell.geom import ifcopenshell.util.alignment from ifcopenshell import entity_instance import ifcopenshell.ifcopenshell_wrapper as wrapper +import ifcopenshell.util.unit import numpy as np import math diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/layout_horizontal_alignment_by_pi_method.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/layout_horizontal_alignment_by_pi_method.py index 3e0ec40b67..3409fd761b 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/layout_horizontal_alignment_by_pi_method.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/layout_horizontal_alignment_by_pi_method.py @@ -23,6 +23,9 @@ from ifcopenshell import entity_instance import math from collections.abc import Sequence +import ifcopenshell.util +import ifcopenshell.util.unit + def layout_horizontal_alignment_by_pi_method( file: ifcopenshell.file, layout: entity_instance, hpoints: Sequence[Sequence[float]], radii: Sequence[float] diff --git a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi index 659a062cfd..52aef6ac6c 100644 --- a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi +++ b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi @@ -17,7 +17,8 @@ # along with IfcOpenShell. If not, see . import ifcopenshell -from typing import Any, Union, Literal, Self +from typing import Any, Union, Literal +from typing_extensions import Self # `std::vector` usually translated to `tuple[xxx, ...]`. diff --git a/src/ifcopenshell-python/test/api/alignment/test_create_as_offset_curve.py b/src/ifcopenshell-python/test/api/alignment/test_create_as_offset_curve.py index 279b96c4e7..25b2656611 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_create_as_offset_curve.py +++ b/src/ifcopenshell-python/test/api/alignment/test_create_as_offset_curve.py @@ -16,6 +16,8 @@ # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell.util +import ifcopenshell.util.unit import pytest import math import ifcopenshell.api.alignment diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py index 8eee09ae0d..c9bdfc0432 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py @@ -21,6 +21,7 @@ import pytest import ifcopenshell.api.alignment +import ifcopenshell.api.unit from ifcopenshell.api.alignment._map_alignment_horizontal_segment import _map_alignment_horizontal_segment diff --git a/src/ifcopenshell-python/test/api/alignment/test_update_fallback_position.py b/src/ifcopenshell-python/test/api/alignment/test_update_fallback_position.py index a69a86ad26..2982cb466b 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_update_fallback_position.py +++ b/src/ifcopenshell-python/test/api/alignment/test_update_fallback_position.py @@ -18,6 +18,8 @@ import pytest import ifcopenshell.api.alignment +import ifcopenshell.api.context +import ifcopenshell.api.unit def test_update_fallback_position(): diff --git a/src/ifcopenshell-python/test/typing_tests.py b/src/ifcopenshell-python/test/typing_tests.py index 5e2a14fd39..c535960348 100644 --- a/src/ifcopenshell-python/test/typing_tests.py +++ b/src/ifcopenshell-python/test/typing_tests.py @@ -23,7 +23,8 @@ Those tests are not automatically checked and just there to make sure overloads import ifcopenshell -from typing import assert_type, Union +from typing import Union +from typing_extensions import assert_type def ifcopenshell_open_test(str_: str, bool_: bool): diff --git a/src/ifcopenshell-python/test/util/test_shape_builder.py b/src/ifcopenshell-python/test/util/test_shape_builder.py index 4a573d454a..a46c014fa7 100644 --- a/src/ifcopenshell-python/test/util/test_shape_builder.py +++ b/src/ifcopenshell-python/test/util/test_shape_builder.py @@ -16,6 +16,9 @@ # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell.geom +import ifcopenshell.util +import ifcopenshell.util.shape import pytest import test.bootstrap import ifcopenshell.api diff --git a/src/ifcpatch/ifcpatch/recipes/ResetSpatialElementLocations.py b/src/ifcpatch/ifcpatch/recipes/ResetSpatialElementLocations.py index abaae30b19..fca2a5ee11 100644 --- a/src/ifcpatch/ifcpatch/recipes/ResetSpatialElementLocations.py +++ b/src/ifcpatch/ifcpatch/recipes/ResetSpatialElementLocations.py @@ -18,6 +18,11 @@ import ifcopenshell import logging +import ifcopenshell.api +import ifcopenshell.api.geometry +import ifcopenshell.util +import ifcopenshell.util.element +import ifcopenshell.util.placement import numpy as np diff --git a/src/ifcpatch/test/test_ResetSpatialElementLocations.py b/src/ifcpatch/test/test_ResetSpatialElementLocations.py index 5514357090..1ae7c63c6f 100644 --- a/src/ifcpatch/test/test_ResetSpatialElementLocations.py +++ b/src/ifcpatch/test/test_ResetSpatialElementLocations.py @@ -18,9 +18,11 @@ import test.bootstrap import ifcopenshell.api +import ifcopenshell.api.aggregate +import ifcopenshell.api.geometry import ifcopenshell.api.root import ifcopenshell.api.unit -import ifcopenshell.util.unit +import ifcopenshell.util.placement import ifcpatch import numpy as np diff --git a/src/ifcpatch/test/test_SetFalseOrigin.py b/src/ifcpatch/test/test_SetFalseOrigin.py index 337f82a43e..da4e621f04 100644 --- a/src/ifcpatch/test/test_SetFalseOrigin.py +++ b/src/ifcpatch/test/test_SetFalseOrigin.py @@ -18,9 +18,15 @@ import test.bootstrap import ifcopenshell.api +import ifcopenshell.api.aggregate +import ifcopenshell.api.context +import ifcopenshell.api.geometry import ifcopenshell.api.root +import ifcopenshell.api.spatial import ifcopenshell.api.unit -import ifcopenshell.util.unit +import ifcopenshell.util.element +import ifcopenshell.util.geolocation +import ifcopenshell.util.placement import ifcpatch import numpy as np diff --git a/src/ifctester/webapp/public/worker/api.py b/src/ifctester/webapp/public/worker/api.py index 20791f162e..d5b77d846d 100644 --- a/src/ifctester/webapp/public/worker/api.py +++ b/src/ifctester/webapp/public/worker/api.py @@ -1,5 +1,6 @@ import ifcopenshell import ifcopenshell.util +import ifcopenshell.util.attribute import ifcopenshell.util.pset import ifcopenshell.util.schema import xml.etree.ElementTree as ET