| 
6 | 6 | import sysconfig  | 
7 | 7 | import time  | 
8 | 8 | import trace  | 
 | 9 | +from typing import NoReturn  | 
9 | 10 | 
 
  | 
10 | 11 | from test.support import (os_helper, MS_WINDOWS, flush_std_streams,  | 
11 | 12 |                           suppress_immortalization)  | 
@@ -155,7 +156,7 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):  | 
155 | 156 |         self.next_single_test: TestName | None = None  | 
156 | 157 |         self.next_single_filename: StrPath | None = None  | 
157 | 158 | 
 
  | 
158 |  | -    def log(self, line=''):  | 
 | 159 | +    def log(self, line: str = '') -> None:  | 
159 | 160 |         self.logger.log(line)  | 
160 | 161 | 
 
  | 
161 | 162 |     def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList | None]:  | 
@@ -233,11 +234,11 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList  | 
233 | 234 |         return (tuple(selected), tests)  | 
234 | 235 | 
 
  | 
235 | 236 |     @staticmethod  | 
236 |  | -    def list_tests(tests: TestTuple):  | 
 | 237 | +    def list_tests(tests: TestTuple) -> None:  | 
237 | 238 |         for name in tests:  | 
238 | 239 |             print(name)  | 
239 | 240 | 
 
  | 
240 |  | -    def _rerun_failed_tests(self, runtests: RunTests):  | 
 | 241 | +    def _rerun_failed_tests(self, runtests: RunTests) -> RunTests:  | 
241 | 242 |         # Configure the runner to re-run tests  | 
242 | 243 |         if self.num_workers == 0 and not self.single_process:  | 
243 | 244 |             # Always run tests in fresh processes to have more deterministic  | 
@@ -269,7 +270,7 @@ def _rerun_failed_tests(self, runtests: RunTests):  | 
269 | 270 |             self.run_tests_sequentially(runtests)  | 
270 | 271 |         return runtests  | 
271 | 272 | 
 
  | 
272 |  | -    def rerun_failed_tests(self, runtests: RunTests):  | 
 | 273 | +    def rerun_failed_tests(self, runtests: RunTests) -> None:  | 
273 | 274 |         if self.python_cmd:  | 
274 | 275 |             # Temp patch for https://github.com/python/cpython/issues/94052  | 
275 | 276 |             self.log(  | 
@@ -338,7 +339,7 @@ def run_bisect(self, runtests: RunTests) -> None:  | 
338 | 339 |             if not self._run_bisect(runtests, name, progress):  | 
339 | 340 |                 return  | 
340 | 341 | 
 
  | 
341 |  | -    def display_result(self, runtests):  | 
 | 342 | +    def display_result(self, runtests: RunTests) -> None:  | 
342 | 343 |         # If running the test suite for PGO then no one cares about results.  | 
343 | 344 |         if runtests.pgo:  | 
344 | 345 |             return  | 
@@ -368,7 +369,7 @@ def run_test(  | 
368 | 369 | 
 
  | 
369 | 370 |         return result  | 
370 | 371 | 
 
  | 
371 |  | -    def run_tests_sequentially(self, runtests) -> None:  | 
 | 372 | +    def run_tests_sequentially(self, runtests: RunTests) -> None:  | 
372 | 373 |         if self.coverage:  | 
373 | 374 |             tracer = trace.Trace(trace=False, count=True)  | 
374 | 375 |         else:  | 
@@ -425,7 +426,7 @@ def run_tests_sequentially(self, runtests) -> None:  | 
425 | 426 |         if previous_test:  | 
426 | 427 |             print(previous_test)  | 
427 | 428 | 
 
  | 
428 |  | -    def get_state(self):  | 
 | 429 | +    def get_state(self) -> str:  | 
429 | 430 |         state = self.results.get_state(self.fail_env_changed)  | 
430 | 431 |         if self.first_state:  | 
431 | 432 |             state = f'{self.first_state} then {state}'  | 
@@ -474,7 +475,7 @@ def display_summary(self) -> None:  | 
474 | 475 |         state = self.get_state()  | 
475 | 476 |         print(f"Result: {state}")  | 
476 | 477 | 
 
  | 
477 |  | -    def create_run_tests(self, tests: TestTuple):  | 
 | 478 | +    def create_run_tests(self, tests: TestTuple) -> RunTests:  | 
478 | 479 |         return RunTests(  | 
479 | 480 |             tests,  | 
480 | 481 |             fail_fast=self.fail_fast,  | 
@@ -685,9 +686,9 @@ def _execute_python(self, cmd, environ):  | 
685 | 686 |                           f"Command: {cmd_text}")  | 
686 | 687 |             # continue executing main()  | 
687 | 688 | 
 
  | 
688 |  | -    def _add_python_opts(self):  | 
689 |  | -        python_opts = []  | 
690 |  | -        regrtest_opts = []  | 
 | 689 | +    def _add_python_opts(self) -> None:  | 
 | 690 | +        python_opts: list[str] = []  | 
 | 691 | +        regrtest_opts: list[str] = []  | 
691 | 692 | 
 
  | 
692 | 693 |         environ, keep_environ = self._add_cross_compile_opts(regrtest_opts)  | 
693 | 694 |         if self.ci_mode:  | 
@@ -728,7 +729,7 @@ def tmp_dir(self) -> StrPath:  | 
728 | 729 |             )  | 
729 | 730 |         return self._tmp_dir  | 
730 | 731 | 
 
  | 
731 |  | -    def main(self, tests: TestList | None = None):  | 
 | 732 | +    def main(self, tests: TestList | None = None) -> NoReturn:  | 
732 | 733 |         if self.want_add_python_opts:  | 
733 | 734 |             self._add_python_opts()  | 
734 | 735 | 
 
  | 
@@ -757,7 +758,7 @@ def main(self, tests: TestList | None = None):  | 
757 | 758 |         sys.exit(exitcode)  | 
758 | 759 | 
 
  | 
759 | 760 | 
 
  | 
760 |  | -def main(tests=None, _add_python_opts=False, **kwargs):  | 
 | 761 | +def main(tests=None, _add_python_opts=False, **kwargs) -> NoReturn:  | 
761 | 762 |     """Run the Python suite."""  | 
762 | 763 |     ns = _parse_args(sys.argv[1:], **kwargs)  | 
763 | 764 |     Regrtest(ns, _add_python_opts=_add_python_opts).main(tests=tests)  | 
0 commit comments