From ec34065e6fea12dde46ecae39097b82d72f55ba5 Mon Sep 17 00:00:00 2001 From: Ahmed Nafies Date: Fri, 2 Feb 2024 00:53:29 +0100 Subject: [PATCH] refactor: refactors --- src/rules_engine/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rules_engine/__init__.py b/src/rules_engine/__init__.py index c1802de..790f7c0 100644 --- a/src/rules_engine/__init__.py +++ b/src/rules_engine/__init__.py @@ -43,16 +43,17 @@ def __init__(self, *rules: Rule) -> None: def run(self, *args: Any, **kwargs: Any) -> Any: for rule in self.rules: if rule.condition(*args, **kwargs): - return Result(value=rule.action(*args, **kwargs), message=rule.message) + return Result(rule.action(*args, **kwargs), rule.message) raise NoMatch def run_all(self, *args: Any, **kwargs: Any) -> list: results = [ - Result(value=rule.action(*args, **kwargs), message=rule.message) + Result(rule.action(*args, **kwargs), rule.message) for rule in self.rules if rule.condition(*args, **kwargs) ] + if not results: raise NoMatch return results