Skip to content

Commit

Permalink
Add a failing test for type ignores in dmypy
Browse files Browse the repository at this point in the history
This catches a regression caused by the previous commits where "type:
ignore" comments are erroneously marked as unused in re-runs of dmypy.

As far as I can tell, this only happens in modules which contain an
import that we don't know how to type (such as a module which does not
exist), and a submodule which is unused.
  • Loading branch information
meshy committed Jul 15, 2023
1 parent cb61a61 commit fd8b35a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test-data/unit/daemon.test
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,24 @@ from foo.empty import *
if False:
a = 1
a

[case testReturnTypeIgnoreAfterUnknownImport]
-- Return type ignores after unknown imports and unused modules are respected on the second pass.
$ dmypy start -- --warn-unused-ignores --no-error-summary
Daemon started
$ dmypy check -- foo.py
foo.py:2: error: Cannot find implementation or library stub for module named "a_module_which_does_not_exist" [import]
foo.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
== Return code: 1
$ dmypy check -- foo.py
foo.py:2: error: Cannot find implementation or library stub for module named "a_module_which_does_not_exist" [import]
foo.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
== Return code: 1

[file unused/__init__.py]
[file unused/empty.py]
[file foo.py]
from unused.empty import *
import a_module_which_does_not_exist
def is_foo() -> str:
return True # type: ignore

0 comments on commit fd8b35a

Please sign in to comment.