Skip to content

Commit

Permalink
fix test and typing
Browse files Browse the repository at this point in the history
  • Loading branch information
gruebel committed Oct 12, 2023
1 parent 965a4cb commit 4e6053d
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: debug-statements
- repo: https://github.com/PyCQA/flake8
Expand Down Expand Up @@ -33,7 +33,7 @@ repos:
additional_dependencies:
- vistir<0.7.0 # can be removed, when v4.0.0 of pipenv-setup comes out
- repo: https://github.com/seddonym/import-linter # checks the import dependencies between each other
rev: v1.11.1
rev: v1.12.0
hooks:
- id: import-linter
language_version: python3.9
Expand Down
2 changes: 1 addition & 1 deletion checkov/common/bridgecrew/vulnerability_scanning/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from typing import Any, TYPE_CHECKING

from aiomultiprocess import Pool # type:ignore[import]
from aiomultiprocess import Pool # type:ignore[import-untyped]

from checkov.common.bridgecrew.vulnerability_scanning.integrations.package_scanning import PackageScanningIntegration

Expand Down
4 changes: 2 additions & 2 deletions checkov/common/graph/graph_builder/graph_components/blocks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Collection
from typing import Union, Dict, Any, List
from typing import Union, Dict, Any, List, cast

from checkov.common.graph.graph_builder.graph_components.attribute_names import CustomAttributes
from checkov.common.graph.graph_builder.utils import calculate_hash, join_trimmed_strings
Expand Down Expand Up @@ -119,7 +119,7 @@ def get_origin_attributes(self, base_attributes: Dict[str, Any]) -> None:

def get_hash(self) -> str:
attributes_dict = self.get_attribute_dict()
return attributes_dict.get(CustomAttributes.HASH, "")
return cast("str", attributes_dict.get(CustomAttributes.HASH, ""))

def update_attribute(
self,
Expand Down
2 changes: 1 addition & 1 deletion checkov/common/parsers/json/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from json.decoder import WHITESPACE, WHITESPACE_STR, BACKSLASH, STRINGCHUNK, JSONArray # type:ignore[attr-defined] # they are not explicitly exported
from typing import Any, Callable, Pattern, Match

from json.scanner import NUMBER_RE # type:ignore[import] # is not explicitly exported
from json.scanner import NUMBER_RE # type:ignore[import-not-found] # is not explicitly exported

from checkov.common.parsers.node import StrNode, DictNode, ListNode
from checkov.common.parsers.json.errors import NullError, DuplicateError, DecodeError
Expand Down
8 changes: 4 additions & 4 deletions checkov/common/sca/commons.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import logging
from typing import List, Optional, Any
from typing import List, Optional, Any, cast

from checkov.common.output.common import SCADetails

Expand Down Expand Up @@ -39,8 +39,8 @@ def get_package_type(package_name: str, package_version: str, sca_details: SCADe

def get_registry_url(package: dict[str, Any]) -> str:
if "registry" in package:
return package.get("registry", "")
return package.get("registryUrl", "")
return cast("str", package.get("registry", ""))
return cast("str", package.get("registryUrl", ""))


def normalize_twistcli_language(language: str) -> str:
Expand All @@ -52,7 +52,7 @@ def normalize_twistcli_language(language: str) -> str:


def get_package_lines(package: dict[str, Any]) -> list[int] | None:
return package.get("linesNumbers", package.get("lines"))
return cast("list[int] | None", package.get("linesNumbers", package.get("lines")))


def get_record_file_line_range(package: dict[str, Any], file_line_range: list[int] | None) -> list[int]:
Expand Down
4 changes: 2 additions & 2 deletions checkov/kubernetes/image_referencer/base_provider.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import os
from typing import Any
from typing import Any, cast

from checkov.common.graph.graph_builder import CustomAttributes
from checkov.common.images.graph.image_referencer_provider import GraphImageReferencerProvider
Expand Down Expand Up @@ -37,4 +37,4 @@ def extract_images_from_resources(self) -> list[Image]:
return images

def _get_resource_path(self, resource: dict[str, Any]) -> str:
return resource.get(CustomAttributes.FILE_PATH, "")
return cast("str", resource.get(CustomAttributes.FILE_PATH, ""))
2 changes: 1 addition & 1 deletion checkov/terraform/plan_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _get_module_call_resources(module_address: str, root_module_conf: dict[str,
continue
root_module_conf = root_module_conf.get("module_calls", {}).get(module_name, {}).get("module", {})

return root_module_conf.get("resources", [])
return cast("list[dict[str, Any]]", root_module_conf.get("resources", []))


def _get_resource_changes(template: dict[str, Any]) -> dict[str, dict[str, Any]]:
Expand Down
6 changes: 3 additions & 3 deletions tests/common/output/test_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ def test_sca_package_output():
"## Creation Information\n",
"Creator: Tool: checkov\n",
"Creator: Organization: bridgecrew ([email protected])\n",
"Created: 2022-12-24T00:00:00+00:00Z\n",
"Created: 2022-12-24T00:00:00Z\n",
"\n",
"## Package Information\n",
"PackageName: django\n",
"SPDXID: SPDXRef-django\n",
"PackageVersion: 1.2\n",
"PackageFileName: /requirements.txt\n",
"PackageDownloadLocation: NONE\n",
"FilesAnalyzed: True\n",
"FilesAnalyzed: true\n",
"PackageLicenseInfoFromFiles: OSI_BDS\n",
"\n",
"## Package Information\n",
Expand All @@ -102,7 +102,7 @@ def test_sca_package_output():
"PackageVersion: 1.1.1\n",
"PackageFileName: /requirements.txt\n",
"PackageDownloadLocation: NONE\n",
"FilesAnalyzed: True\n",
"FilesAnalyzed: true\n",
"PackageLicenseInfoFromFiles: MIT\n",
"\n",
"\n",
Expand Down

0 comments on commit 4e6053d

Please sign in to comment.