Skip to content

Commit 47c1630

Browse files
committed
Move quoting function as well
1 parent f903e30 commit 47c1630

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

crates/ruff_python_formatter/src/string/any.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ use ruff_python_ast::{
66
self as ast, AnyNodeRef, AnyStringFlags, Expr, ExprBytesLiteral, ExprFString,
77
ExprStringLiteral, ExpressionRef, StringFlags, StringLiteral,
88
};
9-
use ruff_source_file::Locator;
109
use ruff_text_size::{Ranged, TextRange};
1110

12-
use crate::expression::expr_f_string::f_string_quoting;
13-
use crate::string::Quoting;
14-
1511
/// Represents any kind of string expression. This could be either a string,
1612
/// bytes or f-string.
1713
#[derive(Copy, Clone, Debug)]
@@ -47,14 +43,6 @@ impl<'a> AnyString<'a> {
4743
matches!(self, Self::FString(_))
4844
}
4945

50-
/// Returns the quoting to be used for this string.
51-
pub(super) fn quoting(self, locator: &Locator<'_>) -> Quoting {
52-
match self {
53-
Self::String(_) | Self::Bytes(_) => Quoting::CanChange,
54-
Self::FString(f_string) => f_string_quoting(f_string, locator),
55-
}
56-
}
57-
5846
/// Returns an iterator over the [`AnyStringPart`]s of this string.
5947
pub(super) fn parts(self) -> AnyStringPartsIter<'a> {
6048
match self {

crates/ruff_python_formatter/src/string/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use ruff_python_ast::{
1010
use ruff_text_size::{Ranged, TextRange};
1111

1212
use crate::comments::{leading_comments, trailing_comments};
13+
use crate::expression::expr_f_string::f_string_quoting;
1314
use crate::expression::parentheses::in_parentheses_only_soft_line_break_or_space;
1415
use crate::other::f_string::FormatFString;
1516
use crate::other::string_literal::StringLiteralKind;
@@ -45,7 +46,11 @@ impl<'a> FormatImplicitConcatenatedString<'a> {
4546
impl Format<PyFormatContext<'_>> for FormatImplicitConcatenatedString<'_> {
4647
fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> {
4748
let comments = f.context().comments().clone();
48-
let quoting = self.string.quoting(&f.context().locator());
49+
50+
let quoting = match self.string {
51+
AnyString::String(_) | AnyString::Bytes(_) => Quoting::CanChange,
52+
AnyString::FString(f_string) => f_string_quoting(f_string, &f.context().locator()),
53+
};
4954

5055
let mut joiner = f.join_with(in_parentheses_only_soft_line_break_or_space());
5156

0 commit comments

Comments
 (0)