mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Remove Stmt::TryStar
(#6566)
## Summary Instead, we set an `is_star` flag on `Stmt::Try`. This is similar to the pattern we've migrated towards for `Stmt::For` (removing `Stmt::AsyncFor`) and friends. While these are significant differences for an interpreter, we tend to handle these cases identically or nearly identically. ## Test Plan `cargo test`
This commit is contained in:
parent
09c8b17661
commit
96d310fbab
33 changed files with 70 additions and 489 deletions
|
@ -513,6 +513,7 @@ impl<'a> Generator<'a> {
|
|||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
is_star,
|
||||
range: _,
|
||||
}) => {
|
||||
statement!({
|
||||
|
@ -522,38 +523,7 @@ impl<'a> Generator<'a> {
|
|||
|
||||
for handler in handlers {
|
||||
statement!({
|
||||
self.unparse_except_handler(handler, false);
|
||||
});
|
||||
}
|
||||
|
||||
if !orelse.is_empty() {
|
||||
statement!({
|
||||
self.p("else:");
|
||||
});
|
||||
self.body(orelse);
|
||||
}
|
||||
if !finalbody.is_empty() {
|
||||
statement!({
|
||||
self.p("finally:");
|
||||
});
|
||||
self.body(finalbody);
|
||||
}
|
||||
}
|
||||
Stmt::TryStar(ast::StmtTryStar {
|
||||
body,
|
||||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
range: _,
|
||||
}) => {
|
||||
statement!({
|
||||
self.p("try:");
|
||||
});
|
||||
self.body(body);
|
||||
|
||||
for handler in handlers {
|
||||
statement!({
|
||||
self.unparse_except_handler(handler, true);
|
||||
self.unparse_except_handler(handler, *is_star);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue