Skip to content

Commit 15b7525

Browse files
authored
Rename parser goal 'All' to 'all' (#6867)
1 parent 0b6dab5 commit 15b7525

File tree

2 files changed

+14493
-19611
lines changed

2 files changed

+14493
-19611
lines changed

crates/ruff_python_parser/src/python.lalrpop

+8-4
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ IpyHelpEndEscapeCommandStatement: ast::Stmt = {
372372
// We are permissive than the original implementation because we would allow whitespace
373373
// between the expression and the suffix while the IPython implementation doesn't allow it.
374374
// For example, `foo ?` would be valid in our case but invalid from IPython.
375-
<location:@L> <e:Expression<"All">> <suffix:("?")+> <end_location:@R> =>? {
375+
<location:@L> <e:Expression<"all">> <suffix:("?")+> <end_location:@R> =>? {
376376
fn unparse_expr(expr: &ast::Expr, buffer: &mut String) -> Result<(), LexicalError> {
377377
match expr {
378378
ast::Expr::Name(ast::ExprName { id, .. }) => {
@@ -1054,7 +1054,7 @@ WithStatement: ast::Stmt = {
10541054

10551055
WithItems: Vec<ast::WithItem> = {
10561056
"(" <WithItemsNoAs> ","? ")",
1057-
"(" <left:(<WithItemsNoAs> ",")?> <mid:WithItem<"as">> <right:("," <WithItem<"all">>)*> ","? ")" => {
1057+
"(" <left:(<WithItemsNoAs> ",")?> <mid:WithItemAs> <right:("," <WithItem<"all">>)*> ","? ")" => {
10581058
left.into_iter().flatten().chain([mid]).chain(right).collect()
10591059
},
10601060
<WithItem<"no-withitems">> => vec![<>],
@@ -1071,12 +1071,16 @@ WithItemsNoAs: Vec<ast::WithItem> = {
10711071
}
10721072

10731073
WithItem<Goal>: ast::WithItem = {
1074-
<location:@L> <context_expr: Test<Goal>> <end_location:@R> if Goal != "as" => ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() },
1074+
<location:@L> <context_expr: Test<Goal>> <end_location:@R> => ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() },
1075+
<WithItemAs>,
1076+
};
1077+
1078+
WithItemAs: ast::WithItem = {
10751079
<location:@L> <context_expr:Test<"all">> "as" <vars:Expression<"all">> <end_location:@R> => {
10761080
let optional_vars = Some(Box::new(set_context(vars, ast::ExprContext::Store)));
10771081
ast::WithItem { context_expr, optional_vars, range: (location..end_location).into() }
10781082
},
1079-
};
1083+
}
10801084

10811085
FuncDef: ast::Stmt = {
10821086
<location:@L> <decorator_list:Decorator*> <is_async:"async"?> "def" <name:Identifier> <type_params:TypeParams?> <args:Parameters> <r:("->" <Test<"all">>)?> ":" <body:Suite> => {

0 commit comments

Comments
 (0)