mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-25 01:38:36 +08:00
Implement the descriptor protocoll properly for instances.
This commit is contained in:
@@ -72,6 +72,7 @@ class NameFinder(object):
|
|||||||
# It's possibly the only api dependency.
|
# It's possibly the only api dependency.
|
||||||
from jedi.api.interpreter import InterpreterNamespace
|
from jedi.api.interpreter import InterpreterNamespace
|
||||||
result = []
|
result = []
|
||||||
|
self.maybe_descriptor = isinstance(self.scope, er.Class)
|
||||||
for name_list_scope, name_list in scope_names_generator:
|
for name_list_scope, name_list in scope_names_generator:
|
||||||
break_scopes = []
|
break_scopes = []
|
||||||
if not isinstance(name_list_scope, compiled.CompiledObject):
|
if not isinstance(name_list_scope, compiled.CompiledObject):
|
||||||
@@ -114,6 +115,11 @@ class NameFinder(object):
|
|||||||
if result:
|
if result:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if isinstance(self.scope, er.Instance):
|
||||||
|
# After checking the dictionary of an instance (self
|
||||||
|
# attributes), an attribute maybe a descriptor.
|
||||||
|
self.maybe_descriptor = True
|
||||||
|
|
||||||
scope_txt = (self.scope if self.scope == name_list_scope
|
scope_txt = (self.scope if self.scope == name_list_scope
|
||||||
else '%s-%s' % (self.scope, name_list_scope))
|
else '%s-%s' % (self.scope, name_list_scope))
|
||||||
debug.dbg('finder.filter_name "%s" in (%s): %s@%s', self.name_str,
|
debug.dbg('finder.filter_name "%s" in (%s): %s@%s', self.name_str,
|
||||||
@@ -332,6 +338,8 @@ class NameFinder(object):
|
|||||||
|
|
||||||
def _resolve_descriptors(self, types):
|
def _resolve_descriptors(self, types):
|
||||||
"""Processes descriptors"""
|
"""Processes descriptors"""
|
||||||
|
if not self.maybe_descriptor:
|
||||||
|
return types
|
||||||
result = []
|
result = []
|
||||||
for r in types:
|
for r in types:
|
||||||
if isinstance(self.scope, (er.Instance, er.Class)) \
|
if isinstance(self.scope, (er.Instance, er.Class)) \
|
||||||
|
|||||||
Reference in New Issue
Block a user