mirror of
https://github.com/davidhalter/jedi.git
synced 2026-08-13 17:31:01 +08:00
Nested list comprehensions seem to be working pretty well.
This commit is contained in:
@@ -135,8 +135,17 @@ class Comprehension(IterableWrapper):
|
|||||||
[x + 1 for x in foo]
|
[x + 1 for x in foo]
|
||||||
"""
|
"""
|
||||||
comprehension = self._atom.children[1]
|
comprehension = self._atom.children[1]
|
||||||
c = comprehension.children
|
# For nested comprehensions we need to search the last one.
|
||||||
return helpers.deep_ast_copy(c[0], {comprehension: c[1]})
|
last = comprehension.children[-1]
|
||||||
|
last_comp = comprehension.children[1]
|
||||||
|
while True:
|
||||||
|
if isinstance(last, pr.CompFor):
|
||||||
|
last_comp = last
|
||||||
|
elif not pr.is_node(last, 'comp_if'):
|
||||||
|
break
|
||||||
|
last = last.children[-1]
|
||||||
|
|
||||||
|
return helpers.deep_ast_copy(comprehension.children[0], {comprehension: last_comp})
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<e%s of %s>" % (type(self).__name__, self._atom)
|
return "<e%s of %s>" % (type(self).__name__, self._atom)
|
||||||
|
|||||||
Reference in New Issue
Block a user