mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-11 19:02:03 +00:00
Hug closing }
when f-string expression has a format specifier (#18704)
This commit is contained in:
parent
2b731d19b9
commit
c22f809049
11 changed files with 323 additions and 198 deletions
|
@ -7,7 +7,7 @@ use ruff_python_parser::Tokens;
|
|||
|
||||
use crate::PyFormatOptions;
|
||||
use crate::comments::Comments;
|
||||
use crate::other::interpolated_string_element::InterpolatedElementContext;
|
||||
use crate::other::interpolated_string::InterpolatedStringContext;
|
||||
|
||||
pub struct PyFormatContext<'a> {
|
||||
options: PyFormatOptions,
|
||||
|
@ -143,7 +143,7 @@ pub(crate) enum InterpolatedStringState {
|
|||
/// curly brace in `f"foo {x}"`.
|
||||
///
|
||||
/// The containing `FStringContext` is the surrounding f-string context.
|
||||
InsideInterpolatedElement(InterpolatedElementContext),
|
||||
InsideInterpolatedElement(InterpolatedStringContext),
|
||||
/// The formatter is outside an f-string.
|
||||
#[default]
|
||||
Outside,
|
||||
|
@ -153,7 +153,7 @@ impl InterpolatedStringState {
|
|||
pub(crate) fn can_contain_line_breaks(self) -> Option<bool> {
|
||||
match self {
|
||||
InterpolatedStringState::InsideInterpolatedElement(context) => {
|
||||
Some(context.can_contain_line_breaks())
|
||||
Some(context.is_multiline())
|
||||
}
|
||||
InterpolatedStringState::Outside => None,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue