diff --git a/mypy/build.py b/mypy/build.py index d956a828fed7..d70b421c380b 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -2748,7 +2748,8 @@ def load_graph(sources: List[BuildSource], manager: BuildManager, manager.errors.set_file(st.xpath, st.id) manager.errors.report( -1, -1, - "Duplicate module named '%s' (also at '%s')" % (st.id, graph[st.id].xpath) + "Duplicate module named '%s' (also at '%s')" % (st.id, graph[st.id].xpath), + blocker=True, ) p1 = len(pathlib.PurePath(st.xpath).parents) p2 = len(pathlib.PurePath(graph[st.id].xpath).parents) diff --git a/mypy/errors.py b/mypy/errors.py index 465bc5f0cabd..a3fb761ac74f 100644 --- a/mypy/errors.py +++ b/mypy/errors.py @@ -316,7 +316,7 @@ def report(self, if end_line is None: end_line = origin_line - code = code or codes.MISC + code = code or (codes.MISC if not blocker else None) info = ErrorInfo(self.import_context(), file, self.current_module(), type, function, line, column, severity, message, code, @@ -357,14 +357,17 @@ def add_error_info(self, info: ErrorInfo) -> None: self._add_error_info(file, info) def is_ignored_error(self, line: int, info: ErrorInfo, ignores: Dict[int, List[str]]) -> bool: + if info.blocker: + # Blocking errors can never be ignored + return False if info.code and self.is_error_code_enabled(info.code) is False: return True - elif line not in ignores: + if line not in ignores: return False - elif not ignores[line]: + if not ignores[line]: # Empty list means that we ignore all errors return True - elif info.code and self.is_error_code_enabled(info.code) is True: + if info.code and self.is_error_code_enabled(info.code) is True: return info.code.code in ignores[line] return False diff --git a/test-data/unit/cmdline.test b/test-data/unit/cmdline.test index 271b7c4f3e68..490831e959a0 100644 --- a/test-data/unit/cmdline.test +++ b/test-data/unit/cmdline.test @@ -1241,3 +1241,14 @@ class Thing: ... [out] Success: no issues found in 1 source file == Return code: 0 + +[case testBlocker] +# cmd: mypy pkg --error-summary --disable-error-code syntax +[file pkg/x.py] +public static void main(String[] args) +[file pkg/y.py] +x: str = 0 +[out] +pkg/x.py:1: error: invalid syntax +Found 1 error in 1 file (errors prevented further checking) +== Return code: 2