From 01ddf8e7699ade0817a20d2f1bd5ae60d4f0ec78 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 15 Apr 2024 11:21:10 +0500 Subject: [PATCH] util.classification small optimization --- .../ifcopenshell/util/classification.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/classification.py b/src/ifcopenshell-python/ifcopenshell/util/classification.py index 12e82139cb..42208a90e7 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/classification.py +++ b/src/ifcopenshell-python/ifcopenshell/util/classification.py @@ -23,10 +23,10 @@ from typing import Optional def get_references(element: ifcopenshell.entity_instance, should_inherit=True) -> set[ifcopenshell.entity_instance]: results = set() if not element.is_a("IfcRoot"): - if hasattr(element, "HasExternalReferences"): - return {r.RelatingReference for r in element.HasExternalReferences or []} - elif hasattr(element, "HasExternalReference"): # Seriously, IFC? - return {r.RelatingReference for r in element.HasExternalReference or []} + if (references := getattr(element, "HasExternalReferences", None)) is not None or ( + references := getattr(element, "HasExternalReference", None) + ) is not None: + return {r.RelatingReference for r in references} if should_inherit: element_type = ifcopenshell.util.element.get_type(element) if element_type and element_type != element: