Unverified Commit 6d8b9016 authored by Shantanu's avatar Shantanu Committed by GitHub
Browse files

string prefixes: don't normalise capital R-strings (#1271)

Resolves #1244

Co-authored-by: default avatarŁukasz Langa <lukasz@langa.pl>
parent bbe5ae70
Loading
Loading
Loading
Loading
+1 −1
Changes for black.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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)}"
+5 −1
Changes for tests/data/string_prefixes.py: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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"