1
0
forked from VimPlug/jedi

Return None instead of raising an IndexError in get_next_leaf.

This commit is contained in:
Dave Halter
2017-02-03 17:26:02 +01:00
parent c5071f9f49
commit 647aec11a6

View File

@@ -255,7 +255,7 @@ class Base(object):
if i == len(c) - 1:
node = node.parent
if node.parent is None:
raise IndexError('Cannot access the next element of the last one.')
return None
else:
node = c[i + 1]
break
@@ -566,18 +566,6 @@ class BaseNode(Base):
except AttributeError:
return self.children[0]
def get_next_leaf(self):
"""
Raises an IndexError if it's the last node. (Would be the module)
"""
c = self.parent.children
index = c.index(self)
if index == len(c) - 1:
# TODO WTF? recursion?
return self.get_next_leaf()
else:
return c[index + 1]
def last_leaf(self):
return self.children[-1].last_leaf()