]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109413: Enable mypy's `disallow_any_generics` setting when checking `libregrtest...
authorsobolevn <mail@sobolevn.me>
Tue, 19 Nov 2024 19:41:59 +0000 (22:41 +0300)
committerGitHub <noreply@github.com>
Tue, 19 Nov 2024 19:41:59 +0000 (22:41 +0300)
Lib/test/libregrtest/mypy.ini
Lib/test/libregrtest/results.py
Lib/test/libregrtest/runtests.py
Lib/test/libregrtest/worker.py

index 905341cc04b8f19d8f7a2b9828bee78dd3f0646e..3fa9afcb7a4a8c3d452e715ef11aa62c4b581fb2 100644 (file)
@@ -15,7 +15,6 @@ strict = True
 
 # Various stricter settings that we can't yet enable
 # Try to enable these in the following order:
-disallow_any_generics = False
 disallow_incomplete_defs = False
 disallow_untyped_calls = False
 disallow_untyped_defs = False
index 4f3e84282dc5dc1e327f842cbd6fe12fcf020503..9eda926966dc7edd08ff0a08391c85ae15be2544 100644 (file)
@@ -1,5 +1,6 @@
 import sys
 import trace
+from typing import TYPE_CHECKING
 
 from .runtests import RunTests
 from .result import State, TestResult, TestStats, Location
@@ -7,6 +8,9 @@ from .utils import (
     StrPath, TestName, TestTuple, TestList, FilterDict,
     printlist, count, format_duration)
 
+if TYPE_CHECKING:
+    from xml.etree.ElementTree import Element
+
 
 # Python uses exit code 1 when an exception is not caught
 # argparse.ArgumentParser.error() uses exit code 2
@@ -34,7 +38,7 @@ class TestResults:
         self.test_times: list[tuple[float, TestName]] = []
         self.stats = TestStats()
         # used by --junit-xml
-        self.testsuite_xml: list = []
+        self.testsuite_xml: list['Element'] = []
         # used by -T with -j
         self.covered_lines: set[Location] = set()
 
index cd1ce8080a04df47204af727c5ec2493bae05512..130c036a62eefb089ca06dac38440ee365fb0cc8 100644 (file)
@@ -28,7 +28,7 @@ class JsonFile:
     file: int | None
     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:
             case JsonFileType.UNIX_FD:
                 # Unix file descriptor
index da24760a82c6c666c44ab716cc00130e10f3659c..0c9f5bd6e42f11daae5f9df59bdefccf15046c79 100644 (file)
@@ -20,7 +20,7 @@ NEED_TTY = {
 
 
 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()
 
     cmd = runtests.create_python_cmd()