Skip to content

Commit d379a93

Browse files
authored
Add tests for the behavior of # type: ignore on import statements (#1740)
These should cause mypy to skip processing the imported module entirely, which I tried to break in #1737.
1 parent 184fb28 commit d379a93

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test-data/unit/check-ignore.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ from xyz_m import * # type: ignore
3232
x # E: Name 'x' is not defined
3333
1() # E: "int" not callable
3434

35+
[case testIgnoreImportBadModule]
36+
import m # type: ignore
37+
from m import a # type: ignore
38+
[file m.py]
39+
+ # A parse error, but we shouldn't even parse m.py
40+
[out]
41+
42+
[case testIgnoreImportStarFromBadModule]
43+
from m import * # type: ignore
44+
[file m.py]
45+
+
46+
[out]
47+
main:1: note: In module imported here:
48+
tmp/m.py:1: error: Parse error before end of line
49+
3550
[case testIgnoreAssignmentTypeError]
3651
x = 1
3752
x = '' # type: ignore

0 commit comments

Comments
 (0)