diff --git a/src/ifcopenshell-python/ifcopenshell/api/attribute/edit_attributes.py b/src/ifcopenshell-python/ifcopenshell/api/attribute/edit_attributes.py index 05dbff5a5c..650c2c57bd 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/attribute/edit_attributes.py +++ b/src/ifcopenshell-python/ifcopenshell/api/attribute/edit_attributes.py @@ -17,9 +17,11 @@ # along with IfcOpenShell. If not, see . import ifcopenshell.api +import ifcopenshell.util.element +from typing import Any -def edit_attributes(file, product=None, attributes=None) -> None: +def edit_attributes(file: ifcopenshell.file, product: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None: """Edit the attributes of a product All IFC entities have attributes. Normally they can be edited directly, @@ -31,7 +33,7 @@ def edit_attributes(file, product=None, attributes=None) -> None: entity. :type product: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/boundary/assign_connection_geometry.py b/src/ifcopenshell-python/ifcopenshell/api/boundary/assign_connection_geometry.py index b184810642..90994d8499 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/boundary/assign_connection_geometry.py +++ b/src/ifcopenshell-python/ifcopenshell/api/boundary/assign_connection_geometry.py @@ -17,17 +17,18 @@ # along with IfcOpenShell. If not, see . import ifcopenshell.util.unit +from typing import Optional def assign_connection_geometry( - file, - rel_space_boundary=None, - outer_boundary=None, - inner_boundaries=None, - location=None, - axis=None, - ref_direction=None, - unit_scale=None, + file: ifcopenshell.file, + rel_space_boundary: ifcopenshell.entity_instance, + outer_boundary: list[tuple[float, float]], + location: tuple[float, float, float], + axis: tuple[float, float, float], + ref_direction: tuple[float, float, float], + inner_boundaries: Optional[list[list[tuple[float, float]]]] = None, + unit_scale: Optional[float] = None, ) -> None: """Create and assign a connection geometry to a space boundary relationship @@ -44,24 +45,24 @@ def assign_connection_geometry( polyline. The last point will connect to the first point. Each point is represented by an interable of 2 floats. The coordinates of the points are relative to the positional matrix arguments. - :type outer_boundary: list[list[float]] + :type outer_boundary: list[tuple[float, float]] :param inner_boundaries: A list of zero or more inner boundaries to use for the plane. Each boundary is represented by an open polyline, as defined by the outer_boundary argument. - :type inner_boundaries: list[list[list[float]]], optional + :type inner_boundaries: list[list[tuple[float, float]]], optional :param location: The local origin of the connection geometry, defined as an XYZ coordinate relative to the placement of the space that is being bounded. - :type location: list[float] + :type location: tuple[float, float, float] :param axis: The local X axis of the connection geometry, defined as an XYZ vector relative to the placement of the space that is being bounded. - :type axis: list[float] + :type axis: tuple[float, float, float] :param ref_direction: The local Z axis of the connection geometry, defined as an XYZ vector relative to the placement of the space that is being bounded. The Y vector is automatically derived using the right hand rule. - :type ref_direction: list[float] + :type ref_direction: tuple[float, float, float] :param unit_scale: The unit scale as calculated by ifcopenshell.util.unit.calculate_unit_scale. If not provided, it will be automatically calculated for you. diff --git a/src/ifcopenshell-python/ifcopenshell/api/boundary/copy_boundary.py b/src/ifcopenshell-python/ifcopenshell/api/boundary/copy_boundary.py index b051bae828..791cc09bbb 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/boundary/copy_boundary.py +++ b/src/ifcopenshell-python/ifcopenshell/api/boundary/copy_boundary.py @@ -19,13 +19,13 @@ import ifcopenshell.util.element -def copy_boundary(file, boundary=None) -> None: +def copy_boundary(file: ifcopenshell.file, boundary: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance: """Copies a space boundary :param boundary: The IfcRelSpaceBoundary you want to copy. :type boundary: ifcopenshell.entity_instance - :return: None - :rtype: None + :return: Duplicate of the IfcRelSpaceBoundary + :rtype: ifcopenshell.entity_instance Example: diff --git a/src/ifcopenshell-python/ifcopenshell/api/boundary/edit_attributes.py b/src/ifcopenshell-python/ifcopenshell/api/boundary/edit_attributes.py index 663c656dbb..449d16c12a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/boundary/edit_attributes.py +++ b/src/ifcopenshell-python/ifcopenshell/api/boundary/edit_attributes.py @@ -15,15 +15,17 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Optional def edit_attributes( - file, - entity=None, - relating_space=None, - related_building_element=None, - parent_boundary=None, - corresponding_boundary=None, + file: ifcopenshell.file, + entity: ifcopenshell.entity_instance, + relating_space: ifcopenshell.entity_instance, + related_building_element: ifcopenshell.entity_instance, + parent_boundary: Optional[ifcopenshell.entity_instance] = None, + corresponding_boundary: Optional[ifcopenshell.entity_instance] = None, ) -> None: """Modify the relationships of a space boundary relationship diff --git a/src/ifcopenshell-python/ifcopenshell/api/boundary/remove_boundary.py b/src/ifcopenshell-python/ifcopenshell/api/boundary/remove_boundary.py index dadf44e3c7..6962a3121a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/boundary/remove_boundary.py +++ b/src/ifcopenshell-python/ifcopenshell/api/boundary/remove_boundary.py @@ -20,7 +20,7 @@ import ifcopenshell import ifcopenshell.util.element -def remove_boundary(file, boundary=None) -> None: +def remove_boundary(file: ifcopenshell.file, boundary: ifcopenshell.entity_instance) -> None: """Removes a space boundary The relating space or related building element is untouched. Only the diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/edit_classification.py b/src/ifcopenshell-python/ifcopenshell/api/classification/edit_classification.py index 7568a11d5e..f7577bdc4c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/classification/edit_classification.py +++ b/src/ifcopenshell-python/ifcopenshell/api/classification/edit_classification.py @@ -15,9 +15,13 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_classification(file, classification=None, attributes=None) -> None: +def edit_classification( + file: ifcopenshell.file, classification: ifcopenshell.entity_instance, attributes: dict[str, Any] +) -> None: """Edits the attributes of an IfcClassification For more information about the attributes and data types of an @@ -26,7 +30,7 @@ def edit_classification(file, classification=None, attributes=None) -> None: :param classification: The IfcClassification entity you want to edit :type classification: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/edit_reference.py b/src/ifcopenshell-python/ifcopenshell/api/classification/edit_reference.py index dc5096f38c..d8052a333f 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/classification/edit_reference.py +++ b/src/ifcopenshell-python/ifcopenshell/api/classification/edit_reference.py @@ -15,9 +15,13 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_reference(file, reference=None, attributes=None) -> None: +def edit_reference( + file: ifcopenshell.file, reference: ifcopenshell.entity_instance, attributes: dict[str, Any] +) -> None: """Edits the attributes of an IfcClassificationReference For more information about the attributes and data types of an @@ -26,7 +30,7 @@ def edit_reference(file, reference=None, attributes=None) -> None: :param reference: The IfcClassificationReference entity you want to edit :type reference: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py b/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py index 21e02d7b86..38ae9408e6 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py +++ b/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py @@ -20,7 +20,7 @@ import ifcopenshell import ifcopenshell.util.element -def remove_classification(file: ifcopenshell.entity_instance, classification: ifcopenshell.entity_instance) -> None: +def remove_classification(file: ifcopenshell.file, classification: ifcopenshell.entity_instance) -> None: """Removes an IfcClassification from the project and all references The classification and all of its relationships, children references, diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric.py index ab0870b528..70ca67a743 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric.py +++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric.py @@ -19,7 +19,7 @@ import ifcopenshell -def add_metric(file, objective=None) -> None: +def add_metric(file: ifcopenshell.file, objective: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance: """Add a new metric benchmark Qualitative constraints may have a series of quantitative benchmarks @@ -50,7 +50,7 @@ def add_metric(file, objective=None) -> None: "Name": "Unnamed", "ConstraintGrade": "NOTDEFINED", "Benchmark": "EQUALTO", - } + }, ) if settings["objective"]: benchmark_values = list(settings["objective"].BenchmarkValues or []) diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric_reference.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric_reference.py index a3c37392e2..fdcdf50f6f 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric_reference.py +++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric_reference.py @@ -19,16 +19,18 @@ import ifcopenshell -def add_metric_reference(file, metric=None, reference_path=None) -> None: +def add_metric_reference( + file: ifcopenshell.file, metric: ifcopenshell.entity_instance, reference_path: str +) -> list[ifcopenshell.entity_instance]: """ Adds a chain of references to a metric. The reference path is a string of the form "attribute.attribute.attribute" Used to reference a value of an attribute of an instance through a metric objective entity. """ settings = {"metric": metric, "reference_path": reference_path} + references_created = [] if settings["reference_path"]: attributes = settings["reference_path"].split(".") - references_created = [] for i in range(len(attributes)): if i == 0: reference = file.create_entity("IfcReference") @@ -40,4 +42,4 @@ def add_metric_reference(file, metric=None, reference_path=None) -> None: reference.AttributeIdentifier = attributes[i] references_created[i - 1].InnerReference = reference references_created.append(reference) - return references_created + return references_created diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_objective.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_objective.py index efce0bc080..2d8c0ab8db 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_objective.py +++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_objective.py @@ -19,7 +19,7 @@ import ifcopenshell -def add_objective(file) -> None: +def add_objective(file: ifcopenshell.file) -> ifcopenshell.entity_instance: """Add a new objective constraint Parametric constraints may be defined by the user. The constraint is defined diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_metric.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_metric.py index b1ba5699ca..f90d1590d9 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_metric.py +++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_metric.py @@ -15,9 +15,11 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_metric(file, metric=None, attributes=None) -> None: +def edit_metric(file: ifcopenshell.file, metric: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None: """Edit the attributes of a metric For more information about the attributes and data types of an @@ -26,7 +28,7 @@ def edit_metric(file, metric=None, attributes=None) -> None: :param metric: The IfcMetric you want to edit. :type metric: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_objective.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_objective.py index 6ce5c597e8..0004261031 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_objective.py +++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_objective.py @@ -15,9 +15,13 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_objective(file, objective=None, attributes=None) -> None: +def edit_objective( + file: ifcopenshell.file, objective: ifcopenshell.entity_instance, attributes: dict[str, Any] +) -> None: """Edit the attributes of a objective For more information about the attributes and data types of an @@ -26,7 +30,7 @@ def edit_objective(file, objective=None, attributes=None) -> None: :param objective: The IfcObjective you want to edit. :type objective: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_constraint.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_constraint.py index 30b61fb5c7..aea342e126 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_constraint.py +++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_constraint.py @@ -20,7 +20,7 @@ import ifcopenshell import ifcopenshell.util.element -def remove_constraint(file, constraint=None) -> None: +def remove_constraint(file: ifcopenshell.file, constraint: ifcopenshell.entity_instance) -> None: """Remove a constraint (typically an objective) Removes a constraint definition and all of its associations to any diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_metric.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_metric.py index 49203da3c5..2829a3355f 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_metric.py +++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_metric.py @@ -15,9 +15,10 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell -def remove_metric(file, metric=None) -> None: +def remove_metric(file: ifcopenshell.file, metric: ifcopenshell.entity_instance) -> None: """Remove a metric benchmark Removes a metric benchmark and all of its associations to any products diff --git a/src/ifcopenshell-python/ifcopenshell/api/context/remove_context.py b/src/ifcopenshell-python/ifcopenshell/api/context/remove_context.py index 94547b675e..e80cbddaf6 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/context/remove_context.py +++ b/src/ifcopenshell-python/ifcopenshell/api/context/remove_context.py @@ -17,9 +17,11 @@ # along with IfcOpenShell. If not, see . import ifcopenshell +import ifcopenshell.api +import ifcopenshell.util.element -def remove_context(file: ifcopenshell.entity_instance, context: ifcopenshell.entity_instance) -> None: +def remove_context(file: ifcopenshell.file, context: ifcopenshell.entity_instance) -> None: """Removes an IfcGeometricRepresentationContext Any representation geometry that is assigned to the context is also diff --git a/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py b/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py index ed52f1be73..b9ca8ab9d0 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py +++ b/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py @@ -19,9 +19,14 @@ import ifcopenshell import ifcopenshell.api import ifcopenshell.guid +from typing import Union -def assign_control(file, relating_control=None, related_object=None) -> None: +def assign_control( + file: ifcopenshell.file, + relating_control: ifcopenshell.entity_instance, + related_object: ifcopenshell.entity_instance, +) -> Union[ifcopenshell.entity_instance, None]: """Assigns a planning control or constraint to an object IFC can describe concepts that control other objects. For example, a diff --git a/src/ifcopenshell-python/ifcopenshell/api/control/unassign_control.py b/src/ifcopenshell-python/ifcopenshell/api/control/unassign_control.py index 0463689c5f..f2d4cc8a9b 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/control/unassign_control.py +++ b/src/ifcopenshell-python/ifcopenshell/api/control/unassign_control.py @@ -19,9 +19,14 @@ import ifcopenshell import ifcopenshell.api import ifcopenshell.util.element +from typing import Union -def unassign_control(file, relating_control=None, related_object=None) -> None: +def unassign_control( + file: ifcopenshell.file, + relating_control: ifcopenshell.entity_instance, + related_object: ifcopenshell.entity_instance, +) -> Union[ifcopenshell.entity_instance, None]: """Unassigns a planning control or constraint to an object :param relating_control: The IfcControl entity that is creating the diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py index 461279942a..a33c17c890 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py @@ -18,22 +18,29 @@ import ifcopenshell.api import ifcopenshell.guid +from typing import Optional -def add_cost_item(file, cost_schedule=None, cost_item=None) -> None: +def add_cost_item( + file: ifcopenshell.file, + cost_schedule: Optional[ifcopenshell.entity_instance] = None, + cost_item: Optional[ifcopenshell.entity_instance] = None, +) -> ifcopenshell.entity_instance: """Add a new cost item A cost item represents a single line item in a cost schedule. Cost items may then be broken down into cost subitems. + Either `cost_schedule` or `cost_item` must be provided. + :param cost_schedule: If the cost item is to be added as a root or top level cost item to a cost schedule, the IfcCostSchedule may be specified. This is mutually exlclusive to the cost_item parameter. - :type cost_schedule: ifcopenshell.entity_instance + :type cost_schedule: ifcopenshell.entity_instance, optional. :param cost_item: If the cost item is to be added as a subitem to an existing cost item, the parent IfcCostItem may be specified. This is mutually exclusive to the cost_schedule parameter. - :type cost_item: ifcopenshell.entity_instance + :type cost_item: ifcopenshell.entity_instance, optional :return: The newly created IfcCostItem :rtype: ifcopenshell.entity_instance @@ -62,7 +69,7 @@ def add_cost_item(file, cost_schedule=None, cost_item=None) -> None: "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file), "RelatedObjects": [cost_item], "RelatingControl": settings["cost_schedule"], - } + }, ) elif settings["cost_item"]: ifcopenshell.api.run( diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py index 47a9b3efb9..61ba86f6b2 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py @@ -19,7 +19,9 @@ import ifcopenshell.api -def add_cost_item_quantity(file, cost_item=None, ifc_class="IfcQuantityCount") -> None: +def add_cost_item_quantity( + file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, ifc_class: str = "IfcQuantityCount" +) -> ifcopenshell.entity_instance: """Adds a new quantity associated with a cost item Cost items calculate their subtotal by multiplying the sum of the cost diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py index d72566ae1f..95c638182a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py @@ -19,9 +19,10 @@ import ifcopenshell.api import ifcopenshell.util.date from datetime import datetime +from typing import Optional -def add_cost_schedule(file, name=None, predefined_type="NOTDEFINED") -> None: +def add_cost_schedule(file: ifcopenshell.file, name: Optional[str] = None, predefined_type="NOTDEFINED") -> None: """Add a new cost schedule A cost schedule is a group of cost items which typically represent a diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_value.py index b6fe5f5698..6c59af0bb6 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_value.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_value.py @@ -15,9 +15,10 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell -def add_cost_value(file, parent=None) -> None: +def add_cost_value(file: ifcopenshell.file, parent: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance: """Adds a new value or subvalue to a cost item A cost item's subtotal can be specified in two ways. diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py index 6c13162ed7..bf5b412a21 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py @@ -17,9 +17,15 @@ # along with IfcOpenShell. If not, see . import ifcopenshell.api +from typing import Optional -def assign_cost_item_quantity(file, cost_item=None, products=None, prop_name="") -> None: +def assign_cost_item_quantity( + file: ifcopenshell.file, + cost_item: ifcopenshell.entity_instance, + products: list[ifcopenshell.entity_instance], + prop_name: Optional[str] = "", +) -> None: """Adds a cost item quantity that is parametrically connected to a product A cost item may have its subtotal calculated by multiplying a unit value diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py index 18bb05694f..dda9d509eb 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py @@ -19,7 +19,9 @@ import ifcopenshell.api -def assign_cost_value(file, cost_item=None, cost_rate=None) -> None: +def assign_cost_value( + file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, cost_rate: ifcopenshell.entity_instance +) -> None: """Assigns a cost value to a cost item from a schedule of rates Instead of assigning cost values from scratch for each cost item in a diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py index c977be1b19..897a2d7412 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py @@ -21,7 +21,7 @@ import ifcopenshell.util.date import ifcopenshell.util.resource -def calculate_cost_item_resource_value(file, cost_item=None) -> None: +def calculate_cost_item_resource_value(file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance) -> None: """Calculates the total cost of all resources associated with a cost item A cost item may have construction resources (e.g. equipment, material, diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py index 13927088ed..7b08df16a5 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py @@ -19,9 +19,14 @@ import ifcopenshell import ifcopenshell.api import ifcopenshell.util.element +from typing import Union -def copy_cost_item(file, cost_item=None) -> None: +def copy_cost_item( + file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance +) -> Union[ifcopenshell.entity_instance, list[ifcopenshell.entity_instance]]: + # TODO: currently it never returns list of duplicated cost items + # though it is stated in the docs """Copies all cost items and related relationships The following relationships are also duplicated: @@ -33,7 +38,7 @@ def copy_cost_item(file, cost_item=None) -> None: :param cost_item: The cost item to be duplicated :type cost_item: ifcopenshell.entity_instance :return: The duplicated cost item or the list of duplicated cost items if the latter has children - :rtype: ifcopenshell.entity_instance or list of ifcopenshell.entity_instance + :rtype: ifcopenshell.entity_instance or list[ifcopenshell.entity_instance] Example: .. code:: python @@ -55,7 +60,7 @@ def copy_cost_item(file, cost_item=None) -> None: class Usecase: def execute(self): self.new_cost_items = [] - self.duplicate_cost_item(self.settings["cost_item"]) + return self.duplicate_cost_item(self.settings["cost_item"]) def duplicate_cost_item(self, cost_item): new_cost_item = ifcopenshell.util.element.copy_deep(self.file, cost_item) diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item_values.py b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item_values.py index 8ccb0a4158..6fadb9a349 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item_values.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item_values.py @@ -20,7 +20,9 @@ import ifcopenshell.util.element import ifcopenshell.api -def copy_cost_item_values(file, source=None, destination=None) -> None: +def copy_cost_item_values( + file: ifcopenshell.file, source: ifcopenshell.entity_instance, destination: ifcopenshell.entity_instance +) -> None: """Copies all cost values from one cost item to another Any previously existing values will be removed. The entire value is diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item.py index 2bf72a5d57..4d168173b6 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item.py @@ -15,9 +15,13 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_cost_item(file, cost_item=None, attributes=None) -> None: +def edit_cost_item( + file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, attributes: dict[str, Any] +) -> None: """Edits the attributes of an IfcCostItem For more information about the attributes and data types of an @@ -26,7 +30,7 @@ def edit_cost_item(file, cost_item=None, attributes=None) -> None: :param cost_item: The IfcCostItem entity you want to edit :type cost_item: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item_quantity.py index 178816a593..9d1c7a554c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item_quantity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item_quantity.py @@ -15,9 +15,13 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_cost_item_quantity(file, physical_quantity=None, attributes=None) -> None: +def edit_cost_item_quantity( + file: ifcopenshell.file, physical_quantity: ifcopenshell.entity_instance, attributes: dict[str, Any] +) -> None: """Edits the attributes of an IfcPhysicalQuantity For more information about the attributes and data types of an @@ -26,7 +30,7 @@ def edit_cost_item_quantity(file, physical_quantity=None, attributes=None) -> No :param physical_quantity: The IfcPhysicalQuantity entity you want to edit :type physical_quantity: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_schedule.py index 3e47f3a430..f7392951f6 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_schedule.py @@ -15,9 +15,13 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_cost_schedule(file, cost_schedule=None, attributes=None) -> None: +def edit_cost_schedule( + file: ifcopenshell.file, cost_schedule: ifcopenshell.entity_instance, attributes: dict[str, Any] +) -> None: """Edits the attributes of an IfcCostSchedule For more information about the attributes and data types of an @@ -26,7 +30,7 @@ def edit_cost_schedule(file, cost_schedule=None, attributes=None) -> None: :param cost_schedule: The IfcCostSchedule entity you want to edit :type cost_schedule: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value.py index 430b4272aa..a0e74b85af 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value.py @@ -19,9 +19,12 @@ import ifcopenshell import ifcopenshell.util.unit import ifcopenshell.util.element +from typing import Any -def edit_cost_value(file, cost_value=None, attributes=None) -> None: +def edit_cost_value( + file: ifcopenshell.file, cost_value: ifcopenshell.entity_instance, attributes: dict[str, Any] +) -> None: """Edits the attributes of an IfcCostValue For more information about the attributes and data types of an @@ -30,7 +33,7 @@ def edit_cost_value(file, cost_value=None, attributes=None) -> None: :param cost_value: The IfcCostValue entity you want to edit :type cost_value: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value_formula.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value_formula.py index eac443ba40..a9af7572b6 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value_formula.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value_formula.py @@ -22,7 +22,7 @@ import ifcopenshell.util.unit import ifcopenshell.util.element -def edit_cost_value_formula(file, cost_value=None, formula=None) -> None: +def edit_cost_value_formula(file: ifcopenshell.file, cost_value: ifcopenshell.entity_instance, formula: str) -> None: """Sets a cost value based on a formula, similar to formulas in spreadsheets Costs may be made up of many components (e.g. labour, material, waste diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item.py index e52fd655cb..119b22d135 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item.py @@ -21,7 +21,7 @@ import ifcopenshell.api import ifcopenshell.util.element -def remove_cost_item(file, cost_item=None) -> None: +def remove_cost_item(file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance) -> None: """Removes a cost item All associated relationships with the cost item are also removed, diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item_quantity.py index eed3a7adb3..cc7b8c32cb 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item_quantity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item_quantity.py @@ -15,9 +15,12 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell -def remove_cost_item_quantity(file, cost_item=None, physical_quantity=None) -> None: +def remove_cost_item_quantity( + file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, physical_quantity: ifcopenshell.entity_instance +) -> None: """Removes a quantity assigned to a cost item If the quantity is part of a product (e.g. wall), then the quantity will diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_schedule.py index 7b73859bb0..01a9c0e0ad 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_schedule.py @@ -21,7 +21,7 @@ import ifcopenshell.api import ifcopenshell.util.element -def remove_cost_schedule(file, cost_schedule=None) -> None: +def remove_cost_schedule(file: ifcopenshell.file, cost_schedule: ifcopenshell.entity_instance) -> None: """Removes a cost schedule All associated relationships with the cost schedule are also removed, diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_value.py index 757877bf9d..10f4054e93 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_value.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_value.py @@ -15,9 +15,12 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell -def remove_cost_value(file, parent=None, cost_value=None) -> None: +def remove_cost_value( + file: ifcopenshell.file, parent: ifcopenshell.entity_instance, cost_value: ifcopenshell.entity_instance +) -> None: """Removes a cost value The cost value may be assigned either to a cost item, a construction diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py index c7c5fc69fd..a11947c6d8 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py @@ -19,7 +19,9 @@ import ifcopenshell.api -def unassign_cost_item_quantity(file, cost_item=None, products=None) -> None: +def unassign_cost_item_quantity( + file: ifcopenshell.file, cost_item: ifcopenshell.entity_instance, products: list[ifcopenshell.entity_instance] +) -> None: """Removes quantities of a cost item that are calculated on products A cost item may have quantities that are parametrically calculated on diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/add_information.py b/src/ifcopenshell-python/ifcopenshell/api/document/add_information.py index 7754f8cef5..86db04421c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/document/add_information.py +++ b/src/ifcopenshell-python/ifcopenshell/api/document/add_information.py @@ -18,9 +18,12 @@ import ifcopenshell import ifcopenshell.guid +from typing import Optional -def add_information(file, parent=None) -> None: +def add_information( + file: ifcopenshell.file, parent: Optional[ifcopenshell.entity_instance] = None +) -> ifcopenshell.entity_instance: """Adds a new document information to the project An IFC document information is a document associated with the project. diff --git a/src/ifcopenshell-python/ifcopenshell/api/drawing/assign_product.py b/src/ifcopenshell-python/ifcopenshell/api/drawing/assign_product.py index c0758c8145..e620724727 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/drawing/assign_product.py +++ b/src/ifcopenshell-python/ifcopenshell/api/drawing/assign_product.py @@ -21,7 +21,11 @@ import ifcopenshell.api import ifcopenshell.guid -def assign_product(file, relating_product=None, related_object=None) -> None: +def assign_product( + file: ifcopenshell.file, + relating_product: ifcopenshell.entity_instance, + related_object: ifcopenshell.entity_instance, +) -> ifcopenshell.entity_instance: """Associates a product and an object, typically for annotation Warning: this is an experimental API. @@ -104,7 +108,7 @@ def assign_product(file, relating_product=None, related_object=None) -> None: "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file), "RelatedObjects": [settings["related_object"]], "RelatingProduct": settings["relating_product"], - } + }, ) if is_grid_axis: diff --git a/src/ifcopenshell-python/ifcopenshell/api/drawing/edit_text_literal.py b/src/ifcopenshell-python/ifcopenshell/api/drawing/edit_text_literal.py index f1aadc25b0..73ba58a776 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/drawing/edit_text_literal.py +++ b/src/ifcopenshell-python/ifcopenshell/api/drawing/edit_text_literal.py @@ -15,9 +15,13 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_text_literal(file, text_literal=None, attributes=None) -> None: +def edit_text_literal( + file: ifcopenshell.file, text_literal: ifcopenshell.entity_instance, attributes: dict[str, Any] +) -> None: """Edits the attributes of an IfcTextLiteral For more information about the attributes and data types of an @@ -26,7 +30,7 @@ def edit_text_literal(file, text_literal=None, attributes=None) -> None: :param reference: The IfcTextLiteral entity you want to edit :type reference: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/drawing/unassign_product.py b/src/ifcopenshell-python/ifcopenshell/api/drawing/unassign_product.py index 8254bffdce..b0f6ad1085 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/drawing/unassign_product.py +++ b/src/ifcopenshell-python/ifcopenshell/api/drawing/unassign_product.py @@ -21,7 +21,11 @@ import ifcopenshell.api import ifcopenshell.util.element -def unassign_product(file, relating_product=None, related_object=None) -> None: +def unassign_product( + file: ifcopenshell.file, + relating_product: ifcopenshell.entity_instance, + related_object: ifcopenshell.entity_instance, +) -> None: """Unassigns a product and an object (typically an annotation) Smart annotation objects can be associated with products so that they @@ -34,8 +38,8 @@ def unassign_product(file, relating_product=None, related_object=None) -> None: :param related_object: The object (typically IfcAnnotation) that the product is related to :type related_object: ifcopenshell.entity_instance - :return: The created IfcRelAssignsToProduct relationship - :rtype: ifcopenshell.entity_instance + :return: None + :rtype: None Example: @@ -68,4 +72,3 @@ def unassign_product(file, relating_product=None, related_object=None) -> None: related_objects.remove(settings["related_object"]) rel.RelatedObjects = related_objects ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel}) - return rel diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py index 5d571920d4..7abdfb1598 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py +++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py @@ -19,7 +19,7 @@ import ifcopenshell def add_person( - file: ifcopenshell.entity_instance, + file: ifcopenshell.file, identification: str = "HSeldon", family_name: str = "Seldon", given_name: str = "Hari", diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person_and_organisation.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person_and_organisation.py index 7f07c1991c..cf2bdb6507 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person_and_organisation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person_and_organisation.py @@ -19,7 +19,7 @@ import ifcopenshell def add_person_and_organisation( - file: ifcopenshell.entity_instance, + file: ifcopenshell.file, person: ifcopenshell.entity_instance, organisation: ifcopenshell.entity_instance, ) -> ifcopenshell.entity_instance: diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/create_owner_history.py b/src/ifcopenshell-python/ifcopenshell/api/owner/create_owner_history.py index 2b4729897f..fbb35dbc45 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/owner/create_owner_history.py +++ b/src/ifcopenshell-python/ifcopenshell/api/owner/create_owner_history.py @@ -22,7 +22,7 @@ import ifcopenshell.api.owner.settings from typing import Union -def create_owner_history(file: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]: +def create_owner_history(file: ifcopenshell.file) -> Union[ifcopenshell.entity_instance, None]: """Creates a new owner history indicating an element was added Any object in IFC with a unique ID and name (such as physical products, diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/assign_declaration.py b/src/ifcopenshell-python/ifcopenshell/api/project/assign_declaration.py index 322e8a18ad..bffef52943 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/project/assign_declaration.py +++ b/src/ifcopenshell-python/ifcopenshell/api/project/assign_declaration.py @@ -24,7 +24,7 @@ from typing import Union def assign_declaration( - file: ifcopenshell.entity_instance, + file: ifcopenshell.file, definitions: list[ifcopenshell.entity_instance], relating_context: ifcopenshell.entity_instance, ) -> Union[ifcopenshell.entity_instance, None]: @@ -142,6 +142,6 @@ def assign_declaration( "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file), "RelatedDefinitions": list(objects_to_change), "RelatingContext": relating_context, - } + }, ) return declares diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py index 01d5d9b2ea..288adebab5 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py @@ -22,7 +22,7 @@ from typing import Optional, Any, Union def edit_pset( - file: ifcopenshell.entity_instance, + file: ifcopenshell.file, pset: ifcopenshell.entity_instance, name: Optional[str] = None, properties: Optional[dict[str, Any]] = None, diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/add_context_dependent_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/add_context_dependent_unit.py index 5de43a505a..ee37c32f53 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/unit/add_context_dependent_unit.py +++ b/src/ifcopenshell-python/ifcopenshell/api/unit/add_context_dependent_unit.py @@ -15,9 +15,15 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell -def add_context_dependent_unit(file, unit_type="USERDEFINED", name="THINGAMAJIG", dimensions=None) -> None: +def add_context_dependent_unit( + file: ifcopenshell.file, + unit_type: str = "USERDEFINED", + name: str = "THINGAMAJIG", + dimensions: tuple[int, int, int, int, int, int, int] = (0, 0, 0, 0, 0, 0, 0), +) -> ifcopenshell.entity_instance: """Add a new arbitrary unit that can only be interpreted in a project specific context Occasionally the construction industry uses arbitrary units to quantify @@ -51,7 +57,7 @@ def add_context_dependent_unit(file, unit_type="USERDEFINED", name="THINGAMAJIG" # Boxes of things ifcopenshell.api.run("unit.add_context_dependent_unit", model, name="BOXES") """ - settings = {"unit_type": unit_type, "name": name, "dimensions": dimensions or (0, 0, 0, 0, 0, 0, 0)} + settings = {"unit_type": unit_type, "name": name, "dimensions": dimensions} return file.create_entity( "IfcContextDependentUnit", diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/add_monetary_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/add_monetary_unit.py index 7e345b9a7c..4cf9ca6730 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/unit/add_monetary_unit.py +++ b/src/ifcopenshell-python/ifcopenshell/api/unit/add_monetary_unit.py @@ -15,9 +15,10 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell -def add_monetary_unit(file, currency="DOLLARYDOO") -> None: +def add_monetary_unit(file: ifcopenshell.file, currency: str = "DOLLARYDOO") -> ifcopenshell.entity_instance: """Add a new currency Currency units are useful in cost plans to know in what currency the diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_derived_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_derived_unit.py index ed56b80461..a8b3316dbd 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_derived_unit.py +++ b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_derived_unit.py @@ -15,9 +15,11 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_derived_unit(file, unit=None, attributes=None) -> None: +def edit_derived_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None: """Edits the attributes of an IfcDerivedUnit For more information about the attributes and data types of an @@ -26,7 +28,7 @@ def edit_derived_unit(file, unit=None, attributes=None) -> None: :param unit: The IfcDerivedUnit entity you want to edit :type unit: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None """ diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_monetary_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_monetary_unit.py index b4f14f328a..888bbde510 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_monetary_unit.py +++ b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_monetary_unit.py @@ -15,9 +15,11 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_monetary_unit(file, unit=None, attributes=None) -> None: +def edit_monetary_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None: """Edits the attributes of an IfcMonetaryUnit For more information about the attributes and data types of an @@ -26,7 +28,7 @@ def edit_monetary_unit(file, unit=None, attributes=None) -> None: :param unit: The IfcMonetaryUnit entity you want to edit :type unit: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_named_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_named_unit.py index be0384aabb..72cd618839 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_named_unit.py +++ b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_named_unit.py @@ -15,9 +15,11 @@ # # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell +from typing import Any -def edit_named_unit(file, unit=None, attributes=None) -> None: +def edit_named_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None: """Edits the attributes of an IfcNamedUnit Named units include SI units, conversion based units (imperial units), @@ -29,7 +31,7 @@ def edit_named_unit(file, unit=None, attributes=None) -> None: :param unit: The IfcNamedUnit entity you want to edit :type unit: ifcopenshell.entity_instance :param attributes: a dictionary of attribute names and values. - :type attributes: dict, optional + :type attributes: dict :return: None :rtype: None diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/remove_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/remove_unit.py index ae2cd192cb..eb572aa59c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/unit/remove_unit.py +++ b/src/ifcopenshell-python/ifcopenshell/api/unit/remove_unit.py @@ -20,7 +20,7 @@ import ifcopenshell.util.unit import ifcopenshell.util.element -def remove_unit(file, unit=None) -> None: +def remove_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance) -> None: """Remove a unit Be very careful when a unit is removed, as it may mean that previously diff --git a/src/ifcopenshell-python/ifcopenshell/api/void/add_filling.py b/src/ifcopenshell-python/ifcopenshell/api/void/add_filling.py index 9e8d09744d..bdc0422955 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/void/add_filling.py +++ b/src/ifcopenshell-python/ifcopenshell/api/void/add_filling.py @@ -21,7 +21,9 @@ import ifcopenshell.guid import ifcopenshell.util.element -def add_filling(file, opening=None, element=None) -> None: +def add_filling( + file: ifcopenshell.file, opening: ifcopenshell.entity_instance, element: ifcopenshell.entity_instance +) -> ifcopenshell.entity_instance: """Fill an opening with an element Physical elements may have openings in them. For example, a wall might @@ -106,13 +108,13 @@ def add_filling(file, opening=None, element=None) -> None: if fills_voids: if fills_voids[0].RelatingOpeningElement == settings["opening"]: - return + return fills_voids[0] history = fills_voids[0].OwnerHistory file.remove(fills_voids[0]) if history: ifcopenshell.util.element.remove_deep2(file, history) - file.create_entity( + return file.create_entity( "IfcRelFillsElement", GlobalId=ifcopenshell.guid.new(), RelatingOpeningElement=settings["opening"], diff --git a/src/ifcopenshell-python/ifcopenshell/api/void/remove_filling.py b/src/ifcopenshell-python/ifcopenshell/api/void/remove_filling.py index b4c3188672..3cfdd05ce3 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/void/remove_filling.py +++ b/src/ifcopenshell-python/ifcopenshell/api/void/remove_filling.py @@ -20,7 +20,7 @@ import ifcopenshell import ifcopenshell.util.element -def remove_filling(file, element=None) -> None: +def remove_filling(file: ifcopenshell.file, element: ifcopenshell.entity_instance) -> None: """Remove a filling relationship If an element is filling an opening, this removes the relationship such diff --git a/src/ifcopenshell-python/ifcopenshell/api/void/remove_opening.py b/src/ifcopenshell-python/ifcopenshell/api/void/remove_opening.py index 58b7782333..7217fc627d 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/void/remove_opening.py +++ b/src/ifcopenshell-python/ifcopenshell/api/void/remove_opening.py @@ -20,7 +20,7 @@ import ifcopenshell.api import ifcopenshell.util.element -def remove_opening(file: ifcopenshell.entity_instance, opening: ifcopenshell.entity_instance) -> None: +def remove_opening(file: ifcopenshell.file, opening: ifcopenshell.entity_instance) -> None: """Remove an opening Fillings are retained as orphans. Voided elements remain. Openings diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 05ad3fd984..499c1a260e 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -281,11 +281,11 @@ class entity_instance: return entity_instance.walk(is_instance, unwrap, v) - def attribute_type(self, attr: int) -> str: + def attribute_type(self, attr: Union[int, str]) -> str: """Return the data type of a positional attribute of the element - :param attr: The index of the attribute - :type attr: int + :param attr: The index or name of the attribute + :type attr: Union[int, str] :rtype: string """ attr_idx = attr if isinstance(attr, numbers.Integral) else self.wrapped_data.get_argument_index(attr) diff --git a/src/ifcopenshell-python/ifcopenshell/util/placement.py b/src/ifcopenshell-python/ifcopenshell/util/placement.py index 75a1de6265..f8b52b274c 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/placement.py +++ b/src/ifcopenshell-python/ifcopenshell/util/placement.py @@ -19,7 +19,7 @@ import numpy as np import numpy.typing as npt import ifcopenshell -from typing import Literal, Iterable +from typing import Literal, Iterable, Optional MatrixType = npt.NDArray[np.float64] @@ -97,7 +97,7 @@ def get_axis2placement(placement: ifcopenshell.entity_instance) -> MatrixType: return a2p(o, z, x) -def get_local_placement(placement: ifcopenshell.entity_instance) -> MatrixType: +def get_local_placement(placement: Optional[ifcopenshell.entity_instance] = None) -> MatrixType: """Parse a local placement into a 4x4 transformation matrix This is typically used to find the location and rotation of an element. The @@ -118,7 +118,7 @@ def get_local_placement(placement: ifcopenshell.entity_instance) -> MatrixType: matrix = ifcopenshell.util.placement.get_local_placement(placement) :param placement: The IfcLocalPlacement entity - :type placement: ifcopenshell.entity_instance + :type placement: ifcopenshell.entity_instance, optional :return: A 4x4 numpy matrix :rtype: MatrixType """