From 527e0f3dbfcf0b797b074babf1d5fe49e3d6255c Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 18 Feb 2025 16:45:21 +0500 Subject: [PATCH] set_element_value - fix error for Python 3.9 types.EllipsisType was added only in 3.10 --- src/ifcopenshell-python/ifcopenshell/util/selector.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index 37919b9408..f0a1025583 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -17,7 +17,7 @@ # along with IfcOpenShell. If not, see . import re -import types +import sys import lark import numpy as np import ifcopenshell.api.pset @@ -37,6 +37,11 @@ import ifcopenshell.util.unit from decimal import Decimal from typing import Optional, Any, Union, Iterable +if sys.version_info >= (3, 10): + from types import EllipsisType +else: + EllipsisType = type(...) + filter_elements_grammar = lark.Lark( """start: filter_group @@ -659,7 +664,7 @@ def set_element_value( def process_pset_prop_value( pset: ifcopenshell.entity_instance, prop: str, value: Any - ) -> Union[Any, types.EllipsisType]: + ) -> Union[Any, EllipsisType]: """Try to process value for edit_pset. `edit_pset` is expecting a sequence of values @@ -672,7 +677,7 @@ def set_element_value( current_value = element.get(key, ...) # Check if previous value is a list as a fast way to identify enum properties. - if not isinstance(current_value, (types.EllipsisType, list)): + if not isinstance(current_value, (EllipsisType, list)): return value if isinstance(current_value, list):