From d379a93c5d84e378f89165765480b4f55088633b Mon Sep 17 00:00:00 2001 From: Reid Barton Date: Wed, 22 Jun 2016 17:24:03 -0400 Subject: [PATCH] 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. --- test-data/unit/check-ignore.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test-data/unit/check-ignore.test b/test-data/unit/check-ignore.test index bff161eeea5d..61c7bff9c109 100644 --- a/test-data/unit/check-ignore.test +++ b/test-data/unit/check-ignore.test @@ -32,6 +32,21 @@ from xyz_m import * # type: ignore x # E: Name 'x' is not defined 1() # E: "int" not callable +[case testIgnoreImportBadModule] +import m # type: ignore +from m import a # type: ignore +[file m.py] ++ # A parse error, but we shouldn't even parse m.py +[out] + +[case testIgnoreImportStarFromBadModule] +from m import * # type: ignore +[file m.py] ++ +[out] +main:1: note: In module imported here: +tmp/m.py:1: error: Parse error before end of line + [case testIgnoreAssignmentTypeError] x = 1 x = '' # type: ignore