(self, node)
return result
Eliminate dead code.
Eliminate dead code.
Eliminate dead code .
def visit_If(self, node):
        """Eliminate dead code."""
        # do not optimize ifs that have a block inside so that it doesn't
        # break super().
        if node.find(nodes.Block) is not None:
            return self.generic_visit(node)
        try:
            val = self.visit(node.test).as_const()
        except nodes.Impossible:
            return self.generic_visit(node)
        if val:
            body = node.body
        else:
            body = node.else_
        result = []
        for node in body:
            result.extend(self.visit_list(node))
        return result
def visit_If ( self , node ) : # do not optimize ifs that have a block inside so that it doesn't # break super(). if node . find ( nodes . Block ) is not None : return self . generic_visit ( node ) try : val = self . visit ( node . test ) . as_const ( ) except nodes . Impossible : return self . generic_visit ( node ) if val : body = node . body else : body = node . else_ result = [ ] for node in body : result . extend ( self . visit_list ( node ) ) return result