mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +00:00
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:
parent
8b749e1d4d
commit
184241f99a
64 changed files with 418 additions and 428 deletions
|
@ -227,14 +227,14 @@ fn handle_enclosed_comment<'a>(
|
|||
handle_pattern_keyword_comment(comment, pattern_keyword, locator)
|
||||
}
|
||||
AnyNodeRef::ExprUnaryOp(unary_op) => handle_unary_op_comment(comment, unary_op, locator),
|
||||
AnyNodeRef::ExprNamedExpr(_) => handle_named_expr_comment(comment, locator),
|
||||
AnyNodeRef::ExprNamed(_) => handle_named_expr_comment(comment, locator),
|
||||
AnyNodeRef::ExprLambda(lambda) => handle_lambda_comment(comment, lambda, locator),
|
||||
AnyNodeRef::ExprDict(_) => handle_dict_unpacking_comment(comment, locator)
|
||||
.or_else(|comment| handle_bracketed_end_of_line_comment(comment, locator))
|
||||
.or_else(|comment| handle_key_value_comment(comment, locator)),
|
||||
AnyNodeRef::ExprDictComp(_) => handle_key_value_comment(comment, locator)
|
||||
.or_else(|comment| handle_bracketed_end_of_line_comment(comment, locator)),
|
||||
AnyNodeRef::ExprIfExp(expr_if) => handle_expr_if_comment(comment, expr_if, locator),
|
||||
AnyNodeRef::ExprIf(expr_if) => handle_expr_if_comment(comment, expr_if, locator),
|
||||
AnyNodeRef::ExprSlice(expr_slice) => {
|
||||
handle_slice_comments(comment, expr_slice, comment_ranges, locator)
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ fn handle_enclosed_comment<'a>(
|
|||
parenthesized: true,
|
||||
..
|
||||
}) => handle_bracketed_end_of_line_comment(comment, locator),
|
||||
AnyNodeRef::ExprGeneratorExp(generator) if generator.parenthesized => {
|
||||
AnyNodeRef::ExprGenerator(generator) if generator.parenthesized => {
|
||||
handle_bracketed_end_of_line_comment(comment, locator)
|
||||
}
|
||||
_ => CommentPlacement::Default(comment),
|
||||
|
@ -1353,10 +1353,10 @@ fn handle_attribute_comment<'a>(
|
|||
/// happens if the comments are in a weird position but it also doesn't hurt handling it.
|
||||
fn handle_expr_if_comment<'a>(
|
||||
comment: DecoratedComment<'a>,
|
||||
expr_if: &'a ast::ExprIfExp,
|
||||
expr_if: &'a ast::ExprIf,
|
||||
locator: &Locator,
|
||||
) -> CommentPlacement<'a> {
|
||||
let ast::ExprIfExp {
|
||||
let ast::ExprIf {
|
||||
range: _,
|
||||
test,
|
||||
body,
|
||||
|
@ -1612,7 +1612,7 @@ fn handle_named_expr_comment<'a>(
|
|||
comment: DecoratedComment<'a>,
|
||||
locator: &Locator,
|
||||
) -> CommentPlacement<'a> {
|
||||
debug_assert!(comment.enclosing_node().is_expr_named_expr());
|
||||
debug_assert!(comment.enclosing_node().is_expr_named());
|
||||
|
||||
let (Some(target), Some(value)) = (comment.preceding_node(), comment.following_node()) else {
|
||||
return CommentPlacement::Default(comment);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue