Rename ExprStringLiteral::as_unconcatenated_string() to ExprStringLiteral::as_single_part_string() (#16253)

This commit is contained in:
Alex Waygood 2025-02-19 16:06:57 +00:00 committed by GitHub
parent 97d0659ce3
commit 25920fe489
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 50 additions and 45 deletions

View file

@ -1,7 +1,7 @@
use ruff_formatter::{format_args, write, FormatError, RemoveSoftLinesBuffer};
use ruff_python_ast::{
AnyNodeRef, Expr, ExprAttribute, ExprCall, FString, FStringPart, Operator, StmtAssign,
StringLike, TypeParams,
AnyNodeRef, Expr, ExprAttribute, ExprCall, FString, Operator, StmtAssign, StringLike,
TypeParams,
};
use crate::builders::parenthesize_if_expands;
@ -1107,9 +1107,7 @@ fn format_f_string_assignment<'a>(
return None;
};
let [FStringPart::FString(f_string)] = expr.value.as_slice() else {
return None;
};
let f_string = expr.as_single_part_fstring()?;
// If the f-string is flat, there are no breakpoints from which it can be made multiline.
// This is the case when the f-string has no expressions or if it does then the expressions