From 658ca1133e46cfd49d12566079678272895404a7 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Fri, 30 Oct 2020 23:38:45 -0700 Subject: [PATCH 1/2] Fix misleading error summary on compile error There's probably an issue for this somewhere. --- mypy/dmypy_server.py | 2 +- mypy/main.py | 9 +++++---- mypy/util.py | 19 +++++++++++++------ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index 157850b39ee9a..8762a05ecf943 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -743,7 +743,7 @@ def pretty_messages(self, messages: List[str], n_sources: int, 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=use_color) else: summary = self.formatter.format_success(n_sources, use_color) if summary: diff --git a/mypy/main.py b/mypy/main.py index 74758b40513e3..80c0731b0d413 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -111,11 +111,12 @@ def flush_errors(new_messages: List[str], serious: bool) -> None: if messages: n_errors, n_files = util.count_stats(messages) if n_errors: - stdout.write(formatter.format_error(n_errors, n_files, len(sources), - options.color_output) + '\n') + summary = formatter.format_error( + n_errors, n_files, len(sources), blockers=blockers, use_color=options.color_output + ) + stdout.write(summary + '\n') else: - stdout.write(formatter.format_success(len(sources), - options.color_output) + '\n') + stdout.write(formatter.format_success(len(sources), options.color_output) + '\n') stdout.flush() if options.fast_exit: # Exit without freeing objects -- it's faster. diff --git a/mypy/util.py b/mypy/util.py index 8481bab69ee9d..f148f5272d8a4 100644 --- a/mypy/util.py +++ b/mypy/util.py @@ -677,13 +677,20 @@ def format_success(self, n_sources: int, use_color: bool = True) -> str: return msg return self.style(msg, 'green', bold=True) - def format_error(self, n_errors: int, n_files: int, n_sources: int, - use_color: bool = True) -> str: + def format_error( + self, n_errors: int, n_files: int, n_sources: int, *, + blockers: bool = False, use_color: bool = True + ) -> str: """Format a short summary in case of errors.""" - msg = 'Found {} error{} in {} file{}' \ - ' (checked {} source file{})'.format(n_errors, 's' if n_errors != 1 else '', - n_files, 's' if n_files != 1 else '', - n_sources, 's' if n_sources != 1 else '') + + msg = 'Found {} error{} in {} file{}'.format( + n_errors, 's' if n_errors != 1 else '', + n_files, 's' if n_files != 1 else '' + ) + if blockers: + msg += ' (errors prevented further checking)' + else: + msg += ' (checked {} source file{})'.format(n_sources, 's' if n_sources != 1 else '') if not use_color: return msg return self.style(msg, 'red', bold=True) From 558b5f0b6bbc774ec2697a43c1f8fa36670e2315 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sat, 31 Oct 2020 00:14:19 -0700 Subject: [PATCH 2/2] fix flake8 --- mypy/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy/main.py b/mypy/main.py index 80c0731b0d413..7de1f57dfece6 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -112,7 +112,8 @@ def flush_errors(new_messages: List[str], serious: bool) -> None: 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 + n_errors, n_files, len(sources), blockers=blockers, + use_color=options.color_output ) stdout.write(summary + '\n') else: