mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:09:22 +00:00
Formatter: Run generate.py for ElifElseClauses (#5864)
**Summary** This removes the diff for the next user of `generate.py`. It's effectively a refactoring. **Test Plan** No functional changes
This commit is contained in:
parent
0c7c81aa31
commit
5d41c832ad
4 changed files with 58 additions and 53 deletions
|
@ -49,21 +49,9 @@ impl FormatNodeRule<StmtIf> for FormatStmtIf {
|
|||
}
|
||||
}
|
||||
|
||||
/// Note that this implementation misses the leading newlines before the leading comments because
|
||||
/// it does not have access to the last node of the previous branch. The `StmtIf` therefore doesn't
|
||||
/// call this but `format_elif_else_clause` directly.
|
||||
#[derive(Default)]
|
||||
pub struct FormatElifElseClause;
|
||||
|
||||
impl FormatNodeRule<ElifElseClause> for FormatElifElseClause {
|
||||
fn fmt_fields(&self, item: &ElifElseClause, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
format_elif_else_clause(item, f, None)
|
||||
}
|
||||
}
|
||||
|
||||
/// Extracted so we can implement `FormatElifElseClause` but also pass in `last_node` from
|
||||
/// `FormatStmtIf`
|
||||
fn format_elif_else_clause(
|
||||
pub(crate) fn format_elif_else_clause(
|
||||
item: &ElifElseClause,
|
||||
f: &mut PyFormatter,
|
||||
last_node: Option<AnyNodeRef>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue