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, PyFormatter};
#[derive(Copy, Clone, Default)]
@ -86,7 +86,7 @@ impl FormatNodeRule<ExceptHandlerExceptHandler> for FormatExceptHandlerExceptHan
Ok(())
}),
),
block_indent(&body.format())
clause_body(body, dangling_comments),
]
)
}

View file

@ -6,7 +6,7 @@ use ruff_text_size::TextRange;
use crate::comments::{leading_comments, SourceComment};
use crate::expression::parentheses::parenthesized;
use crate::prelude::*;
use crate::statement::clause::{clause_header, ClauseHeader};
use crate::statement::clause::{clause_body, clause_header, ClauseHeader};
use crate::{FormatError, FormatNodeRule, PyFormatter};
#[derive(Default)]
@ -57,7 +57,7 @@ impl FormatNodeRule<MatchCase> for FormatMatchCase {
Ok(())
}),
),
block_indent(&body.format())
clause_body(body, dangling_item_comments),
]
)
}