Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def on_boolop(self, node): # ('op', 'values')
"""Boolean operator."""
val = self.run(node.values[0])
is_and = ast.And == node.op.__class__
if (is_and and val) or (not is_and and not val):
for n in node.values[1:]:
val = op2func(node.op)(val, self.run(n))
if (is_and and not val) or (not is_and and val):
break
return val
def on_binop(self, node): # ('left', 'op', 'right')
"""Binary operator."""
return op2func(node.op)(self.run(node.left),
self.run(node.right))
def on_unaryop(self, node): # ('op', 'operand')
"""Unary operator."""
return op2func(node.op)(self.run(node.operand))
def on_compare(self, node): # ('left', 'ops', 'comparators')
"""comparison operators, including chained comparisons (a