Skip to content

Fix whole-file # type: ignore comments. #6853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -309,7 +310,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]
Expand Down
3 changes: 2 additions & 1 deletion mypy/fastparse2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -207,7 +208,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]
Expand Down
4 changes: 4 additions & 0 deletions test-data/unit/check-ignore.test
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ IGNORE
def f(): ...
IGNORE

[case testIgnoreWholeModule5]
# type: ignore
import MISSING

[case testDontIgnoreWholeModule1]
if True:
# type: ignore
Expand Down