-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
58 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
crates/ruff_python_formatter/src/other/elif_else_clause.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use crate::statement::stmt_if::format_elif_else_clause; | ||
use crate::{FormatNodeRule, PyFormatter}; | ||
use ruff_formatter::FormatResult; | ||
use rustpython_parser::ast::ElifElseClause; | ||
|
||
/// 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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters