From fc10915d2b7839a823cca18c4a247699da90a2a1 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 30 Jun 2025 18:08:24 +0500 Subject: [PATCH] ifcopenshell.validate - remove simple_spf dependency (689289b) Moved it to `TYPE_CHECKING` since it's currently used just for typing. Was breaking validation in Bonsai since it doesn't provide all submodules with IfcOpenShell https://github.com/IfcOpenShell/IfcOpenShell/issues/6723#issuecomment-3016223786 Also added a simple test so github workflow would catch a simple error like this. --- src/bonsai/test/bim/feature/debug.feature | 6 ++++++ src/ifcopenshell-python/ifcopenshell/validate.py | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bonsai/test/bim/feature/debug.feature b/src/bonsai/test/bim/feature/debug.feature index 6d0bb55bf9..b4de087ade 100644 --- a/src/bonsai/test/bim/feature/debug.feature +++ b/src/bonsai/test/bim/feature/debug.feature @@ -26,3 +26,9 @@ Scenario: Use the inspector - inspect from object When the object "IfcProject/My Project" is selected And I press "bim.inspect_from_object" Then nothing happens + +Scenario: Run IFC validation + Given an empty IFC project + And I load the demo construction library + And I press "bim.validate_ifc_file" + Then nothing happens diff --git a/src/ifcopenshell-python/ifcopenshell/validate.py b/src/ifcopenshell-python/ifcopenshell/validate.py index 6fd62f538d..f65c95077c 100644 --- a/src/ifcopenshell-python/ifcopenshell/validate.py +++ b/src/ifcopenshell-python/ifcopenshell/validate.py @@ -42,6 +42,7 @@ options: """ +from __future__ import annotations import os import sys import json @@ -50,7 +51,7 @@ import types import argparse from collections import namedtuple -from typing import Union, Any, Optional +from typing import Union, Any, Optional, TYPE_CHECKING from collections.abc import Iterator from logging import Logger, Handler @@ -60,11 +61,13 @@ else: EllipsisType = type(...) import ifcopenshell -import ifcopenshell.simple_spf import ifcopenshell.ifcopenshell_wrapper import ifcopenshell.ifcopenshell_wrapper as W import ifcopenshell.express.rule_executor +if TYPE_CHECKING: + import ifcopenshell.simple_spf + named_type = ifcopenshell.ifcopenshell_wrapper.named_type aggregation_type = ifcopenshell.ifcopenshell_wrapper.aggregation_type simple_type = ifcopenshell.ifcopenshell_wrapper.simple_type