Skip to content

Commit 396f7f9

Browse files
committed
fix: solve ImportError,TypeError, and f-string error
Signed-off-by: Zvi Grinberg <[email protected]>
1 parent 5010406 commit 396f7f9

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

src/execution.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import json
1010
import logging
11+
from typing import Union
1112
import uuid
1213
from pathlib import Path
1314
import copy
@@ -493,7 +494,7 @@ def run(self) -> None:
493494
logger.error(f"Unexpected error during execution: {e}", exc_info=True)
494495
raise
495496

496-
def prepare_tests(self, scan_config_override: str|None) -> tuple:
497+
def prepare_tests(self, scan_config_override: Union[str, None]) -> tuple:
497498
# Read scan configuration
498499
scan_config = self.read_scan_config(scan_config_override)
499500

src/integration_tests_execution.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,19 @@
88

99
import json
1010
import logging
11+
from typing import Union
12+
13+
from execution import Execution
14+
from concurrent_executor import ConcurrentExecutor, ExecutionInput
1115

12-
try:
13-
from .execution import Execution
14-
from .concurrent_executor import ConcurrentExecutor, ExecutionInput
15-
except ImportError:
16-
from execution import Execution
17-
from concurrent_executor import ConcurrentExecutor, ExecutionInput
1816

1917
# Integration tests input file with all tests.
2018
INTEGRATION_TESTS_INPUT_FILE = "scan_it.json"
2119

2220
logger = logging.getLogger(__name__)
2321

2422

25-
def create_error_object(error_message: str, scan_id: str , test: dict) -> dict[str, str | int | dict]:
23+
def create_error_object(error_message: str, scan_id: str , test: dict) -> dict[str, Union[str, int, dict]]:
2624
return {
2725
'error': error_message,
2826
'scan_id': scan_id,

src/it_results_interpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def prepare_common_result_fields(self, result: dict, result_index: int):
117117
TEST_NO: result_index,
118118
LANGUAGE: result.get(ECOSYSTEM),
119119
VULN_ID: result.get(VULN_ID),
120-
GIT_REPO: f"{result.get("image_name")}@{result.get("image_tag")}",
120+
GIT_REPO: f"{result.get('image_name')}@{result.get('image_tag')}",
121121
JUSTIFICATION_STATUS: result.get(JUSTIFICATION_STATUS),
122122
JUSTIFICATION_LABEL: result.get(JUSTIFICATION_LABEL),
123123
EXECUTION_DURATION: result.get(EXECUTION_DURATION)

src/main_integration_tests.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@
99
import argparse
1010
import logging
1111
import sys
12-
12+
from integration_tests_execution import IntegrationTestExecution
13+
from it_results_interpreter import IntegrationTestsResultsInterpreter
1314
try:
14-
from .integration_tests_execution import IntegrationTestExecution
15-
from .it_results_interpreter import IntegrationTestsResultsInterpreter
1615
from .config import Configuration, GoogleSheetsConfig, GoogleSheetsManager
1716
from .execution import Execution
1817
from .data_extractor import DataExtractor, ITDataExtractor
1918
from .analysis import Analysis, GoogleSheetsDataLoader
2019
from .cleanup import Cleanup
2120
except ImportError:
22-
from integration_tests_execution import IntegrationTestExecution
23-
from it_results_interpreter import IntegrationTestsResultsInterpreter
2421
from config import Configuration, GoogleSheetsConfig
2522
from execution import Execution
2623
from data_extractor import DataExtractor, ITDataExtractor

0 commit comments

Comments
 (0)