mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
Bool expression comment placement (#7269)
This commit is contained in:
parent
c21b960fc7
commit
1e6df19a35
12 changed files with 776 additions and 145 deletions
|
@ -1,12 +1,11 @@
|
|||
use ruff_formatter::{format_args, write, FormatRuleWithOptions};
|
||||
use ruff_formatter::{write, FormatRuleWithOptions};
|
||||
use ruff_python_ast::node::{AnyNodeRef, AstNode};
|
||||
use ruff_python_ast::{Expr, ExprSubscript};
|
||||
|
||||
use crate::comments::{trailing_comments, SourceComment};
|
||||
|
||||
use crate::comments::SourceComment;
|
||||
use crate::context::{NodeLevel, WithNodeLevel};
|
||||
use crate::expression::expr_tuple::TupleParentheses;
|
||||
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
|
||||
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
|
||||
use crate::expression::CallChainLayout;
|
||||
use crate::prelude::*;
|
||||
|
||||
|
@ -67,15 +66,9 @@ impl FormatNodeRule<ExprSubscript> for FormatExprSubscript {
|
|||
}
|
||||
});
|
||||
|
||||
write!(
|
||||
f,
|
||||
[group(&format_args![
|
||||
token("["),
|
||||
trailing_comments(dangling_comments),
|
||||
soft_block_indent(&format_slice),
|
||||
token("]")
|
||||
])]
|
||||
)
|
||||
parenthesized("[", &format_slice, "]")
|
||||
.with_dangling_comments(dangling_comments)
|
||||
.fmt(f)
|
||||
}
|
||||
|
||||
fn fmt_dangling_comments(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue