mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-17 00:50:33 +00:00
Format implicit string continuation (#5328)
This commit is contained in:
parent
313711aaf9
commit
49cabca3e7
9 changed files with 443 additions and 60 deletions
|
@ -1,13 +1,10 @@
|
|||
use crate::builders::PyFormatterExtensions;
|
||||
use crate::builders::optional_parentheses;
|
||||
use crate::comments::{dangling_node_comments, Comments};
|
||||
use crate::context::PyFormatContext;
|
||||
use crate::expression::parentheses::{
|
||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||
};
|
||||
use crate::{AsFormat, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::formatter::Formatter;
|
||||
use ruff_formatter::prelude::{block_indent, group, if_group_breaks, soft_block_indent, text};
|
||||
use ruff_formatter::{format_args, write, Buffer, Format, FormatResult, FormatRuleWithOptions};
|
||||
use crate::prelude::*;
|
||||
use ruff_formatter::{format_args, write, FormatRuleWithOptions};
|
||||
use ruff_python_ast::prelude::{Expr, Ranged};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_parser::ast::ExprTuple;
|
||||
|
@ -100,17 +97,7 @@ impl FormatNodeRule<ExprTuple> for FormatExprTuple {
|
|||
])]
|
||||
)
|
||||
}
|
||||
elts => {
|
||||
write!(
|
||||
f,
|
||||
[group(&format_args![
|
||||
// If there were previously no parentheses, add them only if the group breaks
|
||||
if_group_breaks(&text("(")),
|
||||
soft_block_indent(&ExprSequence::new(elts)),
|
||||
if_group_breaks(&text(")")),
|
||||
])]
|
||||
)
|
||||
}
|
||||
elts => optional_parentheses(&ExprSequence::new(elts)).fmt(f),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue