forked from VimPlug/jedi
bug fixes for dynamic/iterator stuff
This commit is contained in:
@@ -104,7 +104,7 @@ def _strip_rest_role(type_str):
|
|||||||
return type_str
|
return type_str
|
||||||
|
|
||||||
|
|
||||||
def find_return_types(func):
|
def find_return_types(evaluator, func):
|
||||||
def search_return_in_docstr(code):
|
def search_return_in_docstr(code):
|
||||||
for p in DOCSTRING_RETURN_PATTERNS:
|
for p in DOCSTRING_RETURN_PATTERNS:
|
||||||
match = p.search(code)
|
match = p.search(code)
|
||||||
|
|||||||
@@ -428,8 +428,7 @@ class Builtin(object):
|
|||||||
def scope(self):
|
def scope(self):
|
||||||
return self.builtin.parser.module
|
return self.builtin.parser.module
|
||||||
|
|
||||||
@property
|
def magic_function_scope(self, evaluator):
|
||||||
def magic_function_scope(self):
|
|
||||||
try:
|
try:
|
||||||
return self._magic_function_scope
|
return self._magic_function_scope
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@@ -440,7 +439,7 @@ class Builtin(object):
|
|||||||
parser = Parser(source, None)
|
parser = Parser(source, None)
|
||||||
module = parser.module
|
module = parser.module
|
||||||
module.parent = self.scope
|
module.parent = self.scope
|
||||||
typ = evaluate.follow_path(iter(['FunctionType']), module, module)
|
typ = evaluator.follow_path(iter(['FunctionType']), module, module)
|
||||||
|
|
||||||
s = self._magic_function_scope = typ.pop()
|
s = self._magic_function_scope = typ.pop()
|
||||||
return s
|
return s
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ def check_array_additions(evaluator, array):
|
|||||||
|
|
||||||
is_list = array._array.type == 'list'
|
is_list = array._array.type == 'list'
|
||||||
current_module = array._array.get_parent_until()
|
current_module = array._array.get_parent_until()
|
||||||
res = _check_array_additions(array, current_module, is_list)
|
res = _check_array_additions(evaluator, array, current_module, is_list)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
@@ -345,10 +345,11 @@ def _check_array_additions(evaluator, compare_array, module, is_list):
|
|||||||
elif add_name in ['extend', 'update']:
|
elif add_name in ['extend', 'update']:
|
||||||
for param in params:
|
for param in params:
|
||||||
iterators = evaluator.follow_statement(param)
|
iterators = evaluator.follow_statement(param)
|
||||||
result += evaluator.get_iterator_types(iterators)
|
result += evaluate.get_iterator_types(iterators)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
from jedi.evaluate import representation as er
|
from jedi.evaluate import representation as er
|
||||||
|
from jedi import evaluate
|
||||||
|
|
||||||
def get_execution_parent(element, *stop_classes):
|
def get_execution_parent(element, *stop_classes):
|
||||||
""" Used to get an Instance/Execution parent """
|
""" Used to get an Instance/Execution parent """
|
||||||
@@ -425,10 +426,10 @@ class ArrayInstance(pr.Base):
|
|||||||
lists/sets are too complicated too handle that.
|
lists/sets are too complicated too handle that.
|
||||||
"""
|
"""
|
||||||
items = []
|
items = []
|
||||||
from jedi.evaluate import representation as er
|
from jedi import evaluate
|
||||||
for stmt in self.var_args:
|
for stmt in self.var_args:
|
||||||
for typ in self._evaluator.follow_statement(stmt):
|
for typ in self._evaluator.follow_statement(stmt):
|
||||||
if isinstance(typ, er.Instance) and len(typ.var_args):
|
if isinstance(typ, evaluate.er.Instance) and len(typ.var_args):
|
||||||
array = typ.var_args[0]
|
array = typ.var_args[0]
|
||||||
if isinstance(array, ArrayInstance):
|
if isinstance(array, ArrayInstance):
|
||||||
# prevent recursions
|
# prevent recursions
|
||||||
@@ -440,7 +441,7 @@ class ArrayInstance(pr.Base):
|
|||||||
'ArrayInstance recursion',
|
'ArrayInstance recursion',
|
||||||
self.var_args)
|
self.var_args)
|
||||||
continue
|
continue
|
||||||
items += self._evaluator.get_iterator_types([typ])
|
items += evaluate.get_iterator_types([typ])
|
||||||
|
|
||||||
# TODO check if exclusion of tuple is a problem here.
|
# TODO check if exclusion of tuple is a problem here.
|
||||||
if isinstance(self.var_args, tuple) or self.var_args.parent is None:
|
if isinstance(self.var_args, tuple) or self.var_args.parent is None:
|
||||||
@@ -448,7 +449,7 @@ class ArrayInstance(pr.Base):
|
|||||||
|
|
||||||
module = self.var_args.get_parent_until()
|
module = self.var_args.get_parent_until()
|
||||||
is_list = str(self.instance.name) == 'list'
|
is_list = str(self.instance.name) == 'list'
|
||||||
items += _check_array_additions(self.instance, module, is_list)
|
items += _check_array_additions(self._evaluator, self.instance, module, is_list)
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -384,10 +384,10 @@ class Function(use_metaclass(CachedMetaClass, pr.IsScope)):
|
|||||||
return decorated_func
|
return decorated_func
|
||||||
|
|
||||||
def get_magic_method_names(self):
|
def get_magic_method_names(self):
|
||||||
return builtin.Builtin.magic_function_scope.get_defined_names()
|
return builtin.Builtin.magic_function_scope(self._evaluator).get_defined_names()
|
||||||
|
|
||||||
def get_magic_method_scope(self):
|
def get_magic_method_scope(self):
|
||||||
return builtin.Builtin.magic_function_scope
|
return builtin.Builtin.magic_function_scope(self._evaluator)
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return getattr(self.base_func, name)
|
return getattr(self.base_func, name)
|
||||||
@@ -860,7 +860,7 @@ class Array(use_metaclass(CachedMetaClass, pr.Base, Iterable)):
|
|||||||
return self.get_exact_index_types(index.var_args[0])
|
return self.get_exact_index_types(index.var_args[0])
|
||||||
|
|
||||||
result = list(self._follow_values(self._array.values))
|
result = list(self._follow_values(self._array.values))
|
||||||
result += dynamic.check_array_additions(evaluator, self)
|
result += dynamic.check_array_additions(self._evaluator, self)
|
||||||
return set(result)
|
return set(result)
|
||||||
|
|
||||||
def get_exact_index_types(self, mixed_index):
|
def get_exact_index_types(self, mixed_index):
|
||||||
|
|||||||
Reference in New Issue
Block a user