55import sys
66import sysconfig
77import time
8+ from typing import NoReturn
89
910from test .support import os_helper , MS_WINDOWS , flush_std_streams
1011
@@ -152,7 +153,7 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):
152153 self .next_single_test : TestName | None = None
153154 self .next_single_filename : StrPath | None = None
154155
155- def log (self , line = '' ):
156+ def log (self , line : str = '' ) -> None :
156157 self .logger .log (line )
157158
158159 def find_tests (self , tests : TestList | None = None ) -> tuple [TestTuple , TestList | None ]:
@@ -228,11 +229,11 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList
228229 return (tuple (selected ), tests )
229230
230231 @staticmethod
231- def list_tests (tests : TestTuple ):
232+ def list_tests (tests : TestTuple ) -> None :
232233 for name in tests :
233234 print (name )
234235
235- def _rerun_failed_tests (self , runtests : RunTests ):
236+ def _rerun_failed_tests (self , runtests : RunTests ) -> RunTests :
236237 # Configure the runner to re-run tests
237238 if self .num_workers == 0 :
238239 # Always run tests in fresh processes to have more deterministic
@@ -257,7 +258,7 @@ def _rerun_failed_tests(self, runtests: RunTests):
257258 self ._run_tests_mp (runtests , self .num_workers )
258259 return runtests
259260
260- def rerun_failed_tests (self , runtests : RunTests ):
261+ def rerun_failed_tests (self , runtests : RunTests ) -> None :
261262 if self .python_cmd :
262263 # Temp patch for https://github.com/python/cpython/issues/94052
263264 self .log (
@@ -326,7 +327,7 @@ def run_bisect(self, runtests: RunTests) -> None:
326327 if not self ._run_bisect (runtests , name , progress ):
327328 return
328329
329- def display_result (self , runtests ) :
330+ def display_result (self , runtests : RunTests ) -> None :
330331 # If running the test suite for PGO then no one cares about results.
331332 if runtests .pgo :
332333 return
@@ -353,7 +354,7 @@ def run_test(self, test_name: TestName, runtests: RunTests, tracer):
353354
354355 return result
355356
356- def run_tests_sequentially (self , runtests ):
357+ def run_tests_sequentially (self , runtests : RunTests ):
357358 if self .coverage :
358359 import trace
359360 tracer = trace .Trace (trace = False , count = True )
@@ -413,7 +414,7 @@ def run_tests_sequentially(self, runtests):
413414
414415 return tracer
415416
416- def get_state (self ):
417+ def get_state (self ) -> str :
417418 state = self .results .get_state (self .fail_env_changed )
418419 if self .first_state :
419420 state = f'{ self .first_state } then { state } '
@@ -442,7 +443,7 @@ def finalize_tests(self, tracer):
442443 if self .junit_filename :
443444 self .results .write_junit (self .junit_filename )
444445
445- def display_summary (self ):
446+ def display_summary (self ) -> None :
446447 duration = time .perf_counter () - self .logger .start_time
447448 filtered = bool (self .match_tests )
448449
@@ -456,7 +457,7 @@ def display_summary(self):
456457 state = self .get_state ()
457458 print (f"Result: { state } " )
458459
459- def create_run_tests (self , tests : TestTuple ):
460+ def create_run_tests (self , tests : TestTuple ) -> RunTests :
460461 return RunTests (
461462 tests ,
462463 fail_fast = self .fail_fast ,
@@ -659,9 +660,9 @@ def _execute_python(self, cmd, environ):
659660 f"Command: { cmd_text } " )
660661 # continue executing main()
661662
662- def _add_python_opts (self ):
663- python_opts = []
664- regrtest_opts = []
663+ def _add_python_opts (self ) -> None :
664+ python_opts : list [ str ] = []
665+ regrtest_opts : list [ str ] = []
665666
666667 environ , keep_environ = self ._add_cross_compile_opts (regrtest_opts )
667668 if self .ci_mode :
@@ -694,7 +695,7 @@ def _init(self):
694695
695696 self .tmp_dir = get_temp_dir (self .tmp_dir )
696697
697- def main (self , tests : TestList | None = None ):
698+ def main (self , tests : TestList | None = None ) -> NoReturn :
698699 if self .want_add_python_opts :
699700 self ._add_python_opts ()
700701
@@ -723,7 +724,7 @@ def main(self, tests: TestList | None = None):
723724 sys .exit (exitcode )
724725
725726
726- def main (tests = None , _add_python_opts = False , ** kwargs ):
727+ def main (tests = None , _add_python_opts = False , ** kwargs ) -> NoReturn :
727728 """Run the Python suite."""
728729 ns = _parse_args (sys .argv [1 :], ** kwargs )
729730 Regrtest (ns , _add_python_opts = _add_python_opts ).main (tests = tests )
0 commit comments