Skip to content

Commit

Permalink
Remove FormatFStringPart
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Nov 19, 2024
1 parent d8538d8 commit 19e6a99
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 42 deletions.
9 changes: 6 additions & 3 deletions crates/ruff_python_formatter/src/expression/expr_f_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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() {
Expand Down
38 changes: 0 additions & 38 deletions crates/ruff_python_formatter/src/other/f_string_part.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/ruff_python_formatter/src/other/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub(crate) mod elif_else_clause;
pub(crate) mod except_handler_except_handler;
pub(crate) mod f_string;
pub(crate) mod f_string_element;
pub(crate) mod f_string_part;
pub(crate) mod identifier;
pub(crate) mod keyword;
pub(crate) mod match_case;
Expand Down

0 comments on commit 19e6a99

Please sign in to comment.