mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-10 02:12:09 +00:00
parent
a95deec00f
commit
424b720c19
62 changed files with 1799 additions and 3890 deletions
|
@ -7,7 +7,6 @@ use crate::comments::{leading_comments, trailing_comments};
|
|||
use crate::expression::expr_tuple::TupleParentheses;
|
||||
use crate::expression::parentheses::is_expression_parenthesized;
|
||||
use crate::prelude::*;
|
||||
use crate::preview::is_comprehension_leading_expression_comments_same_line_enabled;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatComprehension;
|
||||
|
@ -36,14 +35,12 @@ impl FormatNodeRule<Comprehension> for FormatComprehension {
|
|||
// )
|
||||
// ]
|
||||
// ```
|
||||
let will_be_parenthesized =
|
||||
is_comprehension_leading_expression_comments_same_line_enabled(f.context())
|
||||
&& self.preserve_parentheses
|
||||
&& is_expression_parenthesized(
|
||||
self.expression.into(),
|
||||
f.context().comments().ranges(),
|
||||
f.context().source(),
|
||||
);
|
||||
let will_be_parenthesized = self.preserve_parentheses
|
||||
&& is_expression_parenthesized(
|
||||
self.expression.into(),
|
||||
f.context().comments().ranges(),
|
||||
f.context().source(),
|
||||
);
|
||||
|
||||
if has_leading_comments && !will_be_parenthesized {
|
||||
soft_line_break_or_space().fmt(f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue