From 94cb282c773f0d57ce595fb9e6a60c4dfcd3f226 Mon Sep 17 00:00:00 2001 From: Rongrong Date: Thu, 18 Jun 2026 00:25:19 +0800 Subject: [PATCH] rules: Fix last_result not passed among chained rules A previous refactor accidentally broke chained rules that rely on the result chaining, so fix it. With it fixed, some rule examples from docs/rules.md work properly again, yay! --- - Feature: THUMB WHEEL - Rule: [ Modifiers: Control, Test: thumb_wheel_up, MouseScroll: [-2, 0] ] - Rule: - Modifiers: Control - Test: thumb_wheel_down - MouseScroll: [-2, 0] - Rule: [ Or: [ Test: thumb_wheel_up, Test: thumb_wheel_down ], MouseScroll: [-1, 0] ] ... --- - Feature: LOWRES WHEEL - Rule: [ Or: [ Test: lowres_wheel_up, Test: lowres_wheel_down ], MouseScroll: [0, 2] ] ... Fixes: 46366b243012 ("Fix warnings from automatic code inspections") Signed-off-by: Rongrong --- lib/logitech_receiver/diversion.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py index 7c14e3fb..670fd739 100644 --- a/lib/logitech_receiver/diversion.py +++ b/lib/logitech_receiver/diversion.py @@ -481,14 +481,13 @@ class RuleComponent: def _evaluate(components, feature, notification: HIDPPNotification, device, result) -> Any: - res = True for component in components: - res = component.evaluate(feature, notification, device, result) - if not isinstance(component, Action) and res is None: + result = component.evaluate(feature, notification, device, result) + if not isinstance(component, Action) and result is None: return None - if isinstance(component, Condition) and not res: - return res - return res + if isinstance(component, Condition) and not result: + return result + return result class Rule(RuleComponent):