mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix a small _get_annotated_class_object, fixes #1550
This commit is contained in:
@@ -332,13 +332,14 @@ class TreeInstance(_BaseTreeInstance):
|
|||||||
for signature in self.class_value.py__getattribute__('__init__').get_signatures():
|
for signature in self.class_value.py__getattribute__('__init__').get_signatures():
|
||||||
# Just take the first result, it should always be one, because we
|
# Just take the first result, it should always be one, because we
|
||||||
# control the typeshed code.
|
# control the typeshed code.
|
||||||
if not signature.matches_signature(args) \
|
funcdef = signature.value.tree_node
|
||||||
or signature.value.tree_node is None:
|
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
|
# First check if the signature even matches, if not we don't
|
||||||
# need to infer anything.
|
# need to infer anything.
|
||||||
continue
|
continue
|
||||||
bound_method = BoundMethod(self, self.class_value.as_context(), signature.value)
|
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)
|
type_var_dict = infer_type_vars_for_execution(bound_method, args, all_annotations)
|
||||||
if type_var_dict:
|
if type_var_dict:
|
||||||
defined, = self.class_value.define_generics(
|
defined, = self.class_value.define_generics(
|
||||||
|
|||||||
@@ -630,3 +630,19 @@ class C1(MyBase):
|
|||||||
self.f1() . # hey'''
|
self.f1() . # hey'''
|
||||||
#? 13 MyBase.f1
|
#? 13 MyBase.f1
|
||||||
self.f1() . # hey'''
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user