RuleSet: remove irrelevant rules after dependecies have been checked

This commit is contained in:
Yacine Elhamer
2023-07-27 12:44:07 +01:00
parent 97c878db22
commit 44c5e96cf0

View File

@@ -1218,11 +1218,6 @@ class RuleSet:
):
super().__init__()
if rules_filter_func:
# this allows for filtering the ruleset based on
# the execution context (static or dynamic)
rules = list(filter(rules_filter_func, rules))
ensure_rules_are_unique(rules)
# in the next step we extract subscope rules,
@@ -1237,6 +1232,11 @@ class RuleSet:
ensure_rule_dependencies_are_met(rules)
if rules_filter_func:
# this allows for filtering the ruleset based on
# the execution context (static or dynamic)
rules = list(filter(rules_filter_func, rules))
if len(rules) == 0:
raise InvalidRuleSet("no rules selected")