Skip to content

Commit

Permalink
Add success msg for only notes output (#12306)
Browse files Browse the repository at this point in the history
  • Loading branch information
97littleleaf11 authored Mar 18, 2022
1 parent 21d957a commit fd90550
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
11 changes: 5 additions & 6 deletions mypy/dmypy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,12 +772,11 @@ def pretty_messages(self, messages: List[str], n_sources: int,
fixed_terminal_width=terminal_width)
if self.options.error_summary:
summary: Optional[str] = None
if messages:
n_errors, n_files = count_stats(messages)
if n_errors:
summary = self.formatter.format_error(n_errors, n_files, n_sources,
use_color=use_color)
else:
n_errors, n_notes, n_files = count_stats(messages)
if n_errors:
summary = self.formatter.format_error(n_errors, n_files, n_sources,
use_color=use_color)
elif not messages or n_notes == len(messages):
summary = self.formatter.format_success(n_sources, use_color)
if summary:
# Create new list to avoid appending multiple summaries on successive runs.
Expand Down
18 changes: 9 additions & 9 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ def main(script_path: Optional[str],
if messages:
code = 2 if blockers else 1
if options.error_summary:
if messages:
n_errors, n_files = util.count_stats(messages)
if n_errors:
summary = formatter.format_error(
n_errors, n_files, len(sources), blockers=blockers,
use_color=options.color_output
)
stdout.write(summary + '\n')
else:
n_errors, n_notes, n_files = util.count_stats(messages)
if n_errors:
summary = formatter.format_error(
n_errors, n_files, len(sources), blockers=blockers,
use_color=options.color_output
)
stdout.write(summary + '\n')
# Only notes should also output success
elif not messages or n_notes == len(messages):
stdout.write(formatter.format_success(len(sources), options.color_output) + '\n')
stdout.flush()

Expand Down
11 changes: 6 additions & 5 deletions mypy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,12 @@ def check_python_version(program: str) -> None:
"please upgrade to 3.6 or newer".format(name=program))


def count_stats(errors: List[str]) -> Tuple[int, int]:
"""Count total number of errors and files in error list."""
errors = [e for e in errors if ': error:' in e]
files = {e.split(':')[0] for e in errors}
return len(errors), len(files)
def count_stats(messages: List[str]) -> Tuple[int, int, int]:
"""Count total number of errors, notes and error_files in message list."""
errors = [e for e in messages if ': error:' in e]
error_files = {e.split(':')[0] for e in errors}
notes = [e for e in messages if ': note:' in e]
return len(errors), len(notes), len(error_files)


def split_words(msg: str) -> List[str]:
Expand Down

0 comments on commit fd90550

Please sign in to comment.