From 1c66bb80b70d36c0069a04ff174f165290f50aea Mon Sep 17 00:00:00 2001 From: David Szotten Date: Fri, 25 Aug 2023 08:58:26 +0100 Subject: [PATCH] fix is_raw_string for multiple prefixes (#6865) fix `is_raw_string` in the presence of other prefixes (like `rb"foo"`) fixes #6864 --- crates/ruff_python_formatter/src/expression/string.rs | 2 +- .../tests/snapshots/format@expression__fstring.py.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 = (