From c28b5257b528f65a028e7d0dbecbcd81c7997356 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Sat, 22 Jun 2024 23:44:33 -0700 Subject: [PATCH] [1.10 backport] Fix error reporting on cached run after uninstallation of third party library (#17422) --- mypy/build.py | 11 ++++++----- mypy/errors.py | 2 +- mypy/version.py | 2 +- test-data/unit/check-incremental.test | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/mypy/build.py b/mypy/build.py index 65a06211c87e..45363596713e 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -3459,11 +3459,12 @@ 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: - manager.flush_errors( - manager.errors.simplify_path(graph[id].xpath), - manager.errors.file_messages(graph[id].xpath), - False, - ) + if graph[id].xpath not in manager.errors.ignored_files: + manager.flush_errors( + manager.errors.simplify_path(graph[id].xpath), + manager.errors.file_messages(graph[id].xpath), + False, + ) graph[id].write_cache() graph[id].mark_as_rechecked() diff --git a/mypy/errors.py b/mypy/errors.py index eabe96a2dc73..1782e4034d6d 100644 --- a/mypy/errors.py +++ b/mypy/errors.py @@ -802,7 +802,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/mypy/version.py b/mypy/version.py index 23f3a50c1e92..59abc40192af 100644 --- a/mypy/version.py +++ b/mypy/version.py @@ -8,7 +8,7 @@ # - Release versions have the form "1.2.3". # - Dev versions have the form "1.2.3+dev" (PLUS sign to conform to PEP 440). # - Before 1.0 we had the form "0.NNN". -__version__ = "1.10.0" +__version__ = "1.10.1" base_version = __version__ mypy_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) diff --git a/test-data/unit/check-incremental.test b/test-data/unit/check-incremental.test index a7f4fafc579e..06922c70637a 100644 --- a/test-data/unit/check-incremental.test +++ b/test-data/unit/check-incremental.test @@ -1833,6 +1833,21 @@ 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] + [case testIncrementalNamedTupleInMethod] from ntcrash import nope [file ntcrash.py]