mirror of
https://github.com/davidhalter/jedi.git
synced 2026-09-17 05:23:12 +08:00
Fix a lot more of the tuple assignments.
This commit is contained in:
@@ -238,12 +238,17 @@ class Name(_Leaf):
|
|||||||
"""
|
"""
|
||||||
indexes = []
|
indexes = []
|
||||||
node = self.parent
|
node = self.parent
|
||||||
|
compare = self
|
||||||
while node is not None:
|
while node is not None:
|
||||||
if is_node(node, 'testlist_comp') or is_node(node, 'testlist_star_expr'):
|
if is_node(node, 'testlist_comp') or is_node(node, 'testlist_star_expr'):
|
||||||
for i, child in enumerate(node.children):
|
for i, child in enumerate(node.children):
|
||||||
if child == self:
|
if child == compare:
|
||||||
indexes.insert(0, i)
|
indexes.insert(0, int(i / 2))
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise LookupError("Couldn't find the assignment.")
|
||||||
|
|
||||||
|
compare = node
|
||||||
node = node.parent
|
node = node.parent
|
||||||
return indexes
|
return indexes
|
||||||
|
|
||||||
@@ -1058,15 +1063,20 @@ class Statement(Simple, DocstringMixin):
|
|||||||
self.expression_list()
|
self.expression_list()
|
||||||
|
|
||||||
def get_defined_names(self):
|
def get_defined_names(self):
|
||||||
names = []
|
def check_tuple(current):
|
||||||
for i in range(0, len(self.children) - 2, 2):
|
names = []
|
||||||
if self.children[i + 1].value == '=':
|
if is_node(current, 'testlist_star_expr') or is_node(current, 'testlist_comp'):
|
||||||
current = self.children[i]
|
for child in current.children[::2]:
|
||||||
if is_node(current, 'testlist_star_expr'):
|
names += check_tuple(child)
|
||||||
names += current.children[::2]
|
elif is_node(current, 'atom'):
|
||||||
else:
|
names += check_tuple(current.children[1])
|
||||||
names.append(current)
|
else:
|
||||||
return names
|
names.append(current)
|
||||||
|
return names
|
||||||
|
|
||||||
|
return list(chain.from_iterable(check_tuple(self.children[i])
|
||||||
|
for i in range(0, len(self.children) - 2, 2)
|
||||||
|
if self.children[i + 1].value == '='))
|
||||||
|
|
||||||
|
|
||||||
"""Get the names for the statement."""
|
"""Get the names for the statement."""
|
||||||
|
|||||||
Reference in New Issue
Block a user