forked from VimPlug/jedi
Get rid of Array.values() and Array.__iter__().
This commit is contained in:
@@ -5,6 +5,8 @@ from jedi import debug
|
|||||||
from jedi.parser import tree
|
from jedi.parser import tree
|
||||||
from jedi.evaluate.compiled import CompiledObject
|
from jedi.evaluate.compiled import CompiledObject
|
||||||
|
|
||||||
|
from jedi.common import unite
|
||||||
|
|
||||||
|
|
||||||
CODES = {
|
CODES = {
|
||||||
'attribute-error': (1, AttributeError, 'Potential AttributeError.'),
|
'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
|
from jedi.evaluate import iterable
|
||||||
if isinstance(cls, iterable.Array) and cls.type == 'tuple':
|
if isinstance(cls, iterable.Array) and cls.type == 'tuple':
|
||||||
# multiple exceptions
|
# multiple exceptions
|
||||||
for c in cls.values():
|
for typ in unite(cls.py__iter__()):
|
||||||
if check_match(c, exception):
|
if check_match(typ, exception):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
if check_match(cls, exception):
|
if check_match(cls, exception):
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from jedi._compatibility import unicode, u
|
|||||||
from jedi.parser import tree
|
from jedi.parser import tree
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi import common
|
from jedi import common
|
||||||
|
from jedi.common import unite
|
||||||
from jedi import settings
|
from jedi import settings
|
||||||
from jedi.evaluate import representation as er
|
from jedi.evaluate import representation as er
|
||||||
from jedi.evaluate import dynamic
|
from jedi.evaluate import dynamic
|
||||||
@@ -467,9 +468,12 @@ def _check_isinstance_type(evaluator, element, search_name):
|
|||||||
return set()
|
return set()
|
||||||
|
|
||||||
result = set()
|
result = set()
|
||||||
for typ in evaluator.eval_element(classes):
|
for cls_or_tup in evaluator.eval_element(classes):
|
||||||
for typ in (typ.values() if isinstance(typ, iterable.Array) else [typ]):
|
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)
|
result |= evaluator.execute(typ)
|
||||||
|
else:
|
||||||
|
result |= evaluator.execute(cls_or_tup)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -225,12 +225,6 @@ class Array(IterableWrapper, ArrayMixin):
|
|||||||
def name(self):
|
def name(self):
|
||||||
return helpers.FakeName(self.type, parent=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()
|
@memoize_default()
|
||||||
def dict_values(self):
|
def dict_values(self):
|
||||||
return unite(self._evaluator.eval_element(v) for v in self._values())
|
return unite(self._evaluator.eval_element(v) for v in self._values())
|
||||||
@@ -321,9 +315,6 @@ class Array(IterableWrapper, ArrayMixin):
|
|||||||
else:
|
else:
|
||||||
return [array_node]
|
return [array_node]
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return iter(self._items())
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s of %s>" % (type(self).__name__, self.atom)
|
return "<%s of %s>" % (type(self).__name__, self.atom)
|
||||||
|
|
||||||
@@ -396,15 +387,12 @@ class MergedArray(_FakeArray):
|
|||||||
for types in array.py__iter__():
|
for types in array.py__iter__():
|
||||||
yield types
|
yield types
|
||||||
|
|
||||||
def values(self):
|
|
||||||
return unite((a.values() for a in self._arrays))
|
|
||||||
|
|
||||||
def py__getitem__(self, index):
|
def py__getitem__(self, index):
|
||||||
return unite(self.py__iter__())
|
return unite(self.py__iter__())
|
||||||
|
|
||||||
def __iter__(self):
|
def _items(self):
|
||||||
for array in self._arrays:
|
for array in self._arrays:
|
||||||
for a in array:
|
for a in array._items():
|
||||||
yield a
|
yield a
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ def get_params(evaluator, func, var_args):
|
|||||||
# print('\t\tnonkw', non_kw_param.parent.var_args.argument_node, )
|
# print('\t\tnonkw', non_kw_param.parent.var_args.argument_node, )
|
||||||
if origin_args not in [f.parent.parent for f in first_values]:
|
if origin_args not in [f.parent.parent for f in first_values]:
|
||||||
continue
|
continue
|
||||||
|
print(v)
|
||||||
analysis.add(evaluator, 'type-error-too-many-arguments',
|
analysis.add(evaluator, 'type-error-too-many-arguments',
|
||||||
v, message=m)
|
v, message=m)
|
||||||
return param_names
|
return param_names
|
||||||
@@ -380,8 +381,9 @@ def get_params(evaluator, func, var_args):
|
|||||||
def _iterate_star_args(evaluator, array, input_node, func=None):
|
def _iterate_star_args(evaluator, array, input_node, func=None):
|
||||||
from jedi.evaluate.representation import Instance
|
from jedi.evaluate.representation import Instance
|
||||||
if isinstance(array, iterable.Array):
|
if isinstance(array, iterable.Array):
|
||||||
for field_stmt in array: # yield from plz!
|
# TODO ._items is not the call we want here. Replace in the future.
|
||||||
yield field_stmt
|
for node in array._items():
|
||||||
|
yield node
|
||||||
elif isinstance(array, iterable.Generator):
|
elif isinstance(array, iterable.Generator):
|
||||||
for types in array.py__iter__():
|
for types in array.py__iter__():
|
||||||
yield iterable.AlreadyEvaluated(types)
|
yield iterable.AlreadyEvaluated(types)
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ def collections_namedtuple(evaluator, obj, arguments):
|
|||||||
fields = _fields.obj.replace(',', ' ').split()
|
fields = _fields.obj.replace(',', ' ').split()
|
||||||
elif isinstance(_fields, iterable.Array):
|
elif isinstance(_fields, iterable.Array):
|
||||||
try:
|
try:
|
||||||
fields = [v.obj for v in _fields.values()]
|
fields = [v.obj for v in unite(_fields.py__iter__())]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return set()
|
return set()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user