diff --git a/src/blenderbim/blenderbim/core/patch.py b/src/blenderbim/blenderbim/core/patch.py index 2449d6250e..19571437c3 100644 --- a/src/blenderbim/blenderbim/core/patch.py +++ b/src/blenderbim/blenderbim/core/patch.py @@ -17,5 +17,14 @@ # along with BlenderBIM Add-on. If not, see . -def run_migrate_patch(patch, infile=None, outfile=None, schema=None): +from __future__ import annotations +from typing import TYPE_CHECKING, Optional + +if TYPE_CHECKING: + import bpy + import ifcopenshell + import blenderbim.tool as tool + + +def run_migrate_patch(patch: tool.Patch, infile: str, outfile: str, schema: str) -> None: patch.run_migrate_patch(infile, outfile, schema) diff --git a/src/blenderbim/blenderbim/tool/patch.py b/src/blenderbim/blenderbim/tool/patch.py index beb348eb0b..f543a98c6a 100644 --- a/src/blenderbim/blenderbim/tool/patch.py +++ b/src/blenderbim/blenderbim/tool/patch.py @@ -19,15 +19,22 @@ import bpy import ifcopenshell import blenderbim.core.tool +from typing import TYPE_CHECKING + try: import ifcpatch -except: +except ImportError: print("IfcPatch not available") +if TYPE_CHECKING: + import ifcpatch + class Patch(blenderbim.core.tool.Patch): @classmethod - def run_migrate_patch(cls, infile, outfile, schema): - output = ifcpatch.execute({"input": infile, "file": ifcopenshell.open(infile), "recipe": "Migrate", "arguments": [schema]}) + def run_migrate_patch(cls, infile: str, outfile: str, schema: str) -> None: + output = ifcpatch.execute( + {"input": infile, "file": ifcopenshell.open(infile), "recipe": "Migrate", "arguments": [schema]} + ) ifcpatch.write(output, outfile)