mirror of https://github.com/python/cpython.git
gh-109413: libregrtest: enable mypy's `--strict-optional` check on most files (#112586)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
5f6ac2d88a
commit
70a38ffb3d
|
@ -25,7 +25,7 @@ warn_return_any = False
|
||||||
disable_error_code = return
|
disable_error_code = return
|
||||||
|
|
||||||
# Enable --strict-optional for these ASAP:
|
# Enable --strict-optional for these ASAP:
|
||||||
[mypy-Lib.test.libregrtest.main.*,Lib.test.libregrtest.run_workers.*,Lib.test.libregrtest.worker.*,Lib.test.libregrtest.single.*,Lib.test.libregrtest.results.*,Lib.test.libregrtest.utils.*]
|
[mypy-Lib.test.libregrtest.main.*,Lib.test.libregrtest.run_workers.*]
|
||||||
strict_optional = False
|
strict_optional = False
|
||||||
|
|
||||||
# Various internal modules that typeshed deliberately doesn't have stubs for:
|
# Various internal modules that typeshed deliberately doesn't have stubs for:
|
||||||
|
|
|
@ -117,6 +117,8 @@ def accumulate_result(self, result: TestResult, runtests: RunTests):
|
||||||
self.worker_bug = True
|
self.worker_bug = True
|
||||||
|
|
||||||
if result.has_meaningful_duration() and not rerun:
|
if result.has_meaningful_duration() and not rerun:
|
||||||
|
if result.duration is None:
|
||||||
|
raise ValueError("result.duration is None")
|
||||||
self.test_times.append((result.duration, test_name))
|
self.test_times.append((result.duration, test_name))
|
||||||
if result.stats is not None:
|
if result.stats is not None:
|
||||||
self.stats.accumulate(result.stats)
|
self.stats.accumulate(result.stats)
|
||||||
|
|
|
@ -237,11 +237,11 @@ def _runtest(result: TestResult, runtests: RunTests) -> None:
|
||||||
output_on_failure = runtests.output_on_failure
|
output_on_failure = runtests.output_on_failure
|
||||||
timeout = runtests.timeout
|
timeout = runtests.timeout
|
||||||
|
|
||||||
use_timeout = (
|
if timeout is not None and threading_helper.can_start_thread:
|
||||||
timeout is not None and threading_helper.can_start_thread
|
use_timeout = True
|
||||||
)
|
|
||||||
if use_timeout:
|
|
||||||
faulthandler.dump_traceback_later(timeout, exit=True)
|
faulthandler.dump_traceback_later(timeout, exit=True)
|
||||||
|
else:
|
||||||
|
use_timeout = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
setup_tests(runtests)
|
setup_tests(runtests)
|
||||||
|
|
|
@ -377,10 +377,19 @@ def get_temp_dir(tmp_dir: StrPath | None = None) -> StrPath:
|
||||||
# Python out of the source tree, especially when the
|
# Python out of the source tree, especially when the
|
||||||
# source tree is read only.
|
# source tree is read only.
|
||||||
tmp_dir = sysconfig.get_config_var('srcdir')
|
tmp_dir = sysconfig.get_config_var('srcdir')
|
||||||
|
if not tmp_dir:
|
||||||
|
raise RuntimeError(
|
||||||
|
"Could not determine the correct value for tmp_dir"
|
||||||
|
)
|
||||||
tmp_dir = os.path.join(tmp_dir, 'build')
|
tmp_dir = os.path.join(tmp_dir, 'build')
|
||||||
else:
|
else:
|
||||||
# WASI platform
|
# WASI platform
|
||||||
tmp_dir = sysconfig.get_config_var('projectbase')
|
tmp_dir = sysconfig.get_config_var('projectbase')
|
||||||
|
if not tmp_dir:
|
||||||
|
raise RuntimeError(
|
||||||
|
"sysconfig.get_config_var('projectbase') "
|
||||||
|
f"unexpectedly returned {tmp_dir!r} on WASI"
|
||||||
|
)
|
||||||
tmp_dir = os.path.join(tmp_dir, 'build')
|
tmp_dir = os.path.join(tmp_dir, 'build')
|
||||||
|
|
||||||
# When get_temp_dir() is called in a worker process,
|
# When get_temp_dir() is called in a worker process,
|
||||||
|
|
Loading…
Reference in New Issue