From e46a99870b8a9e6d640306f02c7c0f1bb135e834 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 14 Nov 2025 18:18:52 +0500 Subject: [PATCH] typing --- src/bonsai/bonsai/bim/module/drawing/decoration.py | 7 ++++--- src/bonsai/bonsai/bim/ui.py | 1 + src/ifcopenshell-python/ifcopenshell/__init__.py | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/drawing/decoration.py b/src/bonsai/bonsai/bim/module/drawing/decoration.py index 1735b32575..d47e8a85c5 100644 --- a/src/bonsai/bonsai/bim/module/drawing/decoration.py +++ b/src/bonsai/bonsai/bim/module/drawing/decoration.py @@ -42,7 +42,7 @@ from bonsai.bim.module.drawing.helper import format_distance from timeit import default_timer as timer from functools import cache from typing import Optional, Union -from collections.abc import Iterator +from collections.abc import Generator, Iterator UNSPECIAL_ELEMENT_COLOR = (0.2, 0.2, 0.2, 1) # GREY @@ -186,7 +186,7 @@ class BaseDecorator: def camera_zoom_to_factor(self, zoom): return math.pow(((zoom / 50) + math.sqrt(2)) / 2, 2) - def get_splines(self, obj): + def get_splines(self, obj: bpy.types.Object) -> Generator[list[Vector]]: """Iterates through splines Args: obj: Blender object with Curve data @@ -194,13 +194,14 @@ class BaseDecorator: Yields: verts: points of each spline, world coords """ + assert type(obj.data) is bpy.types.Curve for spline in obj.data.splines: spline_points = spline.bezier_points if spline.bezier_points else spline.points if len(spline_points) < 2: continue yield [obj.matrix_world @ p.co for p in spline_points] - def get_path_geom(self, obj, topo=True): + def get_path_geom(self, obj: bpy.types.Object, topo: bool = True): """Parses path geometry into line segments Args: diff --git a/src/bonsai/bonsai/bim/ui.py b/src/bonsai/bonsai/bim/ui.py index f6f21dea86..25137cf639 100644 --- a/src/bonsai/bonsai/bim/ui.py +++ b/src/bonsai/bonsai/bim/ui.py @@ -535,6 +535,7 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences): should_setup_workspace: bool activate_workspace: bool should_setup_toolbar: bool + should_use_snap: bool should_play_chaching_sound: bool tmp_dir: str decorations_colour: tuple[float, float, float, float] diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index c12d619b58..8b65d5afe7 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -60,7 +60,7 @@ import zipfile import tempfile from pathlib import Path from typing import Optional, Union, TYPE_CHECKING, Any, overload, Literal -from collections.abc import Sequence +from collections.abc import Generator, Sequence if TYPE_CHECKING: import ifcopenshell.express.schema_class @@ -355,7 +355,7 @@ def stream2(path: Union[Path, str], mmap: bool = False, page_size: int = 0): yield inst -def stream2_from_string(data: str): +def stream2_from_string(data: str) -> Generator[dict]: """Streams the content of a file path from string, yielding each instance as a dictionary. @@ -371,7 +371,7 @@ def stream2_from_string(data: str): yield inst -def convert_path_to_rocksdb(ifcspf_path: Union[Path, str], rocksdb_path: Union[Path, str]): +def convert_path_to_rocksdb(ifcspf_path: Union[Path, str], rocksdb_path: Union[Path, str]) -> None: """Converts an IFC-SPF file on disk to the IfcOpenShell-specific RocksDB encoding. RocksDB is an embedded key-value store that allows partial reads and is therefore more memory efficient with larger files.