From: Shantanu Date: Tue, 3 Mar 2020 13:55:14 +0000 (-0800) Subject: string prefixes: don't normalise capital R-strings (#1271) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/6d8b90167b00707c5524f993933e33ddbd5a90f6?hp=bbe5ae70c17ff16801fef240f49b707535c7f64c string prefixes: don't normalise capital R-strings (#1271) Resolves #1244 Co-authored-by: Łukasz Langa --- 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"