From ffaf81bf1ba3722ce3ec35946c2d2bd82a73c0e1 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 20 Nov 2015 14:51:52 +0100 Subject: [PATCH] Fix: Set/Dict Comprehensions don't raise an error. They are just ignored for now. --- jedi/evaluate/__init__.py | 3 +++ test/completion/comprehensions.py | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/jedi/evaluate/__init__.py b/jedi/evaluate/__init__.py index 26f3e6a6..041563f0 100644 --- a/jedi/evaluate/__init__.py +++ b/jedi/evaluate/__init__.py @@ -339,6 +339,9 @@ class Evaluator(object): pass else: if isinstance(comp_for, tree.CompFor): + if atom.children[0] == '{': + # TODO dict/set comprehensions should be working. + return [] return set([iterable.Comprehension.from_atom(self, atom)]) return set([iterable.Array(self, atom)]) diff --git a/test/completion/comprehensions.py b/test/completion/comprehensions.py index c36ed6da..bec04689 100644 --- a/test/completion/comprehensions.py +++ b/test/completion/comprehensions.py @@ -47,9 +47,6 @@ left #? str() [a for a in {1:'x'}][0] -##? str() -{a-1:b for a,b in {1:'a', 3:1.0}.items()}[0] - # list comprehensions should also work in combination with functions def listen(arg): for x in arg: @@ -118,6 +115,16 @@ left #? int() right +# ----------------- +# set comprehensions +# ----------------- + +##? str() +{a - 1: b for a, b in {1: 'a', 3: 1.0}.items()}[0] + +#? +{a - 1 for a in [1]} + # ----------------- # name resolution in comprehensions. # ----------------- @@ -127,3 +134,5 @@ def x(): #? 22 [a for a in h if hio] if hio: pass + +