diff --git a/jedi/inference/value/instance.py b/jedi/inference/value/instance.py index 8310e881..bc06cfd4 100644 --- a/jedi/inference/value/instance.py +++ b/jedi/inference/value/instance.py @@ -332,13 +332,14 @@ class TreeInstance(_BaseTreeInstance): for signature in self.class_value.py__getattribute__('__init__').get_signatures(): # Just take the first result, it should always be one, because we # control the typeshed code. - if not signature.matches_signature(args) \ - or signature.value.tree_node is None: + funcdef = signature.value.tree_node + if funcdef is None or funcdef.type != 'funcdef' \ + or not signature.matches_signature(args): # First check if the signature even matches, if not we don't # need to infer anything. continue bound_method = BoundMethod(self, self.class_value.as_context(), signature.value) - all_annotations = py__annotations__(signature.value.tree_node) + all_annotations = py__annotations__(funcdef) type_var_dict = infer_type_vars_for_execution(bound_method, args, all_annotations) if type_var_dict: defined, = self.class_value.define_generics( diff --git a/test/completion/classes.py b/test/completion/classes.py index 04298aa3..5b7b42da 100644 --- a/test/completion/classes.py +++ b/test/completion/classes.py @@ -630,3 +630,19 @@ class C1(MyBase): self.f1() . # hey''' #? 13 MyBase.f1 self.f1() . # hey''' + +# ----------------- +# With a very weird __init__ +# ----------------- + +class WithWeirdInit: + class __init__: + def __init__(self, a): + self.a = a + + def y(self): + return self.a + + +#? +WithWeirdInit(1).y()