forked from VimPlug/jedi
Try to introduce is_instance and is_function
This commit is contained in:
@@ -75,6 +75,9 @@ class FunctionContext(use_metaclass(CachedMetaClass, AbstractFunction)):
|
||||
"""
|
||||
Needed because of decorators. Decorators are evaluated here.
|
||||
"""
|
||||
def is_function(self):
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def from_context(cls, context, tree_node):
|
||||
def create(tree_node):
|
||||
@@ -92,12 +95,10 @@ class FunctionContext(use_metaclass(CachedMetaClass, AbstractFunction)):
|
||||
tree_node=tree_node
|
||||
)
|
||||
|
||||
from jedi.evaluate.context import AbstractInstanceContext
|
||||
|
||||
overloaded_funcs = list(_find_overload_functions(context, tree_node))
|
||||
|
||||
parent_context = context
|
||||
while parent_context.is_class() or isinstance(parent_context, AbstractInstanceContext):
|
||||
while parent_context.is_class() or parent_context.is_instance():
|
||||
parent_context = parent_context.parent_context
|
||||
|
||||
function = create(tree_node)
|
||||
|
||||
@@ -68,8 +68,8 @@ class AbstractInstanceContext(Context):
|
||||
self.class_context = class_context
|
||||
self.var_args = var_args
|
||||
|
||||
def is_class(self):
|
||||
return False
|
||||
def is_instance(self):
|
||||
return True
|
||||
|
||||
def get_annotated_class_object(self):
|
||||
return self.class_context # This is the default.
|
||||
@@ -114,7 +114,7 @@ class AbstractInstanceContext(Context):
|
||||
# `method` is the new parent of the array, don't know if that's good.
|
||||
names = self.get_function_slot_names(u'__get__')
|
||||
if names:
|
||||
if isinstance(obj, AbstractInstanceContext):
|
||||
if obj.is_instance():
|
||||
return self.execute_function_slots(names, obj, obj.class_context)
|
||||
else:
|
||||
none_obj = compiled.builtin_from_name(self.evaluator, u'None')
|
||||
@@ -156,7 +156,7 @@ class AbstractInstanceContext(Context):
|
||||
return
|
||||
|
||||
for generator in self.execute_function_slots(iter_slot_names):
|
||||
if isinstance(generator, AbstractInstanceContext):
|
||||
if generator.is_instance():
|
||||
# `__next__` logic.
|
||||
if self.evaluator.environment.version_info.major == 2:
|
||||
name = u'next'
|
||||
|
||||
Reference in New Issue
Block a user