66import sysconfig
77import time
88import trace
9+ from typing import NoReturn
910
1011from test .support import os_helper , MS_WINDOWS , flush_std_streams
1112
@@ -154,7 +155,7 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):
154155 self .next_single_test : TestName | None = None
155156 self .next_single_filename : StrPath | None = None
156157
157- def log (self , line = '' ):
158+ def log (self , line : str = '' ) -> None :
158159 self .logger .log (line )
159160
160161 def find_tests (self , tests : TestList | None = None ) -> tuple [TestTuple , TestList | None ]:
@@ -230,11 +231,11 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList
230231 return (tuple (selected ), tests )
231232
232233 @staticmethod
233- def list_tests (tests : TestTuple ):
234+ def list_tests (tests : TestTuple ) -> None :
234235 for name in tests :
235236 print (name )
236237
237- def _rerun_failed_tests (self , runtests : RunTests ):
238+ def _rerun_failed_tests (self , runtests : RunTests ) -> RunTests :
238239 # Configure the runner to re-run tests
239240 if self .num_workers == 0 and not self .single_process :
240241 # Always run tests in fresh processes to have more deterministic
@@ -266,7 +267,7 @@ def _rerun_failed_tests(self, runtests: RunTests):
266267 self .run_tests_sequentially (runtests )
267268 return runtests
268269
269- def rerun_failed_tests (self , runtests : RunTests ):
270+ def rerun_failed_tests (self , runtests : RunTests ) -> None :
270271 if self .python_cmd :
271272 # Temp patch for https://github.com/python/cpython/issues/94052
272273 self .log (
@@ -335,7 +336,7 @@ def run_bisect(self, runtests: RunTests) -> None:
335336 if not self ._run_bisect (runtests , name , progress ):
336337 return
337338
338- def display_result (self , runtests ) :
339+ def display_result (self , runtests : RunTests ) -> None :
339340 # If running the test suite for PGO then no one cares about results.
340341 if runtests .pgo :
341342 return
@@ -365,7 +366,7 @@ def run_test(
365366
366367 return result
367368
368- def run_tests_sequentially (self , runtests ) -> None :
369+ def run_tests_sequentially (self , runtests : RunTests ) -> None :
369370 if self .coverage :
370371 tracer = trace .Trace (trace = False , count = True )
371372 else :
@@ -422,7 +423,7 @@ def run_tests_sequentially(self, runtests) -> None:
422423 if previous_test :
423424 print (previous_test )
424425
425- def get_state (self ):
426+ def get_state (self ) -> str :
426427 state = self .results .get_state (self .fail_env_changed )
427428 if self .first_state :
428429 state = f'{ self .first_state } then { state } '
@@ -452,7 +453,7 @@ def finalize_tests(self, coverage: trace.CoverageResults | None) -> None:
452453 if self .junit_filename :
453454 self .results .write_junit (self .junit_filename )
454455
455- def display_summary (self ):
456+ def display_summary (self ) -> None :
456457 duration = time .perf_counter () - self .logger .start_time
457458 filtered = bool (self .match_tests )
458459
@@ -466,7 +467,7 @@ def display_summary(self):
466467 state = self .get_state ()
467468 print (f"Result: { state } " )
468469
469- def create_run_tests (self , tests : TestTuple ):
470+ def create_run_tests (self , tests : TestTuple ) -> RunTests :
470471 return RunTests (
471472 tests ,
472473 fail_fast = self .fail_fast ,
@@ -674,9 +675,9 @@ def _execute_python(self, cmd, environ):
674675 f"Command: { cmd_text } " )
675676 # continue executing main()
676677
677- def _add_python_opts (self ):
678- python_opts = []
679- regrtest_opts = []
678+ def _add_python_opts (self ) -> None :
679+ python_opts : list [ str ] = []
680+ regrtest_opts : list [ str ] = []
680681
681682 environ , keep_environ = self ._add_cross_compile_opts (regrtest_opts )
682683 if self .ci_mode :
@@ -709,7 +710,7 @@ def _init(self):
709710
710711 self .tmp_dir = get_temp_dir (self .tmp_dir )
711712
712- def main (self , tests : TestList | None = None ):
713+ def main (self , tests : TestList | None = None ) -> NoReturn :
713714 if self .want_add_python_opts :
714715 self ._add_python_opts ()
715716
@@ -738,7 +739,7 @@ def main(self, tests: TestList | None = None):
738739 sys .exit (exitcode )
739740
740741
741- def main (tests = None , _add_python_opts = False , ** kwargs ):
742+ def main (tests = None , _add_python_opts = False , ** kwargs ) -> NoReturn :
742743 """Run the Python suite."""
743744 ns = _parse_args (sys .argv [1 :], ** kwargs )
744745 Regrtest (ns , _add_python_opts = _add_python_opts ).main (tests = tests )
0 commit comments