Skip to content

Commit

Permalink
Add failing tests showing disappearing errors
Browse files Browse the repository at this point in the history
This shows two cases where errors disappear from the second run of
dmypy.

The first shows a way that "unused type ignore" errors can disappear.
The case is a little complicated, but I can't yet work out how to make
it smaller.

The second case shows how "module X has not attribute Y" errors
can disappear.
  • Loading branch information
meshy committed Jan 2, 2024
1 parent 94e5df4 commit b5cc83f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test-data/unit/daemon.test
Original file line number Diff line number Diff line change
Expand Up @@ -668,3 +668,42 @@ from foo.empty import *
if False:
a = 1
a

[case testUnusedTypeIgnorePreservedOnRerunWithIgnoredMissingImports]
$ dmypy start -- --no-error-summary --ignore-missing-imports --warn-unused-ignores
Daemon started
$ dmypy check foo
foo/main.py:3: error: Unused "type: ignore" comment [unused-ignore]
== Return code: 1
$ dmypy check foo
foo/main.py:3: error: Unused "type: ignore" comment [unused-ignore]
== Return code: 1

[file unused/__init__.py]
[file unused/submodule.py]
[file foo/empty.py]
[file foo/__init__.py]
from foo.main import *
from unused.submodule import *
[file foo/main.py]
from foo import empty
from foo.does_not_exist import *
a = 1 # type: ignore

[case testModuleDoesNotExistPreservedOnRerun]
$ dmypy start -- --no-error-summary --ignore-missing-imports
Daemon started
$ dmypy check foo
foo/main.py:1: error: Module "foo" has no attribute "does_not_exist" [attr-defined]
== Return code: 1
$ dmypy check foo
foo/main.py:1: error: Module "foo" has no attribute "does_not_exist" [attr-defined]
== Return code: 1

[file unused/__init__.py]
[file unused/submodule.py]
[file foo/__init__.py]
from foo.main import *
[file foo/main.py]
from foo import does_not_exist
from unused.submodule import *

0 comments on commit b5cc83f

Please sign in to comment.