Skip to content

build: disallow ignoring blocking errors #9728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions mypy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -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