Skip to content

Commit

Permalink
Apply pre-commit fix
Browse files Browse the repository at this point in the history
From the artifact of the previous workflow run
  • Loading branch information
geo-ghci-int[bot] committed Dec 2, 2024
1 parent fed0754 commit 0aaf76c
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions c2c/template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def transform_path(
"The key '%s' in '%s' is not present in: [%s]",
key,
current_path,
", ".join([f"'{k}'" for k in value.keys()]),
", ".join([f"'{k}'" for k in value]),
)
else:
if len(path) == 1:
Expand Down Expand Up @@ -231,7 +231,7 @@ def format_walker(

elif isinstance(current_vars, dict):
skip = []
for key in current_vars.keys():
for key in current_vars:
if path is None:
current_path = key
current_path_list = [key]
Expand Down Expand Up @@ -592,9 +592,7 @@ def __call__(self, expression: str, current_path: str) -> Value: # type: ignore
try:
return cast(Value, eval(expression, globs)) # nosec # pylint: disable=eval-used
except Exception: # pragma: nocover # pylint: disable=broad-except
error = "When evaluating {} expression '{}' in '{}' as Python:\n{}".format(
var_name, expression, current_path, traceback.format_exc()
)
error = f"When evaluating {var_name} expression '{expression}' in '{current_path}' as Python:\n{traceback.format_exc()}"
LOG.error(error)
if interpreter.get("ignore_error", False):
return "ERROR: " + error
Expand Down Expand Up @@ -626,9 +624,7 @@ def __call__(self, value: str, current_path: str) -> Value:
try:
return cast(dict[str, Any], json.loads(value))
except ValueError as exception: # pragma: nocover
error = "When evaluating {} expression '{}' in '{}' as JSON: {}".format(
key, value, current_path, exception
)
error = f"When evaluating {key} expression '{value}' in '{current_path}' as JSON: {exception}"
LOG.error(error)
if interpreter.get("ignore_error", False):
return "ERROR: " + error
Expand All @@ -643,9 +639,7 @@ def __call__(self, value: str, current_path: str) -> Value:
try:
return cast(dict[str, Any], yaml.safe_load(value))
except ParserError as exception: # pragma: nocover
error = "When evaluating {} expression '{}' in '{}' as YAML: {}".format(
key, value, current_path, exception
)
error = f"When evaluating {key} expression '{value}' in '{current_path}' as YAML: {exception}"
LOG.error(error)
if self.interpreter.get("ignore_error", False):
return "ERROR: " + error
Expand Down Expand Up @@ -684,9 +678,7 @@ def __call__(self, value: str, current_path: str) -> Value: # type: ignore
try:
return cast(Value, eval(expression, globs)) # nosec # pylint: disable=eval-used
except ValueError as exception: # pragma: nocover
error = "When interpreting the expression '{}' in '{}': {}".format(
expression, current_path, exception
)
error = f"When interpreting the expression '{expression}' in '{current_path}': {exception}"
LOG.error(error)
if ignore_error:
return "ERROR: " + error
Expand Down

0 comments on commit 0aaf76c

Please sign in to comment.