mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-21 11:00:49 +00:00
Add a with_dangling_comments
to the parenthesized formatter (#6402)
See: https://github.com/astral-sh/ruff/pull/6376#discussion_r1285514328.
This commit is contained in:
parent
bb96647d66
commit
8919b6ad9a
11 changed files with 60 additions and 82 deletions
|
@ -1,9 +1,7 @@
|
|||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use ruff_python_ast::{ExprSet, Ranged};
|
||||
|
||||
use crate::expression::parentheses::{
|
||||
parenthesized_with_dangling_comments, NeedsParentheses, OptionalParentheses,
|
||||
};
|
||||
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
|
||||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
|
||||
|
@ -25,7 +23,9 @@ impl FormatNodeRule<ExprSet> for FormatExprSet {
|
|||
let comments = f.context().comments().clone();
|
||||
let dangling = comments.dangling_comments(item);
|
||||
|
||||
parenthesized_with_dangling_comments("{", dangling, &joined, "}").fmt(f)
|
||||
parenthesized("{", &joined, "}")
|
||||
.with_dangling_comments(dangling)
|
||||
.fmt(f)
|
||||
}
|
||||
|
||||
fn fmt_dangling_comments(&self, _node: &ExprSet, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue