From cd7ea63d4b1cfab53b8d6891657b5d60affd6320 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Sat, 22 Jun 2024 00:58:43 -0700 Subject: [PATCH 1/4] add test documenting current state --- test-data/unit/check-incremental.test | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test-data/unit/check-incremental.test b/test-data/unit/check-incremental.test index ead896b8e458..3692cef7cb12 100644 --- a/test-data/unit/check-incremental.test +++ b/test-data/unit/check-incremental.test @@ -1833,6 +1833,23 @@ main:3: note: Revealed type is "builtins.int" main:3: note: Revealed type is "Any" +[case testIncrementalIgnoreErrors] +# flags: --config-file tmp/mypy.ini +import a +[file a.py] +import module_that_will_be_deleted +[file module_that_will_be_deleted.py] + +[file mypy.ini] +\[mypy] +\[mypy-a] +ignore_errors = True +[delete module_that_will_be_deleted.py.2] +[out1] +[out2] +tmp/a.py:1: error: Cannot find implementation or library stub for module named "module_that_will_be_deleted" +tmp/a.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports + [case testIncrementalNamedTupleInMethod] from ntcrash import nope [file ntcrash.py] From 6095159cdbba365826070044c2f631a513bd0d9f Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Sat, 22 Jun 2024 00:59:42 -0700 Subject: [PATCH 2/4] commit fix --- mypy/build.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mypy/build.py b/mypy/build.py index 3ceb473f0948..20ee521f39af 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -3467,8 +3467,9 @@ def process_stale_scc(graph: Graph, scc: list[str], manager: BuildManager) -> No for id in stale: graph[id].transitive_error = True for id in stale: - errors = manager.errors.file_messages(graph[id].xpath, formatter=manager.error_formatter) - manager.flush_errors(manager.errors.simplify_path(graph[id].xpath), errors, False) + if graph[id].xpath not in manager.errors.ignored_files: + errors = manager.errors.file_messages(graph[id].xpath, formatter=manager.error_formatter) + manager.flush_errors(manager.errors.simplify_path(graph[id].xpath), errors, False) graph[id].write_cache() graph[id].mark_as_rechecked() From f0e5515c89cc24e4f9cb82e16abdd02ebba18a44 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Sat, 22 Jun 2024 01:02:53 -0700 Subject: [PATCH 3/4] fix the test and fix the fix --- mypy/errors.py | 2 +- test-data/unit/check-incremental.test | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/mypy/errors.py b/mypy/errors.py index 7a937da39c20..d6dcd4e49e13 100644 --- a/mypy/errors.py +++ b/mypy/errors.py @@ -803,7 +803,7 @@ def blocker_module(self) -> str | None: def is_errors_for_file(self, file: str) -> bool: """Are there any errors for the given file?""" - return file in self.error_info_map + return file in self.error_info_map and file not in self.ignored_files def prefer_simple_messages(self) -> bool: """Should we generate simple/fast error messages? diff --git a/test-data/unit/check-incremental.test b/test-data/unit/check-incremental.test index 3692cef7cb12..24292bce3e21 100644 --- a/test-data/unit/check-incremental.test +++ b/test-data/unit/check-incremental.test @@ -1847,8 +1847,6 @@ ignore_errors = True [delete module_that_will_be_deleted.py.2] [out1] [out2] -tmp/a.py:1: error: Cannot find implementation or library stub for module named "module_that_will_be_deleted" -tmp/a.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports [case testIncrementalNamedTupleInMethod] from ntcrash import nope From 903910b071bca29edcebac7f570265ee9cafbc70 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 22 Jun 2024 08:04:44 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypy/build.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mypy/build.py b/mypy/build.py index 20ee521f39af..733f0685792e 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -3468,7 +3468,9 @@ def process_stale_scc(graph: Graph, scc: list[str], manager: BuildManager) -> No graph[id].transitive_error = True for id in stale: if graph[id].xpath not in manager.errors.ignored_files: - errors = manager.errors.file_messages(graph[id].xpath, formatter=manager.error_formatter) + errors = manager.errors.file_messages( + graph[id].xpath, formatter=manager.error_formatter + ) manager.flush_errors(manager.errors.simplify_path(graph[id].xpath), errors, False) graph[id].write_cache() graph[id].mark_as_rechecked()