Addressed comments in the PR.

This commit is contained in:
julio.oliveira 2024-01-26 16:38:24 -03:00
parent b14c447fcf
commit 8998a34b02

View File

@ -134,15 +134,11 @@ class ConditionSet:
if type(ruleset) is not dict:
raise ValueError(f"Ruleset must be a dictionary, not {type(ruleset)}.")
self.logic = None
# If logic type use it, else return the ruleset
if len(ruleset) == 1:
logic = list(ruleset.keys())[0]
if logic not in (AND, OR):
self.logic = (list(ruleset.keys())[0]).lower()
if self.logic not in (AND, OR):
raise ValueError(
f"Invalid logic type: {logic} (must be '{AND}' or '{OR}'). Please check documentation.")
self.logic = logic.lower()
f"Invalid logic type: {self.logic} (must be '{AND}' or '{OR}'). Please check documentation.")
# Compile the set of Conditions
self.conditions = [
@ -151,6 +147,7 @@ class ConditionSet:
]
else:
try:
self.logic = None
self.conditions = [Condition(**ruleset)]
except TypeError:
raise ValueError(f"Incorrect key(s) informed. Please check documentation.")