From f1f4fd95616529264ebdf8eb78ec7f2b8a7aa614 Mon Sep 17 00:00:00 2001 From: barryyosi-panw Date: Sun, 8 Dec 2024 17:40:29 +0200 Subject: [PATCH] pre-commit --- .../commands/pre_commit/pre_commit_command.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/demisto_sdk/commands/pre_commit/pre_commit_command.py b/demisto_sdk/commands/pre_commit/pre_commit_command.py index 0009aed29a8..de33fcdd483 100644 --- a/demisto_sdk/commands/pre_commit/pre_commit_command.py +++ b/demisto_sdk/commands/pre_commit/pre_commit_command.py @@ -119,7 +119,6 @@ def run_hook( verbose: bool = False, stdout: Optional[int] = subprocess.PIPE, json_output_path: Optional[Path] = None, - ) -> int: """This function runs the pre-commit process and waits until finished. We run this function in multithread. @@ -141,7 +140,7 @@ def run_hook( verbose, stdout, command=["run", "-a", hook_id], - json_output_path=json_output_path + json_output_path=json_output_path, ) if process.stdout: @@ -176,7 +175,7 @@ def _run_pre_commit_process( command = ["run", "-a"] output = subprocess.PIPE if json_output_path else stdout - logger.debug(f'_run_pre_commit_process {json_output_path=}') + logger.debug(f"_run_pre_commit_process {json_output_path=}") return subprocess.run( list( filter( @@ -235,7 +234,7 @@ def run( precommit_env, verbose, command=["install-hooks"], - json_output_path=json_output_path + json_output_path=json_output_path, ) num_processes = cpu_count() @@ -362,7 +361,11 @@ def prepare_and_run( ) return ret_val ret_val = PreCommitRunner.run( - pre_commit_context, precommit_env, verbose, show_diff_on_failure, json_output_path + pre_commit_context, + precommit_env, + verbose, + show_diff_on_failure, + json_output_path, ) return ret_val @@ -416,15 +419,18 @@ def group_by_language( for integration_script_paths in more_itertools.chunked_even( integrations_scripts_mapping.keys(), INTEGRATIONS_BATCH ): - - disable_multiprocessing = os.getenv('DEMISTO_SDK_DISABLE_MULTIPROCESSING', 'false').lower() in ['true', 'yes''1'] + disable_multiprocessing = os.getenv( + "DEMISTO_SDK_DISABLE_MULTIPROCESSING", "false" + ).lower() in ["true", "yes", "1"] if disable_multiprocessing: # Run sequentially content_items = map(BaseContent.from_path, integration_script_paths) else: # Use multiprocessing with multiprocessing.Pool(processes=cpu_count()) as pool: - content_items = pool.map(BaseContent.from_path, integration_script_paths) + content_items = pool.map( + BaseContent.from_path, integration_script_paths + ) for content_item in content_items: if isinstance(content_item, IntegrationScript): @@ -623,7 +629,7 @@ def pre_commit_manager( show_diff_on_failure, exclude_files, dry_run, - json_output_path + json_output_path, )