Comments
Patch
@@ -340,7 +340,7 @@ def getargsdict(x, funcname, keys):
def isvalidsymbol(tree):
"""Examine whether specified ``tree`` is valid ``symbol`` or not
"""
- return tree[0] == 'symbol' and len(tree) > 1
+ return tree[0] == 'symbol'
def getsymbol(tree):
"""Get symbol name from valid ``symbol`` in ``tree``
@@ -352,7 +352,7 @@ def getsymbol(tree):
def isvalidfunc(tree):
"""Examine whether specified ``tree`` is valid ``func`` or not
"""
- return tree[0] == 'func' and len(tree) > 1 and isvalidsymbol(tree[1])
+ return tree[0] == 'func' and isvalidsymbol(tree[1])
def getfuncname(tree):
"""Get function name from valid ``func`` in ``tree``
@@ -366,10 +366,7 @@ def getfuncargs(tree):
This assumes that ``tree`` is already examined by ``isvalidfunc``.
"""
- if len(tree) > 2:
- return getlist(tree[2])
- else:
- return []
+ return getlist(tree[2])
def getset(repo, subset, x):
if not x:
@@ -2438,14 +2435,14 @@ def _getalias(aliases, tree):
"""If tree looks like an unexpanded alias, return it. Return None
otherwise.
"""
- if isinstance(tree, tuple) and tree:
- if tree[0] == 'symbol' and len(tree) == 2:
+ if isinstance(tree, tuple):
+ if tree[0] == 'symbol':
name = tree[1]
alias = aliases.get(name)
if alias and alias.args is None and alias.tree == tree:
return alias
- if tree[0] == 'func' and len(tree) > 1:
- if tree[1][0] == 'symbol' and len(tree[1]) == 2:
+ if tree[0] == 'func':
+ if tree[1][0] == 'symbol':
name = tree[1][1]
alias = aliases.get(name)
if alias and alias.args is not None and alias.tree == tree[:2]:
@@ -2456,7 +2453,7 @@ def _expandargs(tree, args):
"""Replace _aliasarg instances with the substitution value of the
same name in args, recursively.
"""
- if not tree or not isinstance(tree, tuple):
+ if not isinstance(tree, tuple):
return tree
if tree[0] == '_aliasarg':
sym = tree[1]