diff --git a/pyproject.toml b/pyproject.toml index 3d05abd9ec2..279d077a695 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,10 @@ max-branches=50 max-nested-blocks=10 max-statements=200 +[tool.isort] +profile = "black" +src_paths = ["src", "tests/ci", "tests/sqllogic"] + [tool.pylint.FORMAT] #ignore-long-lines = (# )??$ diff --git a/tests/ci/artifacts_helper.py b/tests/ci/artifacts_helper.py index 5feca927a96..37abf0bdefb 100644 --- a/tests/ci/artifacts_helper.py +++ b/tests/ci/artifacts_helper.py @@ -10,11 +10,8 @@ from pathlib import Path from shutil import copy2 from typing import List, Optional, Union -# isort: off from github.Commit import Commit -# isort: on - from build_download_helper import download_build_with_progress from commit_status_helper import post_commit_status from compress_files import SUFFIX, compress_fast, decompress_fast diff --git a/tests/ci/build_download_helper.py b/tests/ci/build_download_helper.py index d540552f768..0f6c8e5aa8a 100644 --- a/tests/ci/build_download_helper.py +++ b/tests/ci/build_download_helper.py @@ -8,11 +8,8 @@ import time from pathlib import Path from typing import Any, Callable, List, Optional, Union -# isort: off import requests -# isort: on - import get_robot_token as grt # we need an updated ROBOT_TOKEN from ci_config import CI_CONFIG diff --git a/tests/ci/build_report_check.py b/tests/ci/build_report_check.py index 48640f15ac0..fba60fb2079 100644 --- a/tests/ci/build_report_check.py +++ b/tests/ci/build_report_check.py @@ -139,7 +139,8 @@ def main(): additional_files=[report_path], ).dump() - if summary_status == ERROR: + # We should fail the report job to rerun it in the following attempts + if summary_status != SUCCESS: sys.exit(1) diff --git a/tests/ci/commit_status_helper.py b/tests/ci/commit_status_helper.py index bda2db13991..42a298f340f 100644 --- a/tests/ci/commit_status_helper.py +++ b/tests/ci/commit_status_helper.py @@ -9,7 +9,6 @@ from dataclasses import asdict, dataclass from pathlib import Path from typing import Dict, List, Optional, Union -# isort: off from github import Github from github.Commit import Commit from github.CommitStatus import CommitStatus @@ -18,8 +17,6 @@ from github.GithubObject import NotSet from github.IssueComment import IssueComment from github.Repository import Repository -# isort: on - from ci_config import CHECK_DESCRIPTIONS, REQUIRED_CHECKS, CheckDescription from env_helper import GITHUB_REPOSITORY, GITHUB_RUN_URL, TEMP_PATH from pr_info import SKIP_MERGEABLE_CHECK_LABEL, PRInfo diff --git a/tests/ci/compatibility_check.py b/tests/ci/compatibility_check.py index 5e980660749..e7fee827320 100644 --- a/tests/ci/compatibility_check.py +++ b/tests/ci/compatibility_check.py @@ -8,11 +8,8 @@ import sys from pathlib import Path from typing import List, Tuple -# isort: off from pip._vendor.packaging.version import Version -# isort: on - from build_download_helper import download_builds_filter from docker_images_helper import DockerImage, get_docker_image, pull_image from env_helper import REPORT_PATH, TEMP_PATH diff --git a/tests/ci/docker_images_check.py b/tests/ci/docker_images_check.py index b04a3975545..786a529e0a9 100644 --- a/tests/ci/docker_images_check.py +++ b/tests/ci/docker_images_check.py @@ -8,11 +8,8 @@ import time from pathlib import Path from typing import List, Optional, Tuple -# isort: off from github import Github -# isort: on - from clickhouse_helper import ClickHouseHelper, prepare_tests_results_for_clickhouse from commit_status_helper import format_description, get_commit, post_commit_status from docker_images_helper import DockerImageData, docker_login, get_images_oredered_list @@ -225,9 +222,11 @@ def main(): parent_version = ( None if not image.parent - else image_tags[image.parent] - if not args.suffix - else f"{image_tags[image.parent]}-{args.suffix}" + else ( + image_tags[image.parent] + if not args.suffix + else f"{image_tags[image.parent]}-{args.suffix}" + ) ) res = process_single_image( diff --git a/tests/ci/docker_manifests_merge.py b/tests/ci/docker_manifests_merge.py index 3c122545735..6c6a88330ea 100644 --- a/tests/ci/docker_manifests_merge.py +++ b/tests/ci/docker_manifests_merge.py @@ -8,11 +8,8 @@ import subprocess import sys from typing import List, Tuple -# isort: off from github import Github -# isort: on - from clickhouse_helper import ClickHouseHelper, prepare_tests_results_for_clickhouse from commit_status_helper import format_description, get_commit, post_commit_status from docker_images_helper import docker_login, get_images_oredered_list diff --git a/tests/ci/finish_check.py b/tests/ci/finish_check.py index eebc846f4b1..2f85785099a 100644 --- a/tests/ci/finish_check.py +++ b/tests/ci/finish_check.py @@ -1,11 +1,8 @@ #!/usr/bin/env python3 import logging -# isort: off from github import Github -# isort: on - from commit_status_helper import ( CI_STATUS_NAME, get_commit, diff --git a/tests/ci/merge_pr.py b/tests/ci/merge_pr.py index cc92fe4f42c..450ece62d4b 100644 --- a/tests/ci/merge_pr.py +++ b/tests/ci/merge_pr.py @@ -9,13 +9,10 @@ from os import getenv from pprint import pformat from typing import Dict, List -# isort: off from github.PaginatedList import PaginatedList from github.PullRequestReview import PullRequestReview from github.WorkflowRun import WorkflowRun -# isort: on - from commit_status_helper import get_commit_filtered_statuses from get_robot_token import get_best_robot_token from github_helper import GitHub, NamedUser, PullRequest, Repository diff --git a/tests/ci/performance_comparison_check.py b/tests/ci/performance_comparison_check.py index c238fbae603..0c779b515bd 100644 --- a/tests/ci/performance_comparison_check.py +++ b/tests/ci/performance_comparison_check.py @@ -9,11 +9,8 @@ import sys import traceback from pathlib import Path -# isort: off from github import Github -# isort: on - from build_download_helper import download_builds_filter from ci_config import CI_CONFIG from clickhouse_helper import get_instance_id, get_instance_type diff --git a/tests/ci/pr_info.py b/tests/ci/pr_info.py index ddf59c49e1f..ce48c0fa6b3 100644 --- a/tests/ci/pr_info.py +++ b/tests/ci/pr_info.py @@ -6,12 +6,8 @@ import re from typing import Dict, List, Set, Union from urllib.parse import quote -# isort: off -# for some reason this line moves to the end from unidiff import PatchSet # type: ignore -# isort: on - from build_download_helper import get_gh_api from env_helper import ( GITHUB_EVENT_PATH, diff --git a/tests/ci/run_check.py b/tests/ci/run_check.py index 6187656983e..65435ba98bd 100644 --- a/tests/ci/run_check.py +++ b/tests/ci/run_check.py @@ -3,11 +3,9 @@ import logging import sys from typing import Tuple -# isort: off from github import Github -# isort: on - +from cherry_pick import Labels from commit_status_helper import ( CI_STATUS_NAME, create_ci_report, @@ -26,7 +24,6 @@ from lambda_shared_package.lambda_shared.pr import ( ) from pr_info import PRInfo from report import FAILURE, PENDING, SUCCESS -from cherry_pick import Labels TRUSTED_ORG_IDS = { 54801242, # clickhouse diff --git a/tests/sqllogic/runner.py b/tests/sqllogic/runner.py index 2e8e098a099..c4eb0574481 100755 --- a/tests/sqllogic/runner.py +++ b/tests/sqllogic/runner.py @@ -10,11 +10,8 @@ import multiprocessing import os from functools import reduce -# isort: off from deepdiff import DeepDiff # pylint:disable=import-error; for style check -# isort: on - from connection import Engines, default_clickhouse_odbc_conn_str, setup_connection from test_runner import RequestType, Status, TestRunner diff --git a/tests/sqllogic/test_parser.py b/tests/sqllogic/test_parser.py index 648fa9f6bf6..c0abcaecd25 100755 --- a/tests/sqllogic/test_parser.py +++ b/tests/sqllogic/test_parser.py @@ -7,14 +7,10 @@ from functools import reduce from hashlib import md5 from itertools import chain -# isort: off # pylint:disable=import-error; for style check import sqlglot from sqlglot.expressions import ColumnDef, PrimaryKeyColumnConstraint -# pylint:enable=import-error; for style check -# isort: on - from exceptions import ( DataResultDiffer, Error, @@ -23,6 +19,9 @@ from exceptions import ( QueryExecutionError, ) +# pylint:enable=import-error; for style check + + logger = logging.getLogger("parser") logger.setLevel(logging.DEBUG) @@ -474,9 +473,11 @@ class QueryResult: f"values_count: {self.values_count}" if self.values_count else "", f"data_hash: {self.data_hash}" if self.data_hash else "", f"exception: {self.exception}" if self.exception else "", - f"hash_threshold: {self.hash_threshold}" - if self.hash_threshold - else "", + ( + f"hash_threshold: {self.hash_threshold}" + if self.hash_threshold + else "" + ), ] if x )