diff --git a/crates/ruff_python_formatter/src/expression/string.rs b/crates/ruff_python_formatter/src/expression/string.rs index 01fa93b372a57..8762fc69ce846 100644 --- a/crates/ruff_python_formatter/src/expression/string.rs +++ b/crates/ruff_python_formatter/src/expression/string.rs @@ -377,7 +377,7 @@ impl StringPrefix { } pub(super) const fn is_raw_string(self) -> bool { - matches!(self, StringPrefix::RAW | StringPrefix::RAW_UPPER) + self.contains(StringPrefix::RAW) || self.contains(StringPrefix::RAW_UPPER) } } diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap index e6e71562081b3..aa3f0a5133aae 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap @@ -46,7 +46,7 @@ result_f = ( (f"{one}" f"{two}") -rf'Not-so-tricky "quote' +rf"Not-so-tricky \"quote" # Regression test for fstrings dropping comments result_f = (