mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
typing: modernize Generator annotations
`None, None` assumed by default. Though this was introduced in Python 3.13, before 3.13 it only breaks if we'd do `typing.Generator[T]` (which is deprecated) -`collections.abc.Generator[T]` works fine, it seems it never had an arity check.
This commit is contained in:
@@ -179,7 +179,7 @@ def format_debug_info(info: dict[str, Any]) -> str:
|
||||
return text.strip()
|
||||
|
||||
|
||||
def get_binaries(path: Path) -> Generator[Path, None, None]:
|
||||
def get_binaries(path: Path) -> Generator[Path]:
|
||||
yield from path.glob("**/*.pyd")
|
||||
yield from path.glob("**/*.dll")
|
||||
# pyradiance is using .so files on windows for some reason.
|
||||
|
||||
@@ -94,9 +94,7 @@ class Array(bonsai.core.tool.Array):
|
||||
return array_objects
|
||||
|
||||
@classmethod
|
||||
def get_all_children_objects(
|
||||
cls, parent_element: ifcopenshell.entity_instance
|
||||
) -> Generator[bpy.types.Object, None, None]:
|
||||
def get_all_children_objects(cls, parent_element: ifcopenshell.entity_instance) -> Generator[bpy.types.Object]:
|
||||
for array_modifier in cls.get_modifiers_data(parent_element):
|
||||
yield from cls.get_children_objects(array_modifier)
|
||||
|
||||
@@ -128,12 +126,12 @@ class Array(bonsai.core.tool.Array):
|
||||
return tool.Ifc.get_object(parent_element)
|
||||
|
||||
@classmethod
|
||||
def get_modifiers_data(cls, parent_element: ifcopenshell.entity_instance) -> Generator[dict[str, Any], None, None]:
|
||||
def get_modifiers_data(cls, parent_element: ifcopenshell.entity_instance) -> Generator[dict[str, Any]]:
|
||||
array_pset = ifcopenshell.util.element.get_pset(parent_element, "BBIM_Array")
|
||||
yield from json.loads(array_pset["Data"])
|
||||
|
||||
@classmethod
|
||||
def get_children_objects(cls, modifier_data: dict[str, Any]) -> Generator[bpy.types.Object, None, None]:
|
||||
def get_children_objects(cls, modifier_data: dict[str, Any]) -> Generator[bpy.types.Object]:
|
||||
child_guid: str
|
||||
for child_guid in modifier_data["children"]:
|
||||
child_obj = tool.Blender.get_object_from_guid(child_guid)
|
||||
|
||||
@@ -2161,7 +2161,7 @@ class Blender(bonsai.core.tool.Blender):
|
||||
return cls.get_internal_data_dir() / relative_path
|
||||
|
||||
@classmethod
|
||||
def get_data_dir_paths(cls, relative_dir_path: Union[str, Path], glob_pattern: str) -> Generator[Path, None, None]:
|
||||
def get_data_dir_paths(cls, relative_dir_path: str | Path, glob_pattern: str) -> Generator[Path]:
|
||||
"""Return paths based on glob pattern from the provided path in data folder.
|
||||
Return paths from internal data folder first and then paths from the user data folder (if it exists)."""
|
||||
custom_path = cls.get_user_data_dir() / relative_dir_path
|
||||
@@ -2681,7 +2681,7 @@ class Blender(bonsai.core.tool.Blender):
|
||||
|
||||
@classmethod
|
||||
@contextlib.contextmanager
|
||||
def bonsai_crash_txt(cls, s: str = "") -> Generator[Path, Any, None]:
|
||||
def bonsai_crash_txt(cls, s: str = "") -> Generator[Path, Any]:
|
||||
"""Create a temporary bonsai.crash.txt file the with current traceback.
|
||||
|
||||
Useful in case Blender crash might occur too unexpectedly (e.g. #6686),
|
||||
|
||||
@@ -562,7 +562,7 @@ class Cost(bonsai.core.tool.Cost):
|
||||
@classmethod
|
||||
def get_schedule_cost_items(
|
||||
cls, cost_schedule: ifcopenshell.entity_instance
|
||||
) -> Generator[ifcopenshell.entity_instance, None, None]:
|
||||
) -> Generator[ifcopenshell.entity_instance]:
|
||||
return ifcopenshell.util.cost.get_schedule_cost_items(cost_schedule)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -150,7 +150,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
|
||||
@classmethod
|
||||
@contextmanager
|
||||
def batch_host_recut(cls) -> Generator[None, None, None]:
|
||||
def batch_host_recut(cls) -> Generator[None]:
|
||||
"""Coalesce host body work — `recut_host` and `update_host_representation`
|
||||
calls inside the with-block enqueue by voided element id. On the outermost
|
||||
exit: every host's `update_representation` runs first (writes Blender mesh
|
||||
@@ -2093,7 +2093,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
return use_immediate_repr
|
||||
|
||||
@classmethod
|
||||
def get_openings(cls, element: ifcopenshell.entity_instance) -> Generator[ifcopenshell.entity_instance, None, None]:
|
||||
def get_openings(cls, element: ifcopenshell.entity_instance) -> Generator[ifcopenshell.entity_instance]:
|
||||
"""Get element openings as IfcRelVoidsElements.
|
||||
|
||||
Use `.RelatedOpeningElement` to get the opening element.
|
||||
|
||||
@@ -258,14 +258,14 @@ class Spatial(bonsai.core.tool.Spatial):
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def get_selected_products(cls) -> Generator[ifcopenshell.entity_instance, None, None]:
|
||||
def get_selected_products(cls) -> Generator[ifcopenshell.entity_instance]:
|
||||
for obj in bpy.context.selected_objects:
|
||||
entity = tool.Ifc.get_entity(obj)
|
||||
if entity and entity.is_a("IfcProduct"):
|
||||
yield entity
|
||||
|
||||
@classmethod
|
||||
def get_selected_product_types(cls) -> Generator[ifcopenshell.entity_instance, None, None]:
|
||||
def get_selected_product_types(cls) -> Generator[ifcopenshell.entity_instance]:
|
||||
for obj in tool.Blender.get_selected_objects():
|
||||
entity = tool.Ifc.get_entity(obj)
|
||||
if entity and entity.is_a("IfcTypeProduct"):
|
||||
|
||||
Reference in New Issue
Block a user