Fix getattr completions on very weird cases, fixes #1573

This commit is contained in:
Dave Halter
2020-05-10 11:37:58 +02:00
parent 12090ce74b
commit bf4ec2282f
2 changed files with 10 additions and 0 deletions

View File

@@ -586,6 +586,9 @@ def _complete_getattr(user_context, instance):
)
for func in functions:
tree_node = func.tree_node
if tree_node.type != 'funcdef':
continue
for return_stmt in tree_node.iter_return_stmts():
# Basically until the next comment we just try to find out if a
# return statement looks exactly like `return getattr(x, name)`.

View File

@@ -419,6 +419,13 @@ GetattrArray().something[0]
#? []
GetattrArray().something
class WeirdGetattr:
class __getattr__():
pass
#? []
WeirdGetattr().something
# -----------------
# private vars