Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
samriddhi99 authored and refeed committed Sep 4, 2024
1 parent 791df63 commit 56d83f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/tirith/core/policy_parameterization.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import re
import pydash


class PydashPathNotFound:
pass


def check_match(string: str, pattern: re.Pattern) -> re.Match:
match_ = re.fullmatch(pattern, string)
return match_
Expand All @@ -14,7 +16,7 @@ def helper(dictionary: dict, var_pattern: re.Pattern, var_dict: dict):
if isinstance(value, str):
match = check_match(value, var_pattern)
if bool(match):
dictionary[key] = pydash.get(var_dict, match.group(1),default=PydashPathNotFound)
dictionary[key] = pydash.get(var_dict, match.group(1), default=PydashPathNotFound)


def replace_vars(policy_dict: dict, var_dict: dict) -> dict:
Expand All @@ -25,13 +27,13 @@ def replace_vars(policy_dict: dict, var_dict: dict) -> dict:
for i in range(len(evaluators)):
match = check_match(evaluators[i]["id"], var_pattern)
if bool(match):
evaluators[i]["id"] = pydash.get(var_dict, match.group(1),default=PydashPathNotFound)
evaluators[i]["id"] = pydash.get(var_dict, match.group(1), default=PydashPathNotFound)

helper(evaluators[i]["condition"], var_pattern, var_dict)
helper(evaluators[i]["provider_args"], var_pattern, var_dict)

match = check_match(policy_dict["eval_expression"], var_pattern)
if bool(match):
policy_dict["eval_expression"] = pydash.get(var_dict, match.group(1),default=PydashPathNotFound)
policy_dict["eval_expression"] = pydash.get(var_dict, match.group(1), default=PydashPathNotFound)

return policy_dict
return policy_dict
1 change: 1 addition & 0 deletions tests/core/test_policy_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from tirith.core.policy_parameterization import replace_vars, PydashPathNotFound


@pytest.fixture
def processed_policy():
var_dict = {
Expand Down

0 comments on commit 56d83f8

Please sign in to comment.