1010import threading
1111import time
1212import traceback
13- from typing import Literal , TextIO
13+ from typing import Any , Literal , TextIO
1414
1515from test import support
1616from test .support import os_helper , MS_WINDOWS
@@ -243,7 +243,9 @@ def create_json_file(self, stack: contextlib.ExitStack) -> tuple[JsonFile, TextI
243243
244244 json_fd = json_tmpfile .fileno ()
245245 if MS_WINDOWS :
246- json_handle = msvcrt .get_osfhandle (json_fd )
246+ # The msvcrt module is only available on Windows;
247+ # we run mypy with `--platform=linux` in CI
248+ json_handle : int = msvcrt .get_osfhandle (json_fd ) # type: ignore[attr-defined]
247249 json_file = JsonFile (json_handle ,
248250 JsonFileType .WINDOWS_HANDLE )
249251 else :
@@ -257,7 +259,7 @@ def create_worker_runtests(self, test_name: TestName, json_file: JsonFile) -> Wo
257259 else :
258260 match_tests = None
259261
260- kwargs = {}
262+ kwargs : dict [ str , Any ] = {}
261263 if match_tests :
262264 kwargs ['match_tests' ] = [(test , True ) for test in match_tests ]
263265 if self .runtests .output_on_failure :
@@ -343,6 +345,7 @@ def _runtest(self, test_name: TestName) -> MultiprocessResult:
343345 json_file , json_tmpfile = self .create_json_file (stack )
344346 worker_runtests = self .create_worker_runtests (test_name , json_file )
345347
348+ retcode : str | int | None
346349 retcode , tmp_files = self .run_tmp_files (worker_runtests ,
347350 stdout_file .fileno ())
348351
0 commit comments