ruff: enable TC — flake8-type-checking (#11368)

## Problem

`TYPE_CHECKING` is used inconsistently across Python tests.

## Summary of changes
- Update `ruff`: 0.7.0 -> 0.11.2
- Enable TC (flake8-type-checking):
https://docs.astral.sh/ruff/rules/#flake8-type-checking-tc
- (auto)fix all new issues
This commit is contained in:
Alexander Bayandin
2025-03-30 20:58:33 +02:00
committed by GitHub
parent db5384e1b0
commit 30a7dd630c
169 changed files with 1263 additions and 888 deletions

View File

@@ -19,7 +19,6 @@ from urllib.parse import urlencode
import allure
import pytest
import zstandard
from psycopg2.extensions import cursor
from typing_extensions import override
from fixtures.common_types import Id, Lsn
@@ -34,6 +33,8 @@ if TYPE_CHECKING:
from collections.abc import Iterable
from typing import IO
from psycopg2.extensions import cursor
from fixtures.common_types import TimelineId
from fixtures.neon_fixtures import PgBin
@@ -512,7 +513,9 @@ def assert_no_errors(log_file: Path, service: str, allowed_errors: list[str]):
for _lineno, error in errors:
log.info(f"not allowed {service} error: {error.strip()}")
assert not errors, f"First log error on {service}: {errors[0]}\nHint: use scripts/check_allowed_errors.sh to test any new allowed_error you add"
assert not errors, (
f"First log error on {service}: {errors[0]}\nHint: use scripts/check_allowed_errors.sh to test any new allowed_error you add"
)
def assert_pageserver_backups_equal(left: Path, right: Path, skip_files: set[str]):
@@ -550,18 +553,18 @@ def assert_pageserver_backups_equal(left: Path, right: Path, skip_files: set[str
left_list, right_list = map(build_hash_list, [left, right])
assert len(left_list) == len(
right_list
), f"unexpected number of files on tar files, {len(left_list)} != {len(right_list)}"
assert len(left_list) == len(right_list), (
f"unexpected number of files on tar files, {len(left_list)} != {len(right_list)}"
)
mismatching: set[str] = set()
for left_tuple, right_tuple in zip(left_list, right_list, strict=False):
left_path, left_hash = left_tuple
right_path, right_hash = right_tuple
assert (
left_path == right_path
), f"file count matched, expected these to be same paths: {left_path}, {right_path}"
assert left_path == right_path, (
f"file count matched, expected these to be same paths: {left_path}, {right_path}"
)
if left_hash != right_hash:
mismatching.add(left_path)