From 770e25dbc2ef539cba14a4a216ee97f3d4807052 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 2 Oct 2024 18:24:01 +0500 Subject: [PATCH] typing --- .../ifcopenshell/entity_instance.py | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 1e826fc655..485efc9942 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -25,7 +25,7 @@ import operator import subprocess import sys import time -from typing import Union, Any, Callable, TypeVar, overload +from typing import Union, Any, Callable, TypeVar, overload, Iterable from . import ifcopenshell_wrapper from . import settings @@ -429,7 +429,7 @@ class entity_instance: """ return self.wrapped_data.id() - def __eq__(self, other): + def __eq__(self, other: "entity_instance") -> bool: if not isinstance(self, type(other)): return False elif None in (self.wrapped_data.file, other.wrapped_data.file): @@ -547,22 +547,21 @@ class entity_instance: ) def get_info( - self, include_identifier=True, recursive=False, return_type=dict, ignore=(), scalar_only=False - ) -> dict: + self, + include_identifier: bool = True, + recursive: bool = False, + return_type: Union[type[dict], type] = dict, + ignore: Iterable[str] = (), + scalar_only: bool = False, + ) -> dict[str, Any]: """Return a dictionary of the entity_instance's properties (Python and IFC) and their values. :param include_identifier: Whether or not to include the STEP numerical identifier - :type include_identifier: bool :param recursive: Whether or not to convert referenced IFC elements into dictionaries too. All attributes also apply recursively - :type recursive: bool :param return_type: The return data type to be casted into - :type return_type: dict|list|other :param ignore: A list of attribute names to ignore - :type ignore: set|list :param scalar_only: Filters out all values that are IFC instances - :type scalar_only: bool :returns: A dictionary of properties and their corresponding values - :rtype: dict Example: @@ -622,7 +621,13 @@ class entity_instance: __dict__ = property(get_info) - def get_info_2(self, include_identifier=True, recursive=False, return_type=dict, ignore=()): + def get_info_2( + self, + include_identifier: bool = True, + recursive: bool = False, + return_type: type[dict] = dict, + ignore: Iterable[str] = (), + ) -> dict[str, Any]: """More perfomant version of `.get_info()` but with limited arguments values.\n Method has exactly the same signature as `.get_info()` but it doesn't support getting information non-recursively.