Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Mar 6, 2024
1 parent 3520635 commit 460b2db
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ def _parse_logical_condition(condition: Dict[str, Any]) -> Dict[str, Any]:
msg = f"'conditions' key missing in {condition}"
raise FilterError(msg)

operator = condition["operator"]
if operator not in ["AND", "OR", "NOT"]:
msg = f"Unknown logical operator '{operator}'. Valid operators are: 'AND', 'OR', 'NOT'"
raise FilterError(msg)

# logical conditions can be nested, so we need to parse them recursively
conditions = []
for c in condition["conditions"]:
Expand All @@ -48,6 +43,7 @@ def _parse_logical_condition(condition: Dict[str, Any]) -> Dict[str, Any]:
else:
conditions.append(_parse_logical_condition(c))

operator = condition["operator"]
if operator == "AND":
return {"$and": conditions}
elif operator == "OR":
Expand All @@ -57,6 +53,9 @@ def _parse_logical_condition(condition: Dict[str, Any]) -> Dict[str, Any]:
# we combine $nor and $and to achieve the same effect.
return {"$nor": [{"$and": conditions}]}

msg = f"Unknown logical operator '{operator}'. Valid operators are: 'AND', 'OR', 'NOT'"
raise FilterError(msg)


def _parse_comparison_condition(condition: Dict[str, Any]) -> Dict[str, Any]:
field: str = condition["field"]
Expand Down

0 comments on commit 460b2db

Please sign in to comment.