1
0
forked from VimPlug/jedi

bug fixes for dynamic/iterator stuff

This commit is contained in:
Dave Halter
2013-12-25 18:28:56 +01:00
parent 5d486f0e3c
commit d86f180d2e
4 changed files with 13 additions and 13 deletions

View File

@@ -104,7 +104,7 @@ def _strip_rest_role(type_str):
return type_str
def find_return_types(func):
def find_return_types(evaluator, func):
def search_return_in_docstr(code):
for p in DOCSTRING_RETURN_PATTERNS:
match = p.search(code)

View File

@@ -428,8 +428,7 @@ class Builtin(object):
def scope(self):
return self.builtin.parser.module
@property
def magic_function_scope(self):
def magic_function_scope(self, evaluator):
try:
return self._magic_function_scope
except AttributeError:
@@ -440,7 +439,7 @@ class Builtin(object):
parser = Parser(source, None)
module = parser.module
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()
return s

View File

@@ -257,7 +257,7 @@ def check_array_additions(evaluator, array):
is_list = array._array.type == 'list'
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
@@ -345,10 +345,11 @@ def _check_array_additions(evaluator, compare_array, module, is_list):
elif add_name in ['extend', 'update']:
for param in params:
iterators = evaluator.follow_statement(param)
result += evaluator.get_iterator_types(iterators)
result += evaluate.get_iterator_types(iterators)
return result
from jedi.evaluate import representation as er
from jedi import evaluate
def get_execution_parent(element, *stop_classes):
""" Used to get an Instance/Execution parent """
@@ -425,10 +426,10 @@ class ArrayInstance(pr.Base):
lists/sets are too complicated too handle that.
"""
items = []
from jedi.evaluate import representation as er
from jedi import evaluate
for stmt in self.var_args:
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]
if isinstance(array, ArrayInstance):
# prevent recursions
@@ -440,7 +441,7 @@ class ArrayInstance(pr.Base):
'ArrayInstance recursion',
self.var_args)
continue
items += self._evaluator.get_iterator_types([typ])
items += evaluate.get_iterator_types([typ])
# TODO check if exclusion of tuple is a problem here.
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()
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

View File

@@ -384,10 +384,10 @@ class Function(use_metaclass(CachedMetaClass, pr.IsScope)):
return decorated_func
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):
return builtin.Builtin.magic_function_scope
return builtin.Builtin.magic_function_scope(self._evaluator)
def __getattr__(self, 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])
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)
def get_exact_index_types(self, mixed_index):