mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 05:54:25 +08:00
Fix annotations on self attributes, fixes #1681
This commit is contained in:
@@ -501,6 +501,18 @@ class SelfName(TreeNameDefinition):
|
||||
def get_defining_qualified_value(self):
|
||||
return self._instance
|
||||
|
||||
def infer(self):
|
||||
stmt = search_ancestor(self.tree_name, 'expr_stmt')
|
||||
if stmt is not None:
|
||||
if stmt.children[1].type == "annassign":
|
||||
from jedi.inference.gradual.annotation import infer_annotation
|
||||
values = infer_annotation(
|
||||
self.parent_context, stmt.children[1].children[1]
|
||||
).execute_annotation()
|
||||
if values:
|
||||
return values
|
||||
return super().infer()
|
||||
|
||||
|
||||
class LazyInstanceClassName(NameWrapper):
|
||||
def __init__(self, instance, class_member_name):
|
||||
|
||||
@@ -179,3 +179,13 @@ def argskwargs(*args: int, **kwargs: float):
|
||||
next(iter(kwargs.keys()))
|
||||
#? float()
|
||||
kwargs['']
|
||||
|
||||
|
||||
class NotCalledClass:
|
||||
def __init__(self, x):
|
||||
self.x: int = x
|
||||
self.y: int = ''
|
||||
#? int()
|
||||
self.x
|
||||
#? int()
|
||||
self.y
|
||||
|
||||
Reference in New Issue
Block a user