diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/add_reference.py b/src/ifcopenshell-python/ifcopenshell/api/document/add_reference.py index 47af28b089..39cdb109d6 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/document/add_reference.py +++ b/src/ifcopenshell-python/ifcopenshell/api/document/add_reference.py @@ -16,9 +16,11 @@ # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell + class Usecase: - def __init__(self, file, information=None): + def __init__(self, file: ifcopenshell.file, information: ifcopenshell.entity_instance): """Creates a new reference to a document to assign to products A document may be associated with physical products, tasks, cost items, @@ -65,7 +67,7 @@ class Usecase: self.file = file self.settings = {"information": information} - def execute(self): + def execute(self) -> ifcopenshell.entity_instance: if self.file.schema == "IFC2X3": reference = self.file.create_entity("IfcDocumentReference") if self.settings["information"]: diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/remove_reference.py b/src/ifcopenshell-python/ifcopenshell/api/document/remove_reference.py index 3a73f692bb..6eee90fb4d 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/document/remove_reference.py +++ b/src/ifcopenshell-python/ifcopenshell/api/document/remove_reference.py @@ -21,7 +21,7 @@ import ifcopenshell.util.element class Usecase: - def __init__(self, file, reference=None): + def __init__(self, file: ifcopenshell.file, reference: ifcopenshell.entity_instance): """Remove a document reference All associations with objects are removed. @@ -42,7 +42,7 @@ class Usecase: self.file = file self.settings = {"reference": reference} - def execute(self): + def execute(self) -> None: for rel in self.settings["reference"].DocumentRefForObjects or []: history = rel.OwnerHistory self.file.remove(rel) diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/add_reference.py b/src/ifcopenshell-python/ifcopenshell/api/library/add_reference.py index 1ac3f87eb9..0a109b2118 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/library/add_reference.py +++ b/src/ifcopenshell-python/ifcopenshell/api/library/add_reference.py @@ -16,9 +16,11 @@ # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell + class Usecase: - def __init__(self, file, library=None): + def __init__(self, file: ifcopenshell.file, library: ifcopenshell.entity_instance): """Adds a new reference to a library A library represents an external data source, such as a database, @@ -54,7 +56,7 @@ class Usecase: "library": library, } - def execute(self): + def execute(self) -> ifcopenshell.entity_instance: if self.file.schema == "IFC2X3": reference = self.file.createIfcLibraryReference() references = list(self.settings["library"].LibraryReference or []) diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/remove_reference.py b/src/ifcopenshell-python/ifcopenshell/api/library/remove_reference.py index c1b15847fc..9a5851827a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/library/remove_reference.py +++ b/src/ifcopenshell-python/ifcopenshell/api/library/remove_reference.py @@ -21,7 +21,7 @@ import ifcopenshell.util.element class Usecase: - def __init__(self, file, reference=None): + def __init__(self, file: ifcopenshell.file, reference: ifcopenshell.entity_instance): """Removes a library reference Any products which have relationships to this reference will not be @@ -44,7 +44,7 @@ class Usecase: self.file = file self.settings = {"reference": reference} - def execute(self): + def execute(self) -> None: for rel in self.settings["reference"].LibraryRefForObjects: history = rel.OwnerHistory self.file.remove(rel) diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py b/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py index 3d4c317df8..8599c00472 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py @@ -18,10 +18,17 @@ import ifcopenshell import ifcopenshell.api +from typing import Optional class Usecase: - def __init__(self, file, ifc_class="IfcBuildingElementProxy", predefined_type=None, name=None): + def __init__( + self, + file: ifcopenshell.file, + ifc_class: str = "IfcBuildingElementProxy", + predefined_type: Optional[str] = None, + name: Optional[str] = None, + ): """Create a new rooted product This is a critical function used to create almost any rooted product or @@ -70,7 +77,7 @@ class Usecase: "name": name, } - def execute(self): + def execute(self) -> ifcopenshell.entity_instance: element = self.file.create_entity( self.settings["ifc_class"], **{ diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py b/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py index 43faafcf23..51fe9516d5 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py +++ b/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py @@ -21,7 +21,7 @@ import ifcopenshell.util.element class Usecase: - def __init__(self, file: ifcopenshell.entity_instance, product: ifcopenshell.entity_instance): + def __init__(self, file: ifcopenshell.file, product: ifcopenshell.entity_instance): """Removes a product This is effectively a smart delete function that not only removes a diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/add_system.py b/src/ifcopenshell-python/ifcopenshell/api/system/add_system.py index 8926b49333..0fdf9992d7 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/system/add_system.py +++ b/src/ifcopenshell-python/ifcopenshell/api/system/add_system.py @@ -21,7 +21,7 @@ import ifcopenshell.api class Usecase: - def __init__(self, file: ifcopenshell.entity_instance, ifc_class: str = "IfcDistributionSystem"): + def __init__(self, file: ifcopenshell.file, ifc_class: str = "IfcDistributionSystem"): """Add a new distribution system A distribution system is a group of distribution elements, like ducts, diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/unassign_system.py b/src/ifcopenshell-python/ifcopenshell/api/system/unassign_system.py index 121939a251..b402407038 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/system/unassign_system.py +++ b/src/ifcopenshell-python/ifcopenshell/api/system/unassign_system.py @@ -24,7 +24,7 @@ import ifcopenshell.util.element class Usecase: def __init__( self, - file: ifcopenshell.entity_instance, + file: ifcopenshell.file, products: list[ifcopenshell.entity_instance], system: ifcopenshell.entity_instance, ): diff --git a/src/ifcpatch/ifcpatch/recipes/ExtractElements.py b/src/ifcpatch/ifcpatch/recipes/ExtractElements.py index 323716bedb..b2660a9d29 100644 --- a/src/ifcpatch/ifcpatch/recipes/ExtractElements.py +++ b/src/ifcpatch/ifcpatch/recipes/ExtractElements.py @@ -20,10 +20,11 @@ import ifcopenshell import ifcopenshell.api import ifcopenshell.util.selector from typing import Union +from logging import Logger class Patcher: - def __init__(self, src, file, logger, query: str = "IfcWall"): + def __init__(self, src: str, file: ifcopenshell.file, logger: Logger, query: str = "IfcWall"): """Extract certain elements into a new model Extract a subset of elements from an existing IFC data set and save it diff --git a/src/ifcpatch/ifcpatch/recipes/MergeDuplicateTypes.py b/src/ifcpatch/ifcpatch/recipes/MergeDuplicateTypes.py index f2461652b7..d30966d409 100644 --- a/src/ifcpatch/ifcpatch/recipes/MergeDuplicateTypes.py +++ b/src/ifcpatch/ifcpatch/recipes/MergeDuplicateTypes.py @@ -19,10 +19,11 @@ import ifcopenshell import ifcopenshell.api import ifcopenshell.util.element +from logging import Logger class Patcher: - def __init__(self, src, file, logger, attribute="Tag"): + def __init__(self, src: str, file: ifcopenshell.file, logger: Logger, attribute: str = "Tag"): """Merge duplicate element types via the Tag or another attribute Revit is notorious for creating many duplicate element types. Element @@ -78,7 +79,9 @@ class Patcher: else: keys[getattr(element_type, key)] = element_type - def assign_type(self, related_object, relating_type): + def assign_type( + self, related_object: ifcopenshell.entity_instance, relating_type: ifcopenshell.entity_instance + ) -> None: # This is basically a portion of the type.assign_type API which only # affects the IfcRelDefinesByType relationship. To be conservative, we # don't use the API directly since that would do other things like