Format function and class definitions into a single line if its body is an ellipsis (#6592)

This commit is contained in:
Tom Kuson 2023-08-21 08:02:23 +01:00 committed by GitHub
parent bb5fbb1b5c
commit 2a8d24dd4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 445 additions and 60 deletions

View file

@ -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};
use crate::statement::clause::{clause_body, clause_header, ClauseHeader};
use crate::FormatNodeRule;
#[derive(Default)]
@ -36,7 +36,7 @@ impl FormatNodeRule<StmtIf> for FormatStmtIf {
maybe_parenthesize_expression(test, item, Parenthesize::IfBreaks),
],
),
block_indent(&body.format())
clause_body(body, trailing_colon_comment),
]
)?;
@ -98,7 +98,7 @@ pub(crate) fn format_elif_else_clause(
}),
)
.with_leading_comments(leading_comments, last_node),
block_indent(&body.format())
clause_body(body, trailing_colon_comment),
]
)
}