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 13aa96f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions 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,9 +42,10 @@ def extract_nodes(self) -> LibraryGraph | None:
return self.extract_nodes_networkx()

def extract_nodes_networkx(self) -> networkx.Graph:
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)
for node, resource_type in graph_connector.nodes(data=CustomAttributes.RESOURCE_TYPE)
if resource_type and resource_type in self.supported_resource_types
]

Expand All @@ -56,13 +58,14 @@ 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:
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'],
self.graph_connector.vs[CustomAttributes.RESOURCE_TYPE])
for node, resource_type in itertools.zip_longest(graph_connector.vs['name'],
graph_connector.vs[CustomAttributes.RESOURCE_TYPE])
if resource_type and resource_type in self.supported_resource_types
]
return self.graph_connector.subgraph(resource_nodes)
Expand Down

0 comments on commit 13aa96f

Please sign in to comment.