Skip to content

Commit bdbe91f

Browse files
committed
typing
1 parent 86d0139 commit bdbe91f

6 files changed

Lines changed: 25 additions & 21 deletions

File tree

src/bonsai/bonsai/bim/module/material/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import ifcopenshell.util.schema
2525
import bonsai.tool as tool
2626
from bonsai.bim.module.drawing.helper import format_distance
27-
from typing import Any
27+
from typing import Any, Union
2828

2929

3030
def refresh():
@@ -174,7 +174,7 @@ def load(cls):
174174
cls.is_loaded = True
175175

176176
@classmethod
177-
def material_class(cls):
177+
def material_class(cls) -> Union[str, None]:
178178
element = tool.Ifc.get_entity(bpy.context.active_object)
179179
cls.material = ifcopenshell.util.element.get_material(element)
180180
if cls.material:

src/bonsai/bonsai/bim/module/pset/prop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def purge():
5252
qtonames = {}
5353

5454

55-
def blender_formatted_enum_from_psets(psets):
55+
def blender_formatted_enum_from_psets(psets: list[ifcopenshell.entity_instance]) -> list[tuple[str, str, str]]:
5656
enum_items = []
5757
version = tool.Ifc.get_schema()
5858
for pset in psets:

src/ifcopenshell-python/ifcopenshell/api/georeference/edit_true_north.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
1818

1919
import ifcopenshell
20+
import ifcopenshell.util.element
2021
import ifcopenshell.util.geolocation
2122
from typing import Union, Optional
2223

src/ifcopenshell-python/ifcopenshell/template.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from .file import file
2424
from .guid import compress
2525
from .ifcopenshell_wrapper import version
26+
from typing import Optional
27+
2628

2729
# A quick way to setup an 'empty' IFC file, taken from:
2830
# http://academy.ifcopenshell.org/creating-a-simple-wall-with-property-set-and-quantity-information/
@@ -68,17 +70,17 @@
6870

6971

7072
def create(
71-
filename=None,
72-
timestring=None,
73-
organization=None,
74-
creator=None,
75-
schema_identifier=None,
76-
application_version=None,
77-
timestamp=None,
78-
application=None,
79-
project_globalid=None,
80-
project_name=None,
81-
):
73+
filename: Optional[str] = None,
74+
timestring: Optional[str] = None,
75+
organization: Optional[str] = None,
76+
creator: Optional[str] = None,
77+
schema_identifier: Optional[str] = None,
78+
application_version: Optional[str] = None,
79+
timestamp: Optional[str] = None,
80+
application: Optional[str] = None,
81+
project_globalid: Optional[str] = None,
82+
project_name: Optional[str] = None,
83+
) -> file:
8284
d = dict(locals())
8385

8486
def _():

src/ifcsverchok/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class IFC_Sv_write_file(bpy.types.Operator):
185185
def poll(cls, context):
186186
return any("IFC" in n for n in context.space_data.edit_tree.nodes.keys())
187187

188-
def ensure_hirarchy(self, file):
189-
elements_in_buildings = set()
188+
def ensure_hirarchy(self, file: ifcopenshell.file) -> None:
189+
elements_in_buildings: set[ifcopenshell.entity_instance] = set()
190190
if len(file.by_type("IfcBuilding")) == 0:
191191
my_building = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcBuilding", name="My Building")
192192
elements = ifcopenshell.util.element.get_decomposition(my_building)
@@ -269,6 +269,7 @@ class IFC_PT_write_file_panel(bpy.types.Panel):
269269
def poll(cls, context):
270270
if context.space_data.edit_tree and any("IFC" in n for n in context.space_data.edit_tree.nodes.keys()):
271271
return True
272+
return False
272273

273274
def draw(self, context):
274275
ng = context.space_data.node_tree

src/ifcsverchok/ifcstore.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
import ifcopenshell.api
2222
import ifcopenshell.util.representation
2323
from ifcopenshell import template
24+
from typing import Union
2425

2526

2627
class SvIfcStore:
2728
path = ""
28-
file = None
29+
file: Union[ifcopenshell.file, None] = None
2930
schema = None
3031
cache = None
3132
cache_path = None
@@ -47,7 +48,7 @@ class SvIfcStore:
4748
schema_identifiers = ["IFC4", "IFC2X3"]
4849

4950
@staticmethod
50-
def purge():
51+
def purge() -> None:
5152
SvIfcStore.path = ""
5253
SvIfcStore.file = None
5354
SvIfcStore.schema = None
@@ -67,8 +68,7 @@ def purge():
6768
SvIfcStore.schema_identifiers = ["IFC4", "IFC2X3"]
6869

6970
@staticmethod
70-
def create_boilerplate():
71-
71+
def create_boilerplate() -> ifcopenshell.file:
7272
file = template.create(
7373
filename="IfcSverchokDemoFile",
7474
organization=None,
@@ -93,7 +93,7 @@ def create_boilerplate():
9393
return SvIfcStore.file
9494

9595
@staticmethod
96-
def get_file():
96+
def get_file() -> ifcopenshell.file:
9797
if SvIfcStore.file is None:
9898
SvIfcStore.create_boilerplate()
9999
return SvIfcStore.file

0 commit comments

Comments
 (0)