diff --git a/src/bonsai/bonsai/bim/module/tester/operator.py b/src/bonsai/bonsai/bim/module/tester/operator.py index b2c8e51d20..3b963d753d 100644 --- a/src/bonsai/bonsai/bim/module/tester/operator.py +++ b/src/bonsai/bonsai/bim/module/tester/operator.py @@ -29,6 +29,7 @@ import ifcopenshell import bonsai.tool as tool import bonsai.bim.handler from pathlib import Path +from typing import Union class ExecuteIfcTester(bpy.types.Operator): @@ -66,7 +67,7 @@ class ExecuteIfcTester(bpy.types.Operator): bonsai.bim.handler.refresh_ui_data() return {"FINISHED"} - def execute_tester(self, ifc_data, ifc_path, specs_path): + def execute_tester(self, ifc_data: ifcopenshell.file, ifc_path: str, specs_path: str) -> Union[set[str], None]: props = bpy.context.scene.IfcTesterProperties with tempfile.TemporaryDirectory() as dirpath: diff --git a/src/ifccsv/ifccsv.py b/src/ifccsv/ifccsv.py index c41bf2d040..e474724ee0 100755 --- a/src/ifccsv/ifccsv.py +++ b/src/ifccsv/ifccsv.py @@ -29,7 +29,7 @@ import ifcopenshell.util.selector import ifcopenshell.util.element import ifcopenshell.util.schema from statistics import mean -from typing import Optional, Union, Literal +from typing import Optional, Union, Literal, Iterable try: from odf.namespaces import OFFICENS @@ -65,6 +65,9 @@ FILE_FORMAT = Literal[ class IfcCsv: + attributes: list[str] + headers: list[str] + def __init__(self): self.headers = [] self.results = [] @@ -73,9 +76,9 @@ class IfcCsv: def export( self, ifc_file: ifcopenshell.file, - elements: ifcopenshell.entity_instance, - attributes, - headers=None, + elements: Iterable[ifcopenshell.entity_instance], + attributes: Union[list[str], None], + headers: Optional[list[str]] = None, output=None, format: FILE_FORMAT = None, should_preserve_existing: bool = False, diff --git a/src/ifcopenshell-python/ifcopenshell/guid.py b/src/ifcopenshell-python/ifcopenshell/guid.py index d31f744166..5be73b6bd5 100644 --- a/src/ifcopenshell-python/ifcopenshell/guid.py +++ b/src/ifcopenshell-python/ifcopenshell/guid.py @@ -33,7 +33,7 @@ from functools import reduce chars = string.digits + string.ascii_uppercase + string.ascii_lowercase + "_$" -def compress(g): +def compress(g: str) -> str: bs = [int(g[i : i + 2], 16) for i in range(0, len(g), 2)] def b64(v, l=4): @@ -42,7 +42,7 @@ def compress(g): return "".join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 8) + bs[i + 2]) for i in range(1, 16, 3)]) -def expand(g): +def expand(g: str) -> str: def b64(v): return reduce(lambda a, b: a * 64 + b, map(lambda c: chars.index(c), v)) @@ -53,9 +53,9 @@ def expand(g): return "".join(["%02x" % b for b in bs]) -def split(g): +def split(g: str) -> str: return "{%s-%s-%s-%s-%s}" % (g[:8], g[8:12], g[12:16], g[16:20], g[20:]) -def new(): +def new() -> str: return compress(uuid.uuid4().hex) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index 8497e99a07..5995fe6d32 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -23,15 +23,15 @@ import ifcopenshell.api.pset import ifcopenshell.api.geometry import ifcopenshell.util import ifcopenshell.util.attribute -import ifcopenshell.util.fm -import ifcopenshell.util.unit -import ifcopenshell.util.element -import ifcopenshell.util.placement -import ifcopenshell.util.geolocation import ifcopenshell.util.classification +import ifcopenshell.util.element +import ifcopenshell.util.fm +import ifcopenshell.util.geolocation +import ifcopenshell.util.placement import ifcopenshell.util.schema import ifcopenshell.util.shape import ifcopenshell.util.system +import ifcopenshell.util.unit from decimal import Decimal from typing import Optional, Any, Union, Iterable diff --git a/src/ifcopenshell-python/ifcopenshell/validate.py b/src/ifcopenshell-python/ifcopenshell/validate.py index 7b8d68e917..1caf969f42 100644 --- a/src/ifcopenshell-python/ifcopenshell/validate.py +++ b/src/ifcopenshell-python/ifcopenshell/validate.py @@ -393,6 +393,7 @@ def validate(f: Union[ifcopenshell.file, str], logger: Logger, express_rules=Fal logger.error(f"Unsupported schema: {schema_name}") return + assert isinstance(f, ifcopenshell.file) log_internal_cpp_errors(f, filename, logger) validate_ifc_header(f, logger)