diff --git a/c2c/template/__init__.py b/c2c/template/__init__.py index c640b3d..d3a23b0 100644 --- a/c2c/template/__init__.py +++ b/c2c/template/__init__.py @@ -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: @@ -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] @@ -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 @@ -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 @@ -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 @@ -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