diff --git a/src/blenderbim/blenderbim/bim/helper.py b/src/blenderbim/blenderbim/bim/helper.py index e42b94013a..937859dea0 100644 --- a/src/blenderbim/blenderbim/bim/helper.py +++ b/src/blenderbim/blenderbim/bim/helper.py @@ -29,6 +29,7 @@ from mathutils import geometry from mathutils import Vector import blenderbim.tool as tool from blenderbim.bim.ifc import IfcStore +from typing import Optional, Callable, Any def draw_attributes(props, layout, copy_operator=None, popup_active_attribute=None): @@ -182,7 +183,7 @@ def add_attribute_description(attribute_blender, attribute_ifc=None): attribute_blender.description = description -def export_attributes(props, callback=None): +def export_attributes(props, callback: Optional[Callable] = None) -> dict[str, Any]: attributes = {} for prop in props: is_handled_by_callback = callback(attributes, prop) if callback else False diff --git a/src/blenderbim/blenderbim/tool/drawing.py b/src/blenderbim/blenderbim/tool/drawing.py index 2b776b1423..69a6815bc4 100644 --- a/src/blenderbim/blenderbim/tool/drawing.py +++ b/src/blenderbim/blenderbim/tool/drawing.py @@ -51,7 +51,7 @@ from blenderbim.bim.module.drawing.prop import get_diagram_scales, BOX_ALIGNMENT from lxml import etree from mathutils import Vector, Matrix from fractions import Fraction -from typing import Optional, Union, Iterable +from typing import Optional, Union, Iterable, Any from pathlib import Path @@ -342,7 +342,7 @@ class Drawing(blenderbim.core.tool.Drawing): return identification @classmethod - def export_text_literal_attributes(cls, obj): + def export_text_literal_attributes(cls, obj: bpy.types.Object) -> list[dict[str, Any]]: literals = [] for literal_props in obj.BIMTextProperties.literals: literal_data = blenderbim.bim.helper.export_attributes(literal_props.attributes) @@ -350,7 +350,9 @@ class Drawing(blenderbim.core.tool.Drawing): return literals @classmethod - def create_annotation_context(cls, target_view, object_type=None): + def create_annotation_context( + cls, target_view: str, object_type: Optional[str] = None + ) -> ifcopenshell.entity_instance: # checking PLAN target view and annotation type that doesn't require 3d if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW") and object_type not in ( "FALL", @@ -596,7 +598,7 @@ class Drawing(blenderbim.core.tool.Drawing): return ifc_literal @classmethod - def get_assigned_product(cls, element): + def get_assigned_product(cls, element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]: for rel in element.HasAssignments: if rel.is_a("IfcRelAssignsToProduct"): return rel.RelatingProduct @@ -1222,7 +1224,9 @@ class Drawing(blenderbim.core.tool.Drawing): mat.translation += annotation_offset return mat - def clip_to_camera_boundary(mesh: bpy.types.Mesh, bounds: tuple[float, float, float, float, float, float]) -> Union[bpy.types.Mesh, None]: + def clip_to_camera_boundary( + mesh: bpy.types.Mesh, bounds: tuple[float, float, float, float, float, float] + ) -> Union[bpy.types.Mesh, None]: mesh.verts.ensure_lookup_table() points = [v.co for v in mesh.verts[0:2]] points = helper.clip_segment(bounds, points) @@ -1461,7 +1465,7 @@ class Drawing(blenderbim.core.tool.Drawing): return bool(a_tree.overlap(b_tree)) @classmethod - def replace_text_literal_variables(cls, text, product): + def replace_text_literal_variables(cls, text: str, product: Optional[ifcopenshell.entity_instance] = None) -> str: if not product: return text diff --git a/src/blenderbim/blenderbim/tool/spatial.py b/src/blenderbim/blenderbim/tool/spatial.py index 1f72007547..4e5afa9682 100644 --- a/src/blenderbim/blenderbim/tool/spatial.py +++ b/src/blenderbim/blenderbim/tool/spatial.py @@ -20,6 +20,7 @@ import bpy import bmesh import shapely import ifcopenshell +import ifcopenshell.util.element import blenderbim.core.type import blenderbim.core.tool import blenderbim.core.root diff --git a/src/blenderbim/test/tool/test_collector.py b/src/blenderbim/test/tool/test_collector.py index 94e9bee0cc..c377fcc26f 100644 --- a/src/blenderbim/test/tool/test_collector.py +++ b/src/blenderbim/test/tool/test_collector.py @@ -18,6 +18,8 @@ import bpy import ifcopenshell +import ifcopenshell.api +import ifcopenshell.util.element import blenderbim.core.tool import blenderbim.tool as tool from blenderbim.tool.collector import Collector as subject diff --git a/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py b/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py index 450dcd5c20..2c4684b59c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py +++ b/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py @@ -21,7 +21,9 @@ import ifcopenshell.api class Usecase: - def __init__(self, file, products=None, group=None): + def __init__( + self, file: ifcopenshell.file, products: list[ifcopenshell.entity_instance], group: ifcopenshell.entity_instance + ): """Assigns products to a group If a product is already assigned to the group, it will not be assigned @@ -48,7 +50,7 @@ class Usecase: "group": group, } - def execute(self): + def execute(self) -> ifcopenshell.entity_instance: if not self.settings["group"].IsGroupedBy: return self.file.create_entity( "IfcRelAssignsToGroup", @@ -65,3 +67,4 @@ class Usecase: related_objects.add(obj) rel.RelatedObjects = list(related_objects) ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel}) + return rel diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index 149e394c4e..5933ff09a5 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -258,7 +258,7 @@ class GetElementTransformer(lark.Transformer): return args[1:-1].replace("\\", "") -def format(query): +def format(query: str) -> str: return FormatTransformer().transform(format_grammar.parse(query)) diff --git a/src/ifcsverchok/__init__.py b/src/ifcsverchok/__init__.py index ad52a86687..2be7946c95 100644 --- a/src/ifcsverchok/__init__.py +++ b/src/ifcsverchok/__init__.py @@ -117,6 +117,8 @@ reload_event = False import bpy from os.path import splitext import ifcopenshell +import ifcopenshell.api +import ifcopenshell.util.element from ifcsverchok.ifcstore import SvIfcStore diff --git a/src/ifcsverchok/nodes/ifc/add_spatial_element.py b/src/ifcsverchok/nodes/ifc/add_spatial_element.py index 3948bc1e17..bb76c7f821 100644 --- a/src/ifcsverchok/nodes/ifc/add_spatial_element.py +++ b/src/ifcsverchok/nodes/ifc/add_spatial_element.py @@ -21,6 +21,8 @@ import bpy from itertools import chain import ifcopenshell +import ifcopenshell.api +import ifcopenshell.util.element import ifcsverchok.helper from ifcsverchok.ifcstore import SvIfcStore diff --git a/src/ifcsverchok/nodes/ifc/write_file.py b/src/ifcsverchok/nodes/ifc/write_file.py index d832d590cf..c48480b8b9 100644 --- a/src/ifcsverchok/nodes/ifc/write_file.py +++ b/src/ifcsverchok/nodes/ifc/write_file.py @@ -19,6 +19,8 @@ from os.path import abspath, splitext import bpy import ifcopenshell +import ifcopenshell.api +import ifcopenshell.util.element import ifcsverchok.helper from ifcsverchok.ifcstore import SvIfcStore from bpy.props import StringProperty, BoolProperty diff --git a/src/ifctester/test/ids_doc_generator.py b/src/ifctester/test/ids_doc_generator.py index 0b0f593576..a4bfe2c7ab 100644 --- a/src/ifctester/test/ids_doc_generator.py +++ b/src/ifctester/test/ids_doc_generator.py @@ -22,6 +22,7 @@ import uuid import pytest import functools import ifcopenshell +import ifcopenshell.api import ifctester import test_facet import test_ids