From 2d6a7ec518db01f525a4e8d75699e93ff9e6eaf0 Mon Sep 17 00:00:00 2001 From: David Fisher Date: Wed, 6 Jul 2016 15:00:40 -0700 Subject: [PATCH] Fix crash when function annotation has more args than function --- mypy/semanal.py | 2 +- test-data/unit/check-fastparse.test | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mypy/semanal.py b/mypy/semanal.py index c0aea9585c2b..ad3b37ffb73b 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -542,7 +542,7 @@ def check_function_signature(self, fdef: FuncItem) -> None: extra_anys = [AnyType()] * (len(fdef.arguments) - len(sig.arg_types)) sig.arg_types.extend(extra_anys) elif len(sig.arg_types) > len(fdef.arguments): - self.fail('Type signature has too many arguments', fdef) + self.fail('Type signature has too many arguments', fdef, blocker=True) def visit_class_def(self, defn: ClassDef) -> None: self.clean_up_bases_and_infer_type_variables(defn) diff --git a/test-data/unit/check-fastparse.test b/test-data/unit/check-fastparse.test index eecacafe9c26..7ef5bd34e0ed 100644 --- a/test-data/unit/check-fastparse.test +++ b/test-data/unit/check-fastparse.test @@ -154,3 +154,19 @@ def f(a, # type: A [builtins fixtures/dict.py] [out] main: note: In function "f": + +[case testFasterParseTooManyArgumentsAnnotation] +# options: fast_parser +def f(): # E: Type signature has too many arguments + # type: (int) -> None + pass +[out] +main: note: In function "f": + +[case testFasterParseTooFewArgumentsAnnotation] +# options: fast_parser +def f(x): # E: Type signature has too few arguments + # type: () -> None + pass +[out] +main: note: In function "f":