Skip to content

Commit 7e66e51

Browse files
authored
Fix misleading error summary on compile error (#9674)
I think there's an issue for this somewhere too. Co-authored-by: hauntsaninja <>
1 parent f6fb60e commit 7e66e51

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

mypy/dmypy_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ def pretty_messages(self, messages: List[str], n_sources: int,
743743
n_errors, n_files = count_stats(messages)
744744
if n_errors:
745745
summary = self.formatter.format_error(n_errors, n_files, n_sources,
746-
use_color)
746+
use_color=use_color)
747747
else:
748748
summary = self.formatter.format_success(n_sources, use_color)
749749
if summary:

mypy/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ def flush_errors(new_messages: List[str], serious: bool) -> None:
111111
if messages:
112112
n_errors, n_files = util.count_stats(messages)
113113
if n_errors:
114-
stdout.write(formatter.format_error(n_errors, n_files, len(sources),
115-
options.color_output) + '\n')
114+
summary = formatter.format_error(
115+
n_errors, n_files, len(sources), blockers=blockers,
116+
use_color=options.color_output
117+
)
118+
stdout.write(summary + '\n')
116119
else:
117-
stdout.write(formatter.format_success(len(sources),
118-
options.color_output) + '\n')
120+
stdout.write(formatter.format_success(len(sources), options.color_output) + '\n')
119121
stdout.flush()
120122
if options.fast_exit:
121123
# Exit without freeing objects -- it's faster.

mypy/util.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,13 +680,20 @@ def format_success(self, n_sources: int, use_color: bool = True) -> str:
680680
return msg
681681
return self.style(msg, 'green', bold=True)
682682

683-
def format_error(self, n_errors: int, n_files: int, n_sources: int,
684-
use_color: bool = True) -> str:
683+
def format_error(
684+
self, n_errors: int, n_files: int, n_sources: int, *,
685+
blockers: bool = False, use_color: bool = True
686+
) -> str:
685687
"""Format a short summary in case of errors."""
686-
msg = 'Found {} error{} in {} file{}' \
687-
' (checked {} source file{})'.format(n_errors, 's' if n_errors != 1 else '',
688-
n_files, 's' if n_files != 1 else '',
689-
n_sources, 's' if n_sources != 1 else '')
688+
689+
msg = 'Found {} error{} in {} file{}'.format(
690+
n_errors, 's' if n_errors != 1 else '',
691+
n_files, 's' if n_files != 1 else ''
692+
)
693+
if blockers:
694+
msg += ' (errors prevented further checking)'
695+
else:
696+
msg += ' (checked {} source file{})'.format(n_sources, 's' if n_sources != 1 else '')
690697
if not use_color:
691698
return msg
692699
return self.style(msg, 'red', bold=True)

0 commit comments

Comments
 (0)