diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index 205c3c7659..9042ff7d1d 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -35,9 +35,8 @@ import sys import zipfile import tempfile from pathlib import Path -from typing import Optional +from typing import Optional, Union -import ifcopenshell.util.file if hasattr(os, "uname"): platform_system = os.uname()[0].lower() @@ -56,16 +55,9 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "lib", p try: from . import ifcopenshell_wrapper -except Exception as e: - if int(python_version_tuple[0]) == 2: - # Only for py2, as py3 has exception chaining - import traceback - - traceback.print_exc() - print("-" * 64) +except Exception: raise ImportError("IfcOpenShell not built for '%s'" % python_distribution) -from . import guid from .file import file from .entity_instance import entity_instance, register_schema_attributes from .sql import sqlite, sqlite_entity @@ -92,11 +84,12 @@ class SchemaError(Error): pass -def open(path: "os.PathLike | str", format: str = None, should_stream: bool = False) -> file: +def open(path: Union[os.PathLike, str], format: Optional[str] = None, should_stream: bool = False) -> file: """Loads an IFC dataset from a filepath - You can specify a file format. If no format is given, it is guessed from its extension. - Currently supported specified format : .ifc | .ifcZIP | .ifcXML + You can specify a file format. If no format is given, it is guessed from + its extension. Currently supported specified format: .ifc | .ifcZIP | + .ifcXML. You can then filter by element ID, class, etc, and subscript by id or guid. diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py b/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py index 5bb64d411a..c1ab6c77e1 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py @@ -18,6 +18,7 @@ import ifcopenshell import ifcopenshell.api +import ifcopenshell.guid from typing import Optional diff --git a/src/ifcopenshell-python/ifcopenshell/geom/main.py b/src/ifcopenshell-python/ifcopenshell/geom/main.py index 23eb66cda7..3cd1cb3c5c 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/main.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/main.py @@ -148,7 +148,7 @@ class tree(ifcopenshell_wrapper.tree): def select( self, value: Union[ - entity_instance, ifcopenshell_wrapper.BRepElement, tuple[float, float, float], TopoDS.TopoDS_Shape + entity_instance, ifcopenshell_wrapper.BRepElement, tuple[float, float, float], "TopoDS.TopoDS_Shape" ], **kwargs, ) -> list[entity_instance]: diff --git a/src/ifcopenshell-python/ifcopenshell/util/data.py b/src/ifcopenshell-python/ifcopenshell/util/data.py index b968879c58..365f0df2cb 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/data.py +++ b/src/ifcopenshell-python/ifcopenshell/util/data.py @@ -30,7 +30,7 @@ class Clipping: operand_type: str = "IfcHalfSpaceSolid" @classmethod - def parse(cls, raw_data: Any) -> Union[ifcopenshell.entity_instance, Clipping, None]: + def parse(cls, raw_data: Any) -> Union[ifcopenshell.entity_instance, "Clipping", None]: """Parse various formats into a clipping object `raw_data` can be either: diff --git a/src/ifcopenshell-python/ifcopenshell/util/pset.py b/src/ifcopenshell-python/ifcopenshell/util/pset.py index 6156af3f9c..97db6ff4b2 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/pset.py +++ b/src/ifcopenshell-python/ifcopenshell/util/pset.py @@ -23,12 +23,12 @@ import ifcopenshell.util.schema import ifcopenshell.util.type from ifcopenshell.entity_instance import entity_instance from functools import lru_cache -from typing import List, Generator, Optional +from typing import List, Optional -templates: dict[str, PsetQto] = {} +templates: dict[str, "PsetQto"] = {} -def get_template(schema: str) -> PsetQto: +def get_template(schema: str) -> "PsetQto": global templates if schema not in templates: templates[schema] = PsetQto(schema)