forked from VimPlug/jedi
fix a set comprehension issue
This commit is contained in:
@@ -242,7 +242,7 @@ class Evaluator(object):
|
||||
except (IndexError, AttributeError):
|
||||
pass
|
||||
else:
|
||||
if isinstance(comp_for, tree.CompFor):
|
||||
if isinstance(comp_for, tree.CompFor) and c[0] != '{':
|
||||
return [iterable.Comprehension.from_atom(self, atom)]
|
||||
return [iterable.Array(self, atom)]
|
||||
|
||||
|
||||
31
test/test_evaluate/test_iterable.py
Normal file
31
test/test_evaluate/test_iterable.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from textwrap import dedent
|
||||
|
||||
from jedi import names
|
||||
|
||||
|
||||
def get_scope_and_evaluator(source):
|
||||
d = names(dedent(source))[0]
|
||||
return d.parent()._definition, d._evaluator
|
||||
|
||||
def find_types(s):
|
||||
scope, evaluator = get_scope_and_evaluator(s)
|
||||
return evaluator.find_types(scope, s[0])
|
||||
|
||||
|
||||
|
||||
def test_comprehensions():
|
||||
"""
|
||||
test list/set/generator/dict comprehension syntax
|
||||
"""
|
||||
|
||||
s = "a = [i for i in range(10)]"
|
||||
assert len(find_types(s)) == 1
|
||||
|
||||
s = "a = [i for i in range(10)]"
|
||||
assert len(find_types(s)) == 1
|
||||
|
||||
s = "a = {i:i for i in range(10)}"
|
||||
assert len(find_types(s)) == 1
|
||||
|
||||
s = "a = {i for i in range(10)}"
|
||||
assert len(find_types(s)) == 1
|
||||
Reference in New Issue
Block a user