From ac77ead1d353e0edaf5469cd64ce33fde996ad30 Mon Sep 17 00:00:00 2001 From: Charlie Denton Date: Sat, 4 Mar 2023 17:38:50 +0000 Subject: [PATCH] Add test to demonstrate issue #9655 This test currently fails with this error: AssertionError: Command 3 (dmypy check -- bar.py) did not give expected output --- Captured stderr call --- Expected: bar.py:2: error: Unused "type: ignore" comment (diff) == Return code: 1 (diff) Actual: (empty) It demonstrates a bug that when an module is removed using `FineGrainedBuildManager.update` because it is not "seen" by `fine_grained_increment_follow_imports`, then "unused type: ignore" warnings disappear from subsequent checks. Ref: https://github.com/python/mypy/issues/9655 --- test-data/unit/daemon.test | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test-data/unit/daemon.test b/test-data/unit/daemon.test index ca2c969d2f5e..07eaff0c64d4 100644 --- a/test-data/unit/daemon.test +++ b/test-data/unit/daemon.test @@ -615,3 +615,20 @@ b: str from demo.test import a [file demo/test.py] a: int + +[case testUnusedTypeIgnorePreservedOnRerun] +-- Regression test for https://github.com/python/mypy/issues/9655 +$ dmypy start -- --warn-unused-ignores --no-error-summary --hide-error-codes +Daemon started +$ dmypy check -- bar.py +bar.py:2: error: Unused "type: ignore" comment +== Return code: 1 +$ dmypy check -- bar.py +bar.py:2: error: Unused "type: ignore" comment +== Return code: 1 + +[file foo/__init__.py] +[file foo/empty.py] +[file bar.py] +from foo.empty import * +a = 1 # type: ignore