Skip to content

Commit 03da3fc

Browse files
brandtbucherJukkaL
authored andcommitted
Enable whole-file # type: ignore comments in Python 2.7. (#7789)
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.
1 parent 1be5487 commit 03da3fc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

mypy/fastparse2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def visit_Module(self, mod: ast27.Module) -> MypyFile:
349349
self.type_ignores[ti.lineno] = parsed
350350
else:
351351
self.fail(INVALID_TYPE_IGNORE, ti.lineno, -1)
352-
body = self.fix_function_overloads(self.translate_stmt_list(mod.body))
352+
body = self.fix_function_overloads(self.translate_stmt_list(mod.body, module=True))
353353
return MypyFile(body,
354354
self.imports,
355355
False,

test-data/unit/check-ignore.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ IGNORE
246246
# type: ignore
247247
import MISSING
248248

249+
[case testIgnoreWholeModulePy27]
250+
# flags: --python-version 2.7
251+
# type: ignore
252+
IGNORE
253+
249254
[case testDontIgnoreWholeModule1]
250255
if True:
251256
# type: ignore

0 commit comments

Comments
 (0)