Skip to content

Commit

Permalink
Enable whole-file # type: ignore comments in Python 2.7. (#7789)
Browse files Browse the repository at this point in the history
Fixes #7785. This was a mistake in my original PR that introduced the feature 
(#6830). I forgot to copy one of the changes in `fastparse.py` to `fastparse2.py`.

It's an embarrassingly simple fix. I also included a regression test for good measure.
  • Loading branch information
brandtbucher authored and JukkaL committed Oct 30, 2019
1 parent 1be5487 commit 03da3fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/fastparse2.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def visit_Module(self, mod: ast27.Module) -> MypyFile:
self.type_ignores[ti.lineno] = parsed
else:
self.fail(INVALID_TYPE_IGNORE, ti.lineno, -1)
body = self.fix_function_overloads(self.translate_stmt_list(mod.body))
body = self.fix_function_overloads(self.translate_stmt_list(mod.body, module=True))
return MypyFile(body,
self.imports,
False,
Expand Down
5 changes: 5 additions & 0 deletions test-data/unit/check-ignore.test
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ IGNORE
# type: ignore
import MISSING

[case testIgnoreWholeModulePy27]
# flags: --python-version 2.7
# type: ignore
IGNORE

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

0 comments on commit 03da3fc

Please sign in to comment.