From cb36d1161d8a5a8c308dfbf01ba201b31ee9c467 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 24 Oct 2019 09:57:06 -0700 Subject: [PATCH 1/2] Add failing regression test. --- test-data/unit/check-ignore.test | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test-data/unit/check-ignore.test b/test-data/unit/check-ignore.test index 6d3d1b097556..863d5ed5cd73 100644 --- a/test-data/unit/check-ignore.test +++ b/test-data/unit/check-ignore.test @@ -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 From 4b7f667aa351a9ed3c42b31bc5dab56ef5c2131c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 24 Oct 2019 09:57:24 -0700 Subject: [PATCH 2/2] Fix whole-file ignores on Python 2.7. --- mypy/fastparse2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/fastparse2.py b/mypy/fastparse2.py index 9d85ea3486ba..b8cbef904a12 100644 --- a/mypy/fastparse2.py +++ b/mypy/fastparse2.py @@ -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,