mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 20:42:10 +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};
|
||||
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),
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue