mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-17 09:00:48 +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
|
@ -656,7 +656,7 @@ pub struct ExprBoolOp<'a> {
|
|||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub struct ExprNamedExpr<'a> {
|
||||
pub struct ExprNamed<'a> {
|
||||
target: Box<ComparableExpr<'a>>,
|
||||
value: Box<ComparableExpr<'a>>,
|
||||
}
|
||||
|
@ -681,7 +681,7 @@ pub struct ExprLambda<'a> {
|
|||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub struct ExprIfExp<'a> {
|
||||
pub struct ExprIf<'a> {
|
||||
test: Box<ComparableExpr<'a>>,
|
||||
body: Box<ComparableExpr<'a>>,
|
||||
orelse: Box<ComparableExpr<'a>>,
|
||||
|
@ -718,7 +718,7 @@ pub struct ExprDictComp<'a> {
|
|||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub struct ExprGeneratorExp<'a> {
|
||||
pub struct ExprGenerator<'a> {
|
||||
elt: Box<ComparableExpr<'a>>,
|
||||
generators: Vec<ComparableComprehension<'a>>,
|
||||
}
|
||||
|
@ -832,17 +832,17 @@ pub struct ExprIpyEscapeCommand<'a> {
|
|||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub enum ComparableExpr<'a> {
|
||||
BoolOp(ExprBoolOp<'a>),
|
||||
NamedExpr(ExprNamedExpr<'a>),
|
||||
NamedExpr(ExprNamed<'a>),
|
||||
BinOp(ExprBinOp<'a>),
|
||||
UnaryOp(ExprUnaryOp<'a>),
|
||||
Lambda(ExprLambda<'a>),
|
||||
IfExp(ExprIfExp<'a>),
|
||||
IfExp(ExprIf<'a>),
|
||||
Dict(ExprDict<'a>),
|
||||
Set(ExprSet<'a>),
|
||||
ListComp(ExprListComp<'a>),
|
||||
SetComp(ExprSetComp<'a>),
|
||||
DictComp(ExprDictComp<'a>),
|
||||
GeneratorExp(ExprGeneratorExp<'a>),
|
||||
GeneratorExp(ExprGenerator<'a>),
|
||||
Await(ExprAwait<'a>),
|
||||
Yield(ExprYield<'a>),
|
||||
YieldFrom(ExprYieldFrom<'a>),
|
||||
|
@ -889,11 +889,11 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> {
|
|||
op: (*op).into(),
|
||||
values: values.iter().map(Into::into).collect(),
|
||||
}),
|
||||
ast::Expr::NamedExpr(ast::ExprNamedExpr {
|
||||
ast::Expr::Named(ast::ExprNamed {
|
||||
target,
|
||||
value,
|
||||
range: _,
|
||||
}) => Self::NamedExpr(ExprNamedExpr {
|
||||
}) => Self::NamedExpr(ExprNamed {
|
||||
target: target.into(),
|
||||
value: value.into(),
|
||||
}),
|
||||
|
@ -923,12 +923,12 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> {
|
|||
parameters: parameters.as_ref().map(Into::into),
|
||||
body: body.into(),
|
||||
}),
|
||||
ast::Expr::IfExp(ast::ExprIfExp {
|
||||
ast::Expr::If(ast::ExprIf {
|
||||
test,
|
||||
body,
|
||||
orelse,
|
||||
range: _,
|
||||
}) => Self::IfExp(ExprIfExp {
|
||||
}) => Self::IfExp(ExprIf {
|
||||
test: test.into(),
|
||||
body: body.into(),
|
||||
orelse: orelse.into(),
|
||||
|
@ -973,12 +973,12 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> {
|
|||
value: value.into(),
|
||||
generators: generators.iter().map(Into::into).collect(),
|
||||
}),
|
||||
ast::Expr::GeneratorExp(ast::ExprGeneratorExp {
|
||||
ast::Expr::Generator(ast::ExprGenerator {
|
||||
elt,
|
||||
generators,
|
||||
range: _,
|
||||
parenthesized: _,
|
||||
}) => Self::GeneratorExp(ExprGeneratorExp {
|
||||
}) => Self::GeneratorExp(ExprGenerator {
|
||||
elt: elt.into(),
|
||||
generators: generators.iter().map(Into::into).collect(),
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue