1
0
forked from VimPlug/jedi

Get rid of Array.values() and Array.__iter__().

This commit is contained in:
Dave Halter
2015-12-10 15:56:45 +01:00
parent 3a975db0d7
commit b10a048167
5 changed files with 18 additions and 22 deletions

View File

@@ -5,6 +5,8 @@ from jedi import debug
from jedi.parser import tree
from jedi.evaluate.compiled import CompiledObject
from jedi.common import unite
CODES = {
'attribute-error': (1, AttributeError, 'Potential AttributeError.'),
@@ -160,8 +162,8 @@ def _check_for_exception_catch(evaluator, jedi_obj, exception, payload=None):
from jedi.evaluate import iterable
if isinstance(cls, iterable.Array) and cls.type == 'tuple':
# multiple exceptions
for c in cls.values():
if check_match(c, exception):
for typ in unite(cls.py__iter__()):
if check_match(typ, exception):
return True
else:
if check_match(cls, exception):

View File

@@ -17,6 +17,7 @@ from jedi._compatibility import unicode, u
from jedi.parser import tree
from jedi import debug
from jedi import common
from jedi.common import unite
from jedi import settings
from jedi.evaluate import representation as er
from jedi.evaluate import dynamic
@@ -467,9 +468,12 @@ def _check_isinstance_type(evaluator, element, search_name):
return set()
result = set()
for typ in evaluator.eval_element(classes):
for typ in (typ.values() if isinstance(typ, iterable.Array) else [typ]):
for cls_or_tup in evaluator.eval_element(classes):
if isinstance(cls_or_tup, iterable.Array) and cls_or_tup.type == 'tuple':
for typ in unite(cls_or_tup.py__iter__()):
result |= evaluator.execute(typ)
else:
result |= evaluator.execute(cls_or_tup)
return result

View File

@@ -225,12 +225,6 @@ class Array(IterableWrapper, ArrayMixin):
def name(self):
return helpers.FakeName(self.type, parent=self)
@memoize_default()
def values(self):
result = unite(self._evaluator.eval_element(v) for v in self._values())
result |= check_array_additions(self._evaluator, self)
return result
@memoize_default()
def dict_values(self):
return unite(self._evaluator.eval_element(v) for v in self._values())
@@ -321,9 +315,6 @@ class Array(IterableWrapper, ArrayMixin):
else:
return [array_node]
def __iter__(self):
return iter(self._items())
def __repr__(self):
return "<%s of %s>" % (type(self).__name__, self.atom)
@@ -396,15 +387,12 @@ class MergedArray(_FakeArray):
for types in array.py__iter__():
yield types
def values(self):
return unite((a.values() for a in self._arrays))
def py__getitem__(self, index):
return unite(self.py__iter__())
def __iter__(self):
def _items(self):
for array in self._arrays:
for a in array:
for a in array._items():
yield a
def __len__(self):

View File

@@ -372,6 +372,7 @@ def get_params(evaluator, func, var_args):
# print('\t\tnonkw', non_kw_param.parent.var_args.argument_node, )
if origin_args not in [f.parent.parent for f in first_values]:
continue
print(v)
analysis.add(evaluator, 'type-error-too-many-arguments',
v, message=m)
return param_names
@@ -380,8 +381,9 @@ def get_params(evaluator, func, var_args):
def _iterate_star_args(evaluator, array, input_node, func=None):
from jedi.evaluate.representation import Instance
if isinstance(array, iterable.Array):
for field_stmt in array: # yield from plz!
yield field_stmt
# TODO ._items is not the call we want here. Replace in the future.
for node in array._items():
yield node
elif isinstance(array, iterable.Generator):
for types in array.py__iter__():
yield iterable.AlreadyEvaluated(types)

View File

@@ -225,7 +225,7 @@ def collections_namedtuple(evaluator, obj, arguments):
fields = _fields.obj.replace(',', ' ').split()
elif isinstance(_fields, iterable.Array):
try:
fields = [v.obj for v in _fields.values()]
fields = [v.obj for v in unite(_fields.py__iter__())]
except AttributeError:
return set()
else: