diff --git a/checkov/terraform/runner.py b/checkov/terraform/runner.py index ae3cebb0660..81763cba964 100644 --- a/checkov/terraform/runner.py +++ b/checkov/terraform/runner.py @@ -3,7 +3,7 @@ import dataclasses import logging import os -from typing import Any, TYPE_CHECKING +from typing import Any, TYPE_CHECKING, Optional from typing_extensions import TypeAlias # noqa[TC002] @@ -56,7 +56,7 @@ def __init__( graph_manager: TerraformGraphManager | None = None, ) -> None: super().__init__(parser, db_connector, external_registries, source, graph_class, graph_manager) - self.all_graphs: list[tuple[LibraryGraph, str]] = [] + self.all_graphs: list[tuple[LibraryGraph, Optional[str]]] = [] def run( self, @@ -73,7 +73,7 @@ def run( report = Report(self.check_type) parsing_errors: dict[str, Exception] = {} self.load_external_checks(external_checks_dir) - local_graphs = None + local_graphs: Optional[list[tuple[Optional[str], Optional[TerraformLocalGraph]]]] = None if self.context is None or self.definitions is None or self.breadcrumbs is None: self.definitions = {} logging.info("Scanning root folder and producing fresh tf_definitions and context") @@ -108,7 +108,7 @@ def run( create_graph=CHECKOV_CREATE_GRAPH, ) # Make graph a list to allow single processing method for all cases - local_graphs = [('', single_graph)] + local_graphs = [(None, single_graph)] elif files: files = [os.path.abspath(file) for file in files] root_folder = os.path.split(os.path.commonprefix(files))[0] @@ -121,7 +121,7 @@ def run( ) else: # local_graph needs to be a list to allow supporting multi graph - local_graphs = [('', self.graph_manager.build_graph_from_definitions(self.definitions))] + local_graphs = [(None, self.graph_manager.build_graph_from_definitions(self.definitions))] else: raise Exception("Root directory was not specified, files were not specified") @@ -190,7 +190,7 @@ def parse_file(file: str) -> tuple[str, dict[str, Any] | None, dict[str, Excepti parsing_errors.update(file_parsing_errors) def _update_definitions_and_breadcrumbs( - self, local_graphs: list[tuple[str, TerraformLocalGraph]], report: Report, root_folder: str + self, local_graphs: list[tuple[Optional[str], TerraformLocalGraph]], report: Report, root_folder: str ) -> None: self.definitions = {} self.breadcrumbs = {}