mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 20:42:10 +00:00
Support fmt: skip
for simple-statements and decorators (#6561)
This commit is contained in:
parent
e3ecbe660e
commit
4dc32a00d0
40 changed files with 545 additions and 316 deletions
|
@ -215,6 +215,18 @@ pub(crate) enum SuppressionKind {
|
|||
Skip,
|
||||
}
|
||||
|
||||
impl SuppressionKind {
|
||||
pub(crate) fn has_skip_comment(trailing_comments: &[SourceComment], source: &str) -> bool {
|
||||
trailing_comments.iter().any(|comment| {
|
||||
comment.line_position().is_end_of_line()
|
||||
&& matches!(
|
||||
comment.suppression_kind(source),
|
||||
Some(SuppressionKind::Skip | SuppressionKind::Off)
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Ranged for SourceComment {
|
||||
#[inline]
|
||||
fn range(&self) -> TextRange {
|
||||
|
|
|
@ -905,7 +905,7 @@ fn handle_leading_class_with_decorators_comment<'a>(
|
|||
comment: DecoratedComment<'a>,
|
||||
class_def: &'a ast::StmtClassDef,
|
||||
) -> CommentPlacement<'a> {
|
||||
if comment.start() < class_def.name.start() {
|
||||
if comment.line_position().is_own_line() && comment.start() < class_def.name.start() {
|
||||
if let Some(decorator) = class_def.decorator_list.last() {
|
||||
if decorator.end() < comment.start() {
|
||||
return CommentPlacement::dangling(class_def, comment);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue