Skip to content

Commit fadb27f

Browse files
authored
build: disallow ignoring blocking errors (#9728)
Fixes #9727 (and effectively also adds a test for #9674) Co-authored-by: hauntsaninja <>
1 parent 260ac5f commit fadb27f

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

mypy/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,8 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
27482748
manager.errors.set_file(st.xpath, st.id)
27492749
manager.errors.report(
27502750
-1, -1,
2751-
"Duplicate module named '%s' (also at '%s')" % (st.id, graph[st.id].xpath)
2751+
"Duplicate module named '%s' (also at '%s')" % (st.id, graph[st.id].xpath),
2752+
blocker=True,
27522753
)
27532754
p1 = len(pathlib.PurePath(st.xpath).parents)
27542755
p2 = len(pathlib.PurePath(graph[st.id].xpath).parents)

mypy/errors.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def report(self,
316316
if end_line is None:
317317
end_line = origin_line
318318

319-
code = code or codes.MISC
319+
code = code or (codes.MISC if not blocker else None)
320320

321321
info = ErrorInfo(self.import_context(), file, self.current_module(), type,
322322
function, line, column, severity, message, code,
@@ -357,14 +357,17 @@ def add_error_info(self, info: ErrorInfo) -> None:
357357
self._add_error_info(file, info)
358358

359359
def is_ignored_error(self, line: int, info: ErrorInfo, ignores: Dict[int, List[str]]) -> bool:
360+
if info.blocker:
361+
# Blocking errors can never be ignored
362+
return False
360363
if info.code and self.is_error_code_enabled(info.code) is False:
361364
return True
362-
elif line not in ignores:
365+
if line not in ignores:
363366
return False
364-
elif not ignores[line]:
367+
if not ignores[line]:
365368
# Empty list means that we ignore all errors
366369
return True
367-
elif info.code and self.is_error_code_enabled(info.code) is True:
370+
if info.code and self.is_error_code_enabled(info.code) is True:
368371
return info.code.code in ignores[line]
369372
return False
370373

test-data/unit/cmdline.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,3 +1241,14 @@ class Thing: ...
12411241
[out]
12421242
Success: no issues found in 1 source file
12431243
== Return code: 0
1244+
1245+
[case testBlocker]
1246+
# cmd: mypy pkg --error-summary --disable-error-code syntax
1247+
[file pkg/x.py]
1248+
public static void main(String[] args)
1249+
[file pkg/y.py]
1250+
x: str = 0
1251+
[out]
1252+
pkg/x.py:1: error: invalid syntax
1253+
Found 1 error in 1 file (errors prevented further checking)
1254+
== Return code: 2

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy