diff --git a/jedi/evaluate_representation.py b/jedi/evaluate_representation.py index 8446f80e..85bbcd84 100644 --- a/jedi/evaluate_representation.py +++ b/jedi/evaluate_representation.py @@ -220,6 +220,10 @@ class InstanceElement(use_metaclass(cache.CachedMetaClass, pr.Base)): if not isinstance(command, unicode) else command for command in self.var.get_commands()] + def __iter__(self): + for el in self.var.__iter__(): + yield InstanceElement(self.instance, el, self.is_class_var) + def __getattr__(self, name): return getattr(self.var, name) diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index b71f38c0..3b341b1b 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -1260,9 +1260,11 @@ class Array(Call): This is not only used for calls on the actual object, but for ducktyping, to invoke this function with anything as `self`. """ - if isinstance(instance, Array): + try: if instance.type in types: return True + except AttributeError: + pass return False def __len__(self): diff --git a/test/completion/arrays.py b/test/completion/arrays.py index 1589fae8..ea3cbcf8 100644 --- a/test/completion/arrays.py +++ b/test/completion/arrays.py @@ -154,9 +154,9 @@ def a(): return '' class C(): def __init__(self): - self.a = (int(1)).real + self.a = (str()).upper() -#? int() +#? str() C().a # -----------------