From 9efb1a345565c1925e7da2140eaabe0a3085b144 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 16:12:05 +0000 Subject: [PATCH 1/2] deps: update dependency tests/engine_tests/engine-test-data to v3.7.0 --- .gitmodules | 2 +- tests/engine_tests/engine-test-data | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 1e99b82..c62bff8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "tests/engine_tests/engine-test-data"] path = tests/engine_tests/engine-test-data url = https://github.com/flagsmith/engine-test-data.git - branch = v3.6.0 + branch = v3.7.0 diff --git a/tests/engine_tests/engine-test-data b/tests/engine_tests/engine-test-data index 9307930..4b29dc7 160000 --- a/tests/engine_tests/engine-test-data +++ b/tests/engine_tests/engine-test-data @@ -1 +1 @@ -Subproject commit 9307930e9e64482a35e7d6b254225addb6e44687 +Subproject commit 4b29dc772a764364af2dd504ecefbdf74cf5473f From 756e1568ed39891478911480bbc5648b5d4589c9 Mon Sep 17 00:00:00 2001 From: Zaimwa9 Date: Wed, 6 May 2026 08:58:06 +0200 Subject: [PATCH 2/2] feat: apply rules based on type instead of hardcoded all (#297) --- flag_engine/segments/evaluator.py | 31 +++++++++++++++++-------------- tests/unit/segments/fixtures.py | 1 + 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/flag_engine/segments/evaluator.py b/flag_engine/segments/evaluator.py index 0b8f8fc..65a380b 100644 --- a/flag_engine/segments/evaluator.py +++ b/flag_engine/segments/evaluator.py @@ -236,27 +236,30 @@ def context_matches_rule( ) -> bool: matches_conditions = ( get_matching_function(rule["type"])( - [ - context_matches_condition( - context=context, - condition=condition, - segment_key=segment_key, - ) - for condition in conditions - ] + context_matches_condition( + context=context, + condition=condition, + segment_key=segment_key, + ) + for condition in conditions ) if (conditions := rule.get("conditions")) else True ) - return matches_conditions and all( - context_matches_rule( - context=context, - rule=rule, - segment_key=segment_key, + matches_rules = ( + get_matching_function(rule["type"])( + context_matches_rule( + context=context, + rule=sub_rule, + segment_key=segment_key, + ) + for sub_rule in rules ) - for rule in rule.get("rules") or [] + if (rules := rule.get("rules")) + else True ) + return matches_conditions and matches_rules def context_matches_condition( diff --git a/tests/unit/segments/fixtures.py b/tests/unit/segments/fixtures.py index 934311c..5ea6698 100644 --- a/tests/unit/segments/fixtures.py +++ b/tests/unit/segments/fixtures.py @@ -110,6 +110,7 @@ ], } + segment_conditions_and_nested_rules: SegmentContext = { "key": "6", "name": "segment_multiple_conditions_all_and_nested_rules",