mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 21:35:58 +00:00
Remove FormatFStringPart
(#14448)
## Summary This is just a small refactor to remove the `FormatFStringPart` as it's only used in the case when the f-string is not implicitly concatenated in which case the only part is going to be `FString`. In implicitly concatenated f-strings, we use `StringLike` instead.
This commit is contained in:
parent
ac23c99744
commit
efe54081d6
3 changed files with 6 additions and 42 deletions
|
@ -4,7 +4,7 @@ use ruff_text_size::TextSlice;
|
|||
use crate::expression::parentheses::{
|
||||
in_parentheses_only_group, NeedsParentheses, OptionalParentheses,
|
||||
};
|
||||
use crate::other::f_string_part::FormatFStringPart;
|
||||
use crate::other::f_string::FormatFString;
|
||||
use crate::prelude::*;
|
||||
use crate::string::implicit::FormatImplicitConcatenatedStringFlat;
|
||||
use crate::string::{implicit::FormatImplicitConcatenatedString, Quoting, StringLikeExtensions};
|
||||
|
@ -17,8 +17,11 @@ impl FormatNodeRule<ExprFString> for FormatExprFString {
|
|||
let ExprFString { value, .. } = item;
|
||||
|
||||
if let [f_string_part] = value.as_slice() {
|
||||
FormatFStringPart::new(f_string_part, f_string_quoting(item, f.context().source()))
|
||||
.fmt(f)
|
||||
// SAFETY: A single string literal cannot be an f-string. This is guaranteed by the
|
||||
// [`ruff_python_ast::FStringValue::single`] constructor.
|
||||
let f_string = f_string_part.as_f_string().unwrap();
|
||||
|
||||
FormatFString::new(f_string, f_string_quoting(item, f.context().source())).fmt(f)
|
||||
} else {
|
||||
// Always join fstrings that aren't parenthesized and thus, are always on a single line.
|
||||
if !f.context().node_level().is_parenthesized() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue