diff --git a/jedi/evaluate/context/iterable.py b/jedi/evaluate/context/iterable.py index c69498e7..9958de28 100644 --- a/jedi/evaluate/context/iterable.py +++ b/jedi/evaluate/context/iterable.py @@ -267,6 +267,11 @@ class DictComprehension(ComprehensionMixin, Sequence): return ContextSet(FakeSequence(self.evaluator, u'list', lazy_contexts)) + def exact_key_items(self): + # NOTE: A smarter thing can probably done here to achieve better + # completions, but at least like this jedi doesn't crash + return [] + class GeneratorComprehension(ComprehensionMixin, GeneratorBase): pass diff --git a/test/completion/functions.py b/test/completion/functions.py index bc4eb200..585b692b 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -319,6 +319,7 @@ exe['c'] a = 'a' exe2 = kwargs_func(**{a:3, 'b':4.0}) + #? int() exe2['a'] #? float() @@ -326,6 +327,19 @@ exe2['b'] #? int() float() exe2['c'] +exe3 = kwargs_func(**{k: v for k, v in [(a, 3), ('b', 4.0)]}) + +# Should resolve to the same as 2 but jedi is not smart enough yet +# Here to make sure it doesn't result in crash though +#? +exe3['a'] + +#? +exe3['b'] + +#? +exe3['c'] + # ----------------- # *args / ** kwargs # ----------------- diff --git a/test/completion/types.py b/test/completion/types.py index f0c4c838..753af6c3 100644 --- a/test/completion/types.py +++ b/test/completion/types.py @@ -138,18 +138,30 @@ set_t2.c # python >= 3.5 d = {'a': 3} +dc = {v: 3 for v in ['a']} #? dict() {**d} +#? dict() +{**dc} + #? str() {**d, "b": "b"}["b"] +#? str() +{**dc, "b": "b"}["b"] + # Should resolve to int() but jedi is not smart enough yet # Here to make sure it doesn't result in crash though #? {**d}["a"] +# Should resolve to int() but jedi is not smart enough yet +# Here to make sure it doesn't result in crash though +#? +{**dc}["a"] + s = {1, 2, 3} #? set()