From 907fdaa15366a4b271b6ea9ab7c5ef0c5ba5a36e Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 20 Jun 2019 09:53:40 +0200 Subject: [PATCH] Fix some minor errors --- jedi/evaluate/context/iterable.py | 7 ++++++- test/completion/complex.py | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/jedi/evaluate/context/iterable.py b/jedi/evaluate/context/iterable.py index 3738720e..91b6f54d 100644 --- a/jedi/evaluate/context/iterable.py +++ b/jedi/evaluate/context/iterable.py @@ -276,6 +276,8 @@ class DictComprehension(ComprehensionMixin, Sequence): for keys, values in self._iterate(): for k in keys: if isinstance(k, compiled.CompiledObject): + # Be careful in the future if refactoring, index could be a + # slice. if k.get_safe_value(default=object()) == index: return values raise SimpleGetItemNotFound() @@ -501,6 +503,9 @@ class FakeSequence(_FakeArray): self._lazy_context_list = lazy_context_list def py__simple_getitem__(self, index): + if isinstance(index, slice): + return ContextSet([self]) + with reraise_getitem_errors(IndexError, TypeError): lazy_context = self._lazy_context_list[index] return lazy_context.infer() @@ -540,7 +545,7 @@ class FakeDict(_DictMixin, _FakeArray): except KeyError: pass - with reraise_getitem_errors(KeyError): + with reraise_getitem_errors(KeyError, TypeError): lazy_context = self._dct[index] return lazy_context.infer() diff --git a/test/completion/complex.py b/test/completion/complex.py index 3ea83274..e8327f8e 100644 --- a/test/completion/complex.py +++ b/test/completion/complex.py @@ -12,3 +12,26 @@ def asdfy(): xorz = getattr(asdfy()(), 'asdf') #? time xorz + + + +def args_returner(*args): + return args + + +#? tuple() +args_returner(1)[:] +#? int() +args_returner(1)[:][0] + + +def kwargs_returner(**kwargs): + return kwargs + + +# TODO This is not really correct, needs correction probably at some point, but +# at least it doesn't raise an error. +#? int() +kwargs_returner(a=1)[:] +#? +kwargs_returner(b=1)[:][0]