From 543d04162d5e35f1a64e0b5b084c2967c6cab37f Mon Sep 17 00:00:00 2001 From: rahul4732saini Date: Sun, 3 Nov 2024 20:08:39 +0530 Subject: [PATCH] Update `ConditionHandler` class in conditions.py Defined new instance attribute `_logical_method_map` mapping operator names with corresponding evaluation methods. Also updated `__slots__` with the same. --- fise/query/conditions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fise/query/conditions.py b/fise/query/conditions.py index 6c38456..67d677a 100644 --- a/fise/query/conditions.py +++ b/fise/query/conditions.py @@ -268,7 +268,7 @@ class ConditionHandler: query conditions for search and delete operations. """ - __slots__ = "_conditions", "_method_map" + __slots__ = "_conditions", "_method_map", "_logical_method_map" def __init__(self, subquery: list[str], entity: int) -> None: """ @@ -279,6 +279,12 @@ def __init__(self, subquery: list[str], entity: int) -> None: - entity (int): Entity being operated upon. """ + # Maps logical operators with corresponding evaluation methods. + self._logical_method_map: dict[str, Callable[[bool, bool], bool]] = { + "and": self._and, + "or": self._or, + } + # Maps operator notations with corresponding evaluation methods. self._method_map: dict[str, Callable[[Any, Any], bool]] = { ">=": self._ge,