66)
77
88from python_utils .math import are_equal
9- from python_utils .types_hinting import DictOrObject
9+ from python_utils .types_hinting import T
1010
1111
1212def safe_find (records : Iterable , filter_func : Callable ) -> Optional [Any ]:
@@ -85,7 +85,7 @@ def filter_dicts(records: List[Dict], as_list=True, **filters) -> Union[List[Dic
8585 return filtered_records
8686
8787
88- def filter_objects (objects : List [object ], as_list = True , ** filters ) -> Union [List [object ], Iterable [Dict ]]:
88+ def filter_objects (objects : List [T ], as_list = True , ** filters ) -> Union [List [T ], Iterable [Dict ]]:
8989 """
9090 Pass a list of objects and filters as kwargs to get all filtered records as list or filter obj
9191
@@ -122,7 +122,7 @@ def filter_objects(objects: List[object], as_list=True, **filters) -> Union[List
122122 return filtered_objects
123123
124124
125- def find_object (objects : List [object ], ** filters ) -> Optional [object ]:
125+ def find_object (objects : List [T ], ** filters ) -> Optional [T ]:
126126 """
127127 Pass a list of objects and filters as kwargs to get first occurence record. If no filters
128128 passed return first object in the list
@@ -217,7 +217,7 @@ def get_values(dictionary: Dict, keys: List[Hashable], dtypes: Dict = None) -> D
217217
218218
219219def get_differences (
220- old_data : DictOrObject ,
220+ old_data : Union [ Dict , T ] ,
221221 new_data : Dict ,
222222 skip_keys : List [Hashable ] = None ,
223223 number_precision : int = 6
@@ -438,7 +438,7 @@ class Finder:
438438 }
439439 available_ops = ops .keys ()
440440
441- def __init__ (self , records : List [DictOrObject ]):
441+ def __init__ (self , records : List [Union [ Dict , T ] ]):
442442 self ._records = records
443443
444444 @classmethod
@@ -449,7 +449,7 @@ def _compare(cls, value1: Any, op: str, value2: Any, ignore_types=False) -> bool
449449 return cls .ops [op ](value1 , value2 )
450450
451451 @classmethod
452- def _verify (cls , record : DictOrObject , ignore_types = False , ** checks ) -> bool :
452+ def _verify (cls , record : Union [ Dict , T ] , ignore_types = False , ** checks ) -> bool :
453453 """
454454 Verify that the record fulfills the given checks.
455455
@@ -480,7 +480,7 @@ def _verify(cls, record: DictOrObject, ignore_types=False, **checks) -> bool:
480480 return True
481481
482482 @staticmethod
483- def _get_value (record : DictOrObject , attr : str ) -> Optional [Any ]:
483+ def _get_value (record : Union [ Dict , T ] , attr : str ) -> Optional [Any ]:
484484 """
485485 Get the value of the attribute for the given record. Used to process dicts and objects uniformly.
486486
0 commit comments