mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-20 07:19:40 +08:00
fix UnboundLocalError and TypeError within Array lookups, not a very good solution, but for now it doesn't puke errors
This commit is contained in:
@@ -812,9 +812,12 @@ class Array(use_metaclass(cache.CachedMetaClass, pr.Base)):
|
|||||||
# otherwise it just ignores the index (e.g. [1+1]).
|
# otherwise it just ignores the index (e.g. [1+1]).
|
||||||
index = index_possibilities[0]
|
index = index_possibilities[0]
|
||||||
if isinstance(index, Instance) \
|
if isinstance(index, Instance) \
|
||||||
and str(index.name) in ['int', 'str'] \
|
and str(index.name) in ['int', 'str'] \
|
||||||
and len(index.var_args) == 1:
|
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])
|
return self.get_exact_index_types(index.var_args[0])
|
||||||
|
|
||||||
result = list(self._follow_values(self._array.values))
|
result = list(self._follow_values(self._array.values))
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
[1,""][2]
|
[1,""][2]
|
||||||
#? int() str()
|
#? int() str()
|
||||||
[1,""][20]
|
[1,""][20]
|
||||||
|
#? int() str()
|
||||||
|
[1,""][str(hello)]
|
||||||
|
|
||||||
a = list()
|
a = list()
|
||||||
#? list()
|
#? list()
|
||||||
@@ -215,6 +217,11 @@ def y(a):
|
|||||||
#?
|
#?
|
||||||
y(**d)
|
y(**d)
|
||||||
|
|
||||||
|
# problem with more complicated casts
|
||||||
|
dic = {str(key): ''}
|
||||||
|
#? str()
|
||||||
|
dic['']
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# with variable as index
|
# with variable as index
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user