diff --git a/jedi/evaluate_representation.py b/jedi/evaluate_representation.py index aa19b894..dfb62057 100644 --- a/jedi/evaluate_representation.py +++ b/jedi/evaluate_representation.py @@ -812,9 +812,12 @@ class Array(use_metaclass(cache.CachedMetaClass, pr.Base)): # otherwise it just ignores the index (e.g. [1+1]). index = index_possibilities[0] if isinstance(index, Instance) \ - and str(index.name) in ['int', 'str'] \ + and str(index.name) in ['int', 'str'] \ and len(index.var_args) == 1: - with common.ignored(KeyError, IndexError): + # TODO this is just very hackish and a lot of use cases are + # being ignored + with common.ignored(KeyError, IndexError, + UnboundLocalError, TypeError): return self.get_exact_index_types(index.var_args[0]) result = list(self._follow_values(self._array.values)) diff --git a/test/completion/arrays.py b/test/completion/arrays.py index 4725435d..26d20950 100644 --- a/test/completion/arrays.py +++ b/test/completion/arrays.py @@ -11,6 +11,8 @@ [1,""][2] #? int() str() [1,""][20] +#? int() str() +[1,""][str(hello)] a = list() #? list() @@ -215,6 +217,11 @@ def y(a): #? y(**d) +# problem with more complicated casts +dic = {str(key): ''} +#? str() +dic[''] + # ----------------- # with variable as index # -----------------