From 6bab0603e64dcd2fbbc8119a6f73c606aef23946 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 11 Aug 2026 16:44:47 +1000 Subject: [PATCH] by_type now returns tuple - update annotations and fix failing tests --- src/bonsai/bonsai/bim/module/boundary/operator.py | 2 +- src/ifcopenshell-python/ifcopenshell/file.py | 4 ++-- src/ifcpatch/test/test_UnsharePsets.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/boundary/operator.py b/src/bonsai/bonsai/bim/module/boundary/operator.py index 7ff65e692f..2c53007a1e 100644 --- a/src/bonsai/bonsai/bim/module/boundary/operator.py +++ b/src/bonsai/bonsai/bim/module/boundary/operator.py @@ -678,7 +678,7 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator): # Identify all potential building elements # TODO: don't select everything, use AABB culling in Blender - building_elements = ( + building_elements = list( tool.Ifc.get().by_type("IfcWall") + tool.Ifc.get().by_type("IfcSlab") + tool.Ifc.get().by_type("IfcVirtualElement") diff --git a/src/ifcopenshell-python/ifcopenshell/file.py b/src/ifcopenshell-python/ifcopenshell/file.py index 59fbc46bde..c8908ca20f 100644 --- a/src/ifcopenshell-python/ifcopenshell/file.py +++ b/src/ifcopenshell-python/ifcopenshell/file.py @@ -728,7 +728,7 @@ class file_mixin: [self.transaction.store_create(e) for e in reversed(added_elements)] return result - def by_type(self, type: str, include_subtypes=True) -> list[ifcopenshell.entity_instance]: + def by_type(self, type: str, include_subtypes=True) -> tuple[ifcopenshell.entity_instance, ...]: """Return IFC objects filtered by IFC Type and wrapped with the entity_instance class. If an IFC type class has subclasses, all entities of those subclasses are also returned. @@ -746,7 +746,7 @@ class file_mixin: def traverse( self, inst: ifcopenshell.entity_instance, max_levels: Optional[int] = None, breadth_first: bool = False - ) -> list[ifcopenshell.entity_instance]: + ) -> tuple[ifcopenshell.entity_instance, ...]: """Get a list of all referenced instances for a particular instance including itself :param inst: The entity instance to get all sub instances diff --git a/src/ifcpatch/test/test_UnsharePsets.py b/src/ifcpatch/test/test_UnsharePsets.py index ae09ed879b..2e7b024b14 100644 --- a/src/ifcpatch/test/test_UnsharePsets.py +++ b/src/ifcpatch/test/test_UnsharePsets.py @@ -75,7 +75,7 @@ class TestUnsharePsets(test.bootstrap.IFC4): rel.RelatedObjects = elements ifcpatch.execute({"file": self.file, "recipe": "UnsharePsets", "arguments": ["IfcWall"]}) - assert len(psets := self.file.by_type("IfcPropertySet")) == 4 + assert len(psets := list(self.file.by_type("IfcPropertySet"))) == 4 assert len(self.file.by_type("IfcRelDefinesByProperties")) == 4 psets.remove(shared_pset)