gh-109413: Enable strict_optional
for libregrtest/main.py
(#126394)
This commit is contained in:
parent
3c99969094
commit
12ca7e622f
@ -148,7 +148,7 @@ class Namespace(argparse.Namespace):
|
|||||||
self.randomize = False
|
self.randomize = False
|
||||||
self.fromfile = None
|
self.fromfile = None
|
||||||
self.fail_env_changed = False
|
self.fail_env_changed = False
|
||||||
self.use_resources = None
|
self.use_resources: list[str] = []
|
||||||
self.trace = False
|
self.trace = False
|
||||||
self.coverdir = 'coverage'
|
self.coverdir = 'coverage'
|
||||||
self.runleaks = False
|
self.runleaks = False
|
||||||
@ -403,8 +403,6 @@ def _parse_args(args, **kwargs):
|
|||||||
raise TypeError('%r is an invalid keyword argument '
|
raise TypeError('%r is an invalid keyword argument '
|
||||||
'for this function' % k)
|
'for this function' % k)
|
||||||
setattr(ns, k, v)
|
setattr(ns, k, v)
|
||||||
if ns.use_resources is None:
|
|
||||||
ns.use_resources = []
|
|
||||||
|
|
||||||
parser = _create_parser()
|
parser = _create_parser()
|
||||||
# Issue #14191: argparse doesn't support "intermixed" positional and
|
# Issue #14191: argparse doesn't support "intermixed" positional and
|
||||||
|
@ -123,7 +123,7 @@ class Regrtest:
|
|||||||
self.python_cmd = None
|
self.python_cmd = None
|
||||||
self.coverage: bool = ns.trace
|
self.coverage: bool = ns.trace
|
||||||
self.coverage_dir: StrPath | None = ns.coverdir
|
self.coverage_dir: StrPath | None = ns.coverdir
|
||||||
self.tmp_dir: StrPath | None = ns.tempdir
|
self._tmp_dir: StrPath | None = ns.tempdir
|
||||||
|
|
||||||
# Randomize
|
# Randomize
|
||||||
self.randomize: bool = ns.randomize
|
self.randomize: bool = ns.randomize
|
||||||
@ -159,6 +159,8 @@ class Regrtest:
|
|||||||
self.logger.log(line)
|
self.logger.log(line)
|
||||||
|
|
||||||
def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList | None]:
|
def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList | None]:
|
||||||
|
if tests is None:
|
||||||
|
tests = []
|
||||||
if self.single_test_run:
|
if self.single_test_run:
|
||||||
self.next_single_filename = os.path.join(self.tmp_dir, 'pynexttest')
|
self.next_single_filename = os.path.join(self.tmp_dir, 'pynexttest')
|
||||||
try:
|
try:
|
||||||
@ -454,6 +456,11 @@ class Regrtest:
|
|||||||
self.results.write_junit(self.junit_filename)
|
self.results.write_junit(self.junit_filename)
|
||||||
|
|
||||||
def display_summary(self) -> None:
|
def display_summary(self) -> None:
|
||||||
|
if self.first_runtests is None:
|
||||||
|
raise ValueError(
|
||||||
|
"Should never call `display_summary()` before calling `_run_test()`"
|
||||||
|
)
|
||||||
|
|
||||||
duration = time.perf_counter() - self.logger.start_time
|
duration = time.perf_counter() - self.logger.start_time
|
||||||
filtered = bool(self.match_tests)
|
filtered = bool(self.match_tests)
|
||||||
|
|
||||||
@ -708,7 +715,15 @@ class Regrtest:
|
|||||||
|
|
||||||
strip_py_suffix(self.cmdline_args)
|
strip_py_suffix(self.cmdline_args)
|
||||||
|
|
||||||
self.tmp_dir = get_temp_dir(self.tmp_dir)
|
self._tmp_dir = get_temp_dir(self._tmp_dir)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tmp_dir(self) -> StrPath:
|
||||||
|
if self._tmp_dir is None:
|
||||||
|
raise ValueError(
|
||||||
|
"Should never use `.tmp_dir` before calling `.main()`"
|
||||||
|
)
|
||||||
|
return self._tmp_dir
|
||||||
|
|
||||||
def main(self, tests: TestList | None = None) -> NoReturn:
|
def main(self, tests: TestList | None = None) -> NoReturn:
|
||||||
if self.want_add_python_opts:
|
if self.want_add_python_opts:
|
||||||
|
@ -22,10 +22,8 @@ disallow_untyped_defs = False
|
|||||||
check_untyped_defs = False
|
check_untyped_defs = False
|
||||||
warn_return_any = False
|
warn_return_any = False
|
||||||
|
|
||||||
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.*]
|
[mypy-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:
|
||||||
|
@ -211,6 +211,7 @@ class WorkerThread(threading.Thread):
|
|||||||
# on reading closed stdout
|
# on reading closed stdout
|
||||||
raise ExitThread
|
raise ExitThread
|
||||||
raise
|
raise
|
||||||
|
return None
|
||||||
except:
|
except:
|
||||||
self._kill()
|
self._kill()
|
||||||
raise
|
raise
|
||||||
@ -544,6 +545,7 @@ class RunWorkers:
|
|||||||
running = get_running(self.workers)
|
running = get_running(self.workers)
|
||||||
if running:
|
if running:
|
||||||
self.log(running)
|
self.log(running)
|
||||||
|
return None
|
||||||
|
|
||||||
def display_result(self, mp_result: MultiprocessResult) -> None:
|
def display_result(self, mp_result: MultiprocessResult) -> None:
|
||||||
result = mp_result.result
|
result = mp_result.result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user