Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Jul 23, 2024
1 parent bbdc1da commit b73b42f
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 122 deletions.
4 changes: 2 additions & 2 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ def save_baseline(manager: BuildManager):
file.parent.mkdir(parents=True)
data: BaselineType = {
"files": new_baseline,
"format": "1.7",
"format": "2.6",
"targets": manager.options._targets,
}
with file.open("w") as f:
Expand Down Expand Up @@ -1159,7 +1159,7 @@ def error(msg: str | None = None) -> bool:

if baseline_format is None and error():
return
elif baseline_format != "1.7":
elif baseline_format != "2.6":
if not options.write_baseline:
error(
f"error: Baseline file '{file}' was generated with an old version of basedmypy.\n"
Expand Down
4 changes: 2 additions & 2 deletions mypy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ def remove_duplicates(errors: list[ErrorInfo]) -> list[ErrorInfo]:
return unduplicated_result

allowed = self.options.baseline_allows
banned = self.options.baseline_allows
banned = self.options.baseline_bans
rejected = []
error_list = []

Expand All @@ -1404,7 +1404,7 @@ def yes_no(condition: bool) -> bool:
if allowed:
return yes_no(error.code in allowed)
if banned:
return yes_no(error.code in banned)
return yes_no(error.code not in banned)
return yes_no(True)

result = {
Expand Down
10 changes: 6 additions & 4 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
from collections import defaultdict
from gettext import gettext
from operator import itemgetter
from typing import IO, Any, Final, NoReturn, Sequence, TextIO

import mypy.options
Expand Down Expand Up @@ -134,8 +135,8 @@ def main(
all_errors[error.code.code] += 1
if all_errors:
max_code_name_length = max(len(code_name) for code_name in all_errors)
for code_name, count in all_errors.items():
stdout.write(f" {code_name:<{max_code_name_length}} {count:>5}\n")
for error_code, count in sorted(all_errors.items(), key=itemgetter(1)):
stdout.write(f" {error_code:<{max_code_name_length}} {count:>5}\n")
if options.write_baseline and res:
n_files = len(res.manager.errors.all_errors)
stats = res.manager.errors.baseline_stats
Expand All @@ -144,7 +145,8 @@ def main(
new_errors = n_errors - rejected
previous = res.manager.errors.original_baseline
stdout.write(formatter.style("baseline:\n", color="none", bold=True))
stdout.write(f" {new_errors} new error{plural_s(new_errors)}\n")
if new_errors >= 0:
stdout.write(f" {new_errors} new error{plural_s(new_errors)}\n")
stdout.write(f" {total} error{plural_s(total)} in baseline\n")
difference = (
len(
Expand Down Expand Up @@ -653,7 +655,7 @@ def add_invertible_flag(
)
add_invertible_flag(
"--no-summary",
default=False,
default=True,
help="don't show an error code summary at the end",
group=based_group,
)
Expand Down
5 changes: 4 additions & 1 deletion mypy/test/testcmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_python_cmdline(testcase: DataDrivenTestCase, step: int) -> None:
if "# dont-normalize-output:" in testcase.input:
testcase.normalize_output = False
args.append("--show-traceback")
args.append("--no-summary")
based = "based" in testcase.parent.name
if not based:
args.append("--no-strict")
Expand Down Expand Up @@ -116,7 +117,7 @@ def test_python_cmdline(testcase: DataDrivenTestCase, step: int) -> None:
# Remove temp file.
os.remove(program_path)
# Compare actual output to expected.
if testcase.output_files:
if testcase.output_files and False:
assert not testcase.output, "output not checked when outfile supplied"
# Ignore stdout, but we insist on empty stderr and zero status.
if err or result:
Expand All @@ -126,6 +127,8 @@ def test_python_cmdline(testcase: DataDrivenTestCase, step: int) -> None:
)
check_test_output_files(testcase, step)
else:
if testcase.output_files:
check_test_output_files(testcase, step)
if testcase.normalize_output:
out = normalize_error_messages(err + out)
obvious_result = 1 if out else 0
Expand Down
Loading

0 comments on commit b73b42f

Please sign in to comment.