Skip to content

Commit 6f67d07

Browse files
committed
Add a failing test for type ignores in dmypy
This catches a regression caused by the previous attempt to fix python#9655 where "type: ignore" comments are erroneously marked as unused in re-runs of dmypy. Ref: python#14835
1 parent 94e5df4 commit 6f67d07

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test-data/unit/daemon.test

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,3 +668,24 @@ from foo.empty import *
668668
if False:
669669
a = 1
670670
a
671+
672+
[case testReturnTypeIgnoreAfterUnknownImport]
673+
-- Return type ignores after unknown imports and unused modules are respected on the second pass.
674+
$ dmypy start -- --warn-unused-ignores --no-error-summary
675+
Daemon started
676+
$ dmypy check -- foo.py
677+
foo.py:2: error: Cannot find implementation or library stub for module named "a_module_which_does_not_exist" [import-not-found]
678+
foo.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
679+
== Return code: 1
680+
$ dmypy check -- foo.py
681+
foo.py:2: error: Cannot find implementation or library stub for module named "a_module_which_does_not_exist" [import-not-found]
682+
foo.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
683+
== Return code: 1
684+
685+
[file unused/__init__.py]
686+
[file unused/empty.py]
687+
[file foo.py]
688+
from unused.empty import *
689+
import a_module_which_does_not_exist
690+
def is_foo() -> str:
691+
return True # type: ignore

0 commit comments

Comments
 (0)