예제 #1
0
    def py__simple_getitem__(self, index):
        if isinstance(index, slice):
            return ValueSet([self])

        with reraise_getitem_errors(IndexError, TypeError):
            lazy_value = self._lazy_value_list[index]
        return lazy_value.infer()
예제 #2
0
파일: value.py 프로젝트: steff456/jedi
    def py__simple_getitem__(self, index):
        with reraise_getitem_errors(IndexError, KeyError, TypeError):
            access = self.access_handle.py__simple_getitem__(index)
        if access is None:
            return NO_VALUES

        return ValueSet([create_from_access_path(self.inference_state, access)])
예제 #3
0
 def py__simple_getitem__(self, index):
     """Here the index is an int/str. Raises IndexError/KeyError."""
     if isinstance(index, slice):
         return ValueSet([self])
     else:
         with reraise_getitem_errors(TypeError, KeyError, IndexError):
             node = self.get_tree_entries()[index]
         return self._defining_context.infer_node(node)
예제 #4
0
    def py__simple_getitem__(self, index):
        if isinstance(index, slice):
            return ValueSet([self])

        all_types = list(self.py__iter__())
        with reraise_getitem_errors(IndexError, TypeError):
            lazy_value = all_types[index]
        return lazy_value.infer()
예제 #5
0
    def py__simple_getitem__(self, index):
        with reraise_getitem_errors(IndexError, KeyError, TypeError):
            try:
                access = self.access_handle.py__simple_getitem__(index)
            except AttributeError:
                return super(CompiledValue, self).py__simple_getitem__(index)
        if access is None:
            return NO_VALUES

        return ValueSet([create_from_access_path(self.inference_state, access)])
예제 #6
0
    def py__simple_getitem__(self, index):
        if is_py3 and self.inference_state.environment.version_info.major == 2:
            # In Python 2 bytes and unicode compare.
            if isinstance(index, bytes):
                index_unicode = force_unicode(index)
                try:
                    return self._dct[index_unicode].infer()
                except KeyError:
                    pass
            elif isinstance(index, str):
                index_bytes = index.encode('utf-8')
                try:
                    return self._dct[index_bytes].infer()
                except KeyError:
                    pass

        with reraise_getitem_errors(KeyError, TypeError):
            lazy_value = self._dct[index]
        return lazy_value.infer()
예제 #7
0
 def py__simple_getitem__(self, index):
     with reraise_getitem_errors(KeyError, TypeError):
         lazy_value = self._dct[index]
     return lazy_value.infer()