From 6d8b90167b00707c5524f993933e33ddbd5a90f6 Mon Sep 17 00:00:00 2001 From: Shantanu Date: Tue, 3 Mar 2020 05:55:14 -0800 Subject: [PATCH] string prefixes: don't normalise capital R-strings (#1271) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Resolves #1244 Co-authored-by: Łukasz Langa --- black.py | 2 +- tests/data/string_prefixes.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/black.py b/black.py index 69d24c5..b7cacf7 100644 --- a/black.py +++ b/black.py @@ -2842,7 +2842,7 @@ def normalize_string_prefix(leaf: Leaf, remove_u_prefix: bool = False) -> None: match = re.match(r"^([furbFURB]*)(.*)$", leaf.value, re.DOTALL) assert match is not None, f"failed to match string {leaf.value!r}" orig_prefix = match.group(1) - new_prefix = orig_prefix.lower() + new_prefix = orig_prefix.replace("F", "f").replace("B", "b").replace("U", "u") if remove_u_prefix: new_prefix = new_prefix.replace("u", "") leaf.value = f"{new_prefix}{match.group(2)}" diff --git a/tests/data/string_prefixes.py b/tests/data/string_prefixes.py index fbad5e0..0ca3686 100644 --- a/tests/data/string_prefixes.py +++ b/tests/data/string_prefixes.py @@ -3,12 +3,16 @@ name = R"Łukasz" F"hello {name}" B"hello" +r"hello" +fR"hello" # output #!/usr/bin/env python3.6 -name = r"Łukasz" +name = R"Łukasz" f"hello {name}" b"hello" +r"hello" +fR"hello" -- 2.39.5