Skip to content

Commit fd90550

Browse files
Add success msg for only notes output (#12306)
1 parent 21d957a commit fd90550

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

mypy/dmypy_server.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -772,12 +772,11 @@ def pretty_messages(self, messages: List[str], n_sources: int,
772772
fixed_terminal_width=terminal_width)
773773
if self.options.error_summary:
774774
summary: Optional[str] = None
775-
if messages:
776-
n_errors, n_files = count_stats(messages)
777-
if n_errors:
778-
summary = self.formatter.format_error(n_errors, n_files, n_sources,
779-
use_color=use_color)
780-
else:
775+
n_errors, n_notes, n_files = count_stats(messages)
776+
if n_errors:
777+
summary = self.formatter.format_error(n_errors, n_files, n_sources,
778+
use_color=use_color)
779+
elif not messages or n_notes == len(messages):
781780
summary = self.formatter.format_success(n_sources, use_color)
782781
if summary:
783782
# Create new list to avoid appending multiple summaries on successive runs.

mypy/main.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ def main(script_path: Optional[str],
113113
if messages:
114114
code = 2 if blockers else 1
115115
if options.error_summary:
116-
if messages:
117-
n_errors, n_files = util.count_stats(messages)
118-
if n_errors:
119-
summary = formatter.format_error(
120-
n_errors, n_files, len(sources), blockers=blockers,
121-
use_color=options.color_output
122-
)
123-
stdout.write(summary + '\n')
124-
else:
116+
n_errors, n_notes, n_files = util.count_stats(messages)
117+
if n_errors:
118+
summary = formatter.format_error(
119+
n_errors, n_files, len(sources), blockers=blockers,
120+
use_color=options.color_output
121+
)
122+
stdout.write(summary + '\n')
123+
# Only notes should also output success
124+
elif not messages or n_notes == len(messages):
125125
stdout.write(formatter.format_success(len(sources), options.color_output) + '\n')
126126
stdout.flush()
127127

mypy/util.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,12 @@ def check_python_version(program: str) -> None:
435435
"please upgrade to 3.6 or newer".format(name=program))
436436

437437

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

444445

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

0 commit comments

Comments
 (0)