gh-109413: Enable mypy's `disallow_any_generics` setting when checking `libregrtest` (#127033)

This commit is contained in:
sobolevn 2024-11-19 22:41:59 +03:00 committed by GitHub
parent 8da9920a80
commit 824afbf548
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 4 deletions

View File

@ -15,7 +15,6 @@ strict = True
# Various stricter settings that we can't yet enable # Various stricter settings that we can't yet enable
# Try to enable these in the following order: # Try to enable these in the following order:
disallow_any_generics = False
disallow_incomplete_defs = False disallow_incomplete_defs = False
disallow_untyped_calls = False disallow_untyped_calls = False
disallow_untyped_defs = False disallow_untyped_defs = False

View File

@ -1,5 +1,6 @@
import sys import sys
import trace import trace
from typing import TYPE_CHECKING
from .runtests import RunTests from .runtests import RunTests
from .result import State, TestResult, TestStats, Location from .result import State, TestResult, TestStats, Location
@ -7,6 +8,9 @@ from .utils import (
StrPath, TestName, TestTuple, TestList, FilterDict, StrPath, TestName, TestTuple, TestList, FilterDict,
printlist, count, format_duration) printlist, count, format_duration)
if TYPE_CHECKING:
from xml.etree.ElementTree import Element
# Python uses exit code 1 when an exception is not caught # Python uses exit code 1 when an exception is not caught
# argparse.ArgumentParser.error() uses exit code 2 # argparse.ArgumentParser.error() uses exit code 2
@ -34,7 +38,7 @@ class TestResults:
self.test_times: list[tuple[float, TestName]] = [] self.test_times: list[tuple[float, TestName]] = []
self.stats = TestStats() self.stats = TestStats()
# used by --junit-xml # used by --junit-xml
self.testsuite_xml: list = [] self.testsuite_xml: list['Element'] = []
# used by -T with -j # used by -T with -j
self.covered_lines: set[Location] = set() self.covered_lines: set[Location] = set()

View File

@ -28,7 +28,7 @@ class JsonFile:
file: int | None file: int | None
file_type: str file_type: str
def configure_subprocess(self, popen_kwargs: dict) -> None: def configure_subprocess(self, popen_kwargs: dict[str, Any]) -> None:
match self.file_type: match self.file_type:
case JsonFileType.UNIX_FD: case JsonFileType.UNIX_FD:
# Unix file descriptor # Unix file descriptor

View File

@ -20,7 +20,7 @@ NEED_TTY = {
def create_worker_process(runtests: WorkerRunTests, output_fd: int, def create_worker_process(runtests: WorkerRunTests, output_fd: int,
tmp_dir: StrPath | None = None) -> subprocess.Popen: tmp_dir: StrPath | None = None) -> subprocess.Popen[str]:
worker_json = runtests.as_json() worker_json = runtests.as_json()
cmd = runtests.create_python_cmd() cmd = runtests.create_python_cmd()