mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
Format function and class definitions into a single line if its body is an ellipsis (#6592)
This commit is contained in:
parent
bb5fbb1b5c
commit
2a8d24dd4b
15 changed files with 445 additions and 60 deletions
|
@ -6,7 +6,7 @@ use crate::comments::SourceComment;
|
|||
use crate::expression::maybe_parenthesize_expression;
|
||||
use crate::expression::parentheses::Parenthesize;
|
||||
use crate::prelude::*;
|
||||
use crate::statement::clause::{clause_header, ClauseHeader, ElseClause};
|
||||
use crate::statement::clause::{clause_body, clause_header, ClauseHeader, ElseClause};
|
||||
use crate::FormatNodeRule;
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -43,7 +43,7 @@ impl FormatNodeRule<StmtWhile> for FormatStmtWhile {
|
|||
maybe_parenthesize_expression(test, item, Parenthesize::IfBreaks),
|
||||
]
|
||||
),
|
||||
block_indent(&body.format())
|
||||
clause_body(body, trailing_condition_comments),
|
||||
]
|
||||
)?;
|
||||
|
||||
|
@ -63,7 +63,7 @@ impl FormatNodeRule<StmtWhile> for FormatStmtWhile {
|
|||
&text("else")
|
||||
)
|
||||
.with_leading_comments(leading, body.last()),
|
||||
block_indent(&orelse.format())
|
||||
clause_body(orelse, trailing),
|
||||
]
|
||||
)?;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue