Skip to content

Add success msg for only notes output #12306

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

Merged
merged 2 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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