def visit_Delete(self, n: ast35.Delete) -> Node: if len(n.targets) > 1: tup = TupleExpr(self.visit_list(n.targets)) tup.set_line(n.lineno) return DelStmt(tup) else: return DelStmt(self.visit(n.targets[0]))
def visit_Delete(self, n: ast27.Delete) -> DelStmt: if len(n.targets) > 1: tup = TupleExpr(self.translate_expr_list(n.targets)) tup.set_line(n.lineno) return DelStmt(tup) else: return DelStmt(self.visit(n.targets[0]))
def visit_Raise(self, n: ast27.Raise) -> RaiseStmt: if n.type is None: e = None else: if n.inst is None: e = self.visit(n.type) else: if n.tback is None: e = TupleExpr([self.visit(n.type), self.visit(n.inst)]) else: e = TupleExpr([self.visit(n.type), self.visit(n.inst), self.visit(n.tback)]) return RaiseStmt(e, None)
def visit_List(self, n: ast27.List) -> Union[ListExpr, TupleExpr]: expr_list: List[Expression] = [self.visit(e) for e in n.elts] if isinstance(n.ctx, ast27.Store): # [x, y] = z and (x, y) = z means exactly the same thing e: Union[ListExpr, TupleExpr] = TupleExpr(expr_list) else: e = ListExpr(expr_list) return self.set_line(e, n)
def visit_Raise(self, n: ast27.Raise) -> RaiseStmt: legacy_mode = False if n.type is None: e = None else: if n.inst is None: e = self.visit(n.type) else: legacy_mode = True if n.tback is None: e = TupleExpr([self.visit(n.type), self.visit(n.inst)]) else: e = TupleExpr([ self.visit(n.type), self.visit(n.inst), self.visit(n.tback) ]) stmt = RaiseStmt(e, None) stmt.legacy_mode = legacy_mode return self.set_line(stmt, n)
def visit_ExtSlice(self, n: ast35.ExtSlice) -> Node: return TupleExpr(self.visit_list(n.dims))
def visit_Tuple(self, n: ast35.Tuple) -> Node: return TupleExpr([self.visit(e) for e in n.elts])
def visit_ExtSlice(self, n: ast27.ExtSlice) -> TupleExpr: return TupleExpr(self.translate_expr_list(n.dims))
def visit_Tuple(self, n: ast27_Tuple) -> TupleExpr: e = TupleExpr([self.visit(e) for e in n.elts]) return self.set_line(e, n)
def visit_Tuple(self, n: ast27.Tuple) -> TupleExpr: return TupleExpr([self.visit(e) for e in n.elts])
def visit_List(self, n: ast27.List) -> Union[ListExpr, TupleExpr]: expr_list = [self.visit(e) for e in n.elts] # type: List[Expression] if isinstance(n.ctx, ast27.Store): # [x, y] = z and (x, y) = z means exactly the same thing return TupleExpr(expr_list) return ListExpr(expr_list)
def visit_tuple_expr(self, node: TupleExpr) -> Node: return TupleExpr(self.nodes(node.items))
def visit_tuple_expr(self, node: TupleExpr) -> TupleExpr: return TupleExpr(self.expressions(node.items))
def visit_ExtSlice(self, n): return TupleExpr(self.visit(n.dims))
def visit_Tuple(self, n): return TupleExpr([self.visit(e) for e in n.elts])