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 attempt to fix python#9655
where "type: ignore" comments are erroneously marked as unused in
re-runs of dmypy.

Ref: python#14835
  • Loading branch information
meshy committed Jan 2, 2024
1 parent b5cc83f commit 5a55ab1
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 @@ -707,3 +707,24 @@ from foo.main import *
[file foo/main.py]
from foo import does_not_exist
from unused.submodule import *

[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-not-found]
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-not-found]
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 5a55ab1

Please sign in to comment.