diff --git a/mypy/fastparse.py b/mypy/fastparse.py index c6fb9c957a6a..f0181b295c1f 100644 --- a/mypy/fastparse.py +++ b/mypy/fastparse.py @@ -38,6 +38,7 @@ from mypy import message_registry from mypy.errors import Errors from mypy.options import Options +from mypy.reachability import mark_block_unreachable try: # pull this into a final variable to make mypyc be quiet about the @@ -311,7 +312,7 @@ def translate_stmt_list(self, and min(self.type_ignores) < self.get_lineno(stmts[0])): self.errors.used_ignored_lines[self.errors.file].add(min(self.type_ignores)) block = Block(self.fix_function_overloads(self.translate_stmt_list(stmts))) - block.is_unreachable = True + mark_block_unreachable(block) return [block] res = [] # type: List[Statement] diff --git a/mypy/fastparse2.py b/mypy/fastparse2.py index a54a40a95005..6d9c4ca1cd20 100644 --- a/mypy/fastparse2.py +++ b/mypy/fastparse2.py @@ -47,6 +47,7 @@ from mypy.errors import Errors from mypy.fastparse import TypeConverter, parse_type_comment, bytes_to_human_readable_repr from mypy.options import Options +from mypy.reachability import mark_block_unreachable try: from typed_ast import ast27 @@ -209,7 +210,7 @@ def translate_stmt_list(self, and min(self.type_ignores) < self.get_lineno(stmts[0])): self.errors.used_ignored_lines[self.errors.file].add(min(self.type_ignores)) block = Block(self.fix_function_overloads(self.translate_stmt_list(stmts))) - block.is_unreachable = True + mark_block_unreachable(block) return [block] res = [] # type: List[Statement] diff --git a/test-data/unit/check-ignore.test b/test-data/unit/check-ignore.test index 3992819a4648..3d6411031c71 100644 --- a/test-data/unit/check-ignore.test +++ b/test-data/unit/check-ignore.test @@ -242,6 +242,10 @@ IGNORE def f(): ... IGNORE +[case testIgnoreWholeModule5] +# type: ignore +import MISSING + [case testDontIgnoreWholeModule1] if True: # type: ignore