-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-109413: Fix some trivial mypy nitpicks in libregrtest #109454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,8 +231,7 @@ def display_summary(self, first_runtests: RunTests, filtered: bool): | |
report.append(f'failures={stats.failures:,}') | ||
if stats.skipped: | ||
report.append(f'skipped={stats.skipped:,}') | ||
report = ' '.join(report) | ||
print(f"Total tests: {report}") | ||
print(f"Total tests: {' '.join(report)}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's the same issue here: |
||
|
||
# Total test files | ||
all_tests = [self.good, self.bad, self.rerun, | ||
|
@@ -256,5 +255,4 @@ def display_summary(self, first_runtests: RunTests, filtered: bool): | |
): | ||
if tests: | ||
report.append(f'{name}={len(tests)}') | ||
report = ' '.join(report) | ||
print(f"Total test files: {report}") | ||
print(f"Total test files: {' '.join(report)}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,14 +136,14 @@ def _runtest_env_changed_exc(result: TestResult, runtests: RunTests, | |
with saved_test_environment(test_name, | ||
runtests.verbose, quiet, pgo=pgo): | ||
_load_run_test(result, runtests) | ||
except support.ResourceDenied as msg: | ||
except support.ResourceDenied as exc: | ||
if not quiet and not pgo: | ||
print(f"{test_name} skipped -- {msg}", flush=True) | ||
print(f"{test_name} skipped -- {exc}", flush=True) | ||
result.state = State.RESOURCE_DENIED | ||
return | ||
except unittest.SkipTest as msg: | ||
except unittest.SkipTest as exc: | ||
if not quiet and not pgo: | ||
print(f"{test_name} skipped -- {msg}", flush=True) | ||
print(f"{test_name} skipped -- {exc}", flush=True) | ||
Comment on lines
-139
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This passage was causing mypy to get very agitated:
Mypy was getting confused because the |
||
result.state = State.SKIPPED | ||
return | ||
except support.TestFailedWithDetails as exc: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ def create_worker_process(runtests: RunTests, output_fd: int, | |
if python_cmd is not None: | ||
executable = python_cmd | ||
else: | ||
executable = [sys.executable] | ||
executable = (sys.executable,) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mypy complained about this line because on line 26, the |
||
cmd = [*executable, *support.args_from_interpreter_flags(), | ||
'-u', # Unbuffered stdout and stderr | ||
'-m', 'test.libregrtest.worker', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable has been renamed here because there's already a variable earlier in this function called
test_time
, and it has typefloat
. Mypy enforces that a variable should only ever have one consistent type within any given scope, and here the name is reassigned to astr
. We can fix the mypy complaints by using a new variable name for thestr
value, rather than reusing thetest_time
nameThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_time is a bad name, in fact, it's just time relative to regrtest start time.
I suggest renaming test_time to log_time and the second variable to formatted_log_time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good shout, I'll do the renames
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I 8000 n the past, I put "test" everywhere :-) "test" now means nothing, since everything is called "test" in libregrtest :-) That's why I renamed "runtest.py" to "single.py" and rename "runtest_mp.py" to "run_worker.py" ;-)