diff --git a/jedi/evaluate/compiled/__init__.py b/jedi/evaluate/compiled/__init__.py index 109c1b30..770c8e62 100644 --- a/jedi/evaluate/compiled/__init__.py +++ b/jedi/evaluate/compiled/__init__.py @@ -93,15 +93,26 @@ class CompiledObject(Base): else: raise KeyError("CompiledObject doesn't have an attribute '%s'." % name) - def get_index_types(self, mixed_obj): + def get_index_types(self, index_types): # If the object doesn't have `__getitem__`, just raise the # AttributeError. self.obj.__getitem__ - try: - self.obj[mixed_obj] - except (KeyError, IndexError): - raise AttributeError() + result = [] + from jedi.evaluate import iterable + for typ in index_types: + if isinstance(typ, iterable.Slice): + result.append(self) + else: + try: + new = self.obj[typ.obj] + except (KeyError, IndexError): + pass + else: + result.append(CompiledObject(new)) + if not result: + pass + return result @property def name(self): diff --git a/jedi/evaluate/iterable.py b/jedi/evaluate/iterable.py index d4414361..1b0383df 100644 --- a/jedi/evaluate/iterable.py +++ b/jedi/evaluate/iterable.py @@ -99,7 +99,11 @@ class Array(use_metaclass(CachedMetaClass, pr.Base)): self._array = array def get_index_types(self, indexes=[]): - """ Get the types of a specific index or all, if not given """ + """ + Get the types of a specific index or all, if not given. + + :param indexes: The index input types. + """ result = [] if [index for index in indexes if isinstance(index, Slice)]: return [self]