From 5d2742b1196e9513245ab0ec7ac74c928c5f983f Mon Sep 17 00:00:00 2001 From: daleselaji-dev Date: Wed, 5 Aug 2026 11:15:29 +0800 Subject: [PATCH] Reset errors before reloading suggestion targets --- mypy/suggestions.py | 1 + test-data/unit/daemon.test | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/mypy/suggestions.py b/mypy/suggestions.py index 39a220e34091e..83fe339c4b8f6 100644 --- a/mypy/suggestions.py +++ b/mypy/suggestions.py @@ -707,6 +707,7 @@ def reload(self, state: State) -> list[str]: """Recheck the module given by state.""" assert state.path is not None self.fgmanager.flush_cache() + self.manager.errors.reset() return self.fgmanager.update([(state.id, state.path)], []) def ensure_loaded(self, state: State, force: bool = False) -> MypyFile: diff --git a/test-data/unit/daemon.test b/test-data/unit/daemon.test index 448af5d080029..f620a26da79da 100644 --- a/test-data/unit/daemon.test +++ b/test-data/unit/daemon.test @@ -370,6 +370,13 @@ bar.py:3: (str) bar.py:4: (arg=str) $ dmypy suggest foo.foo (str) -> int +$ {python} -c "print('reveal_type(1)')" >note.py +$ dmypy check foo.py bar.py note.py +note.py:1: note: Revealed type is "Literal[1]?" +== Return code: 1 +$ dmypy suggest --callsites foo.foo +bar.py:3: (str) +bar.py:4: (arg=str) $ {python} -c "import shutil; shutil.copy('foo2.py', 'foo.py')" $ dmypy check foo.py bar.py bar.py:3: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] @@ -391,6 +398,8 @@ from foo import foo def bar() -> None: x = foo('abc') # type: str foo(arg='xyz') +[file note.py] +reveal_type(1) [case testDaemonInspectCheck] $ dmypy start