From 3915aa06392f4cd104c5f3c27cfca198d86d247b Mon Sep 17 00:00:00 2001 From: Kacper Date: Tue, 21 Jul 2020 14:31:19 +0200 Subject: [PATCH] AttributeError exception in build_unannotated_method_args (#429) * AttributeError exception in build_unannotated_method_args * assigning [] to arguments if AttributeError Co-authored-by: Kacper Szmigiel --- mypy_django_plugin/lib/helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mypy_django_plugin/lib/helpers.py b/mypy_django_plugin/lib/helpers.py index ee0cf61..c99f2f8 100644 --- a/mypy_django_plugin/lib/helpers.py +++ b/mypy_django_plugin/lib/helpers.py @@ -311,7 +311,11 @@ def add_new_sym_for_info(info: TypeInfo, *, name: str, sym_type: MypyType) -> No def build_unannotated_method_args(method_node: FuncDef) -> Tuple[List[Argument], MypyType]: prepared_arguments = [] - for argument in method_node.arguments[1:]: + try: + arguments = method_node.arguments[1:] + except AttributeError: + arguments = [] + for argument in arguments: argument.type_annotation = AnyType(TypeOfAny.unannotated) prepared_arguments.append(argument) return_type = AnyType(TypeOfAny.unannotated)