Skip to content

Commit

Permalink
Mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
bo156 committed Sep 26, 2023
1 parent 03ec02f commit 075e704
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion checkov/common/images/graph/image_referencer_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import itertools
import os
import typing
from abc import abstractmethod
from typing import TYPE_CHECKING, Callable, Any, Mapping, Generator

Expand Down Expand Up @@ -41,6 +42,8 @@ def extract_nodes(self) -> LibraryGraph | None:
return self.extract_nodes_networkx()

def extract_nodes_networkx(self) -> networkx.Graph:
if typing.TYPE_CHECKING:
self.graph_connector = typing.cast(networkx.Graph, self.graph_connector)
resource_nodes = [
node
for node, resource_type in self.graph_connector.nodes(data=CustomAttributes.RESOURCE_TYPE)
Expand All @@ -56,9 +59,11 @@ def extract_nodes_rustworkx(self) -> rustworkx.PyDiGraph[Any, Any]:
if self.resource_type_pred(node, list(self.supported_resource_types))
]

return self.graph_connector.subgraph(resource_nodes) # type: ignore
return self.graph_connector.subgraph(resource_nodes)

def extract_nodes_igraph(self) -> igraph.Graph:
if typing.TYPE_CHECKING:
self.graph_connector = typing.cast(igraph.Graph, self.graph_connector)
resource_nodes = [
node
for node, resource_type in itertools.zip_longest(self.graph_connector.vs['name'],
Expand Down

0 comments on commit 075e704

Please sign in to comment.