Remove Expr postfix from ExprNamed, ExprIf, and ExprGenerator (#10229)

The expression types in our AST are called `ExprYield`, `ExprAwait`,
`ExprStringLiteral` etc, except `ExprNamedExpr`, `ExprIfExpr` and
`ExprGenratorExpr`. This seems to align with [Python AST's
naming](https://docs.python.org/3/library/ast.html) but feels
inconsistent and excessive.

This PR removes the `Expr` postfix from `ExprNamedExpr`, `ExprIfExpr`,
and `ExprGeneratorExpr`.
This commit is contained in:
Micha Reiser 2024-03-04 12:55:01 +01:00 committed by GitHub
parent 8b749e1d4d
commit 184241f99a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
64 changed files with 418 additions and 428 deletions

View file

@ -273,17 +273,17 @@ where
if visitor.enter_node(node).is_traverse() {
match expr {
Expr::BoolOp(expr) => expr.visit_preorder(visitor),
Expr::NamedExpr(expr) => expr.visit_preorder(visitor),
Expr::Named(expr) => expr.visit_preorder(visitor),
Expr::BinOp(expr) => expr.visit_preorder(visitor),
Expr::UnaryOp(expr) => expr.visit_preorder(visitor),
Expr::Lambda(expr) => expr.visit_preorder(visitor),
Expr::IfExp(expr) => expr.visit_preorder(visitor),
Expr::If(expr) => expr.visit_preorder(visitor),
Expr::Dict(expr) => expr.visit_preorder(visitor),
Expr::Set(expr) => expr.visit_preorder(visitor),
Expr::ListComp(expr) => expr.visit_preorder(visitor),
Expr::SetComp(expr) => expr.visit_preorder(visitor),
Expr::DictComp(expr) => expr.visit_preorder(visitor),
Expr::GeneratorExp(expr) => expr.visit_preorder(visitor),
Expr::Generator(expr) => expr.visit_preorder(visitor),
Expr::Await(expr) => expr.visit_preorder(visitor),
Expr::Yield(expr) => expr.visit_preorder(visitor),
Expr::YieldFrom(expr) => expr.visit_preorder(visitor),

View file

@ -329,7 +329,7 @@ pub fn walk_expr<V: Transformer + ?Sized>(visitor: &V, expr: &mut Expr) {
visitor.visit_expr(expr);
}
}
Expr::NamedExpr(ast::ExprNamedExpr {
Expr::Named(ast::ExprNamed {
target,
value,
range: _,
@ -365,7 +365,7 @@ pub fn walk_expr<V: Transformer + ?Sized>(visitor: &V, expr: &mut Expr) {
}
visitor.visit_expr(body);
}
Expr::IfExp(ast::ExprIfExp {
Expr::If(ast::ExprIf {
test,
body,
orelse,
@ -424,7 +424,7 @@ pub fn walk_expr<V: Transformer + ?Sized>(visitor: &V, expr: &mut Expr) {
visitor.visit_expr(key);
visitor.visit_expr(value);
}
Expr::GeneratorExp(ast::ExprGeneratorExp {
Expr::Generator(ast::ExprGenerator {
elt,
generators,
range: _,