Skip to content

Commit 6d8b901

Browse files
hauntsaninjaambv
andauthored
string prefixes: don't normalise capital R-strings (#1271)
Resolves #1244 Co-authored-by: Łukasz Langa <[email protected]>
1 parent bbe5ae7 commit 6d8b901

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

black.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2842,7 +2842,7 @@ def normalize_string_prefix(leaf: Leaf, remove_u_prefix: bool = False) -> None:
28422842
match = re.match(r"^([furbFURB]*)(.*)$", leaf.value, re.DOTALL)
28432843
assert match is not None, f"failed to match string {leaf.value!r}"
28442844
orig_prefix = match.group(1)
2845-
new_prefix = orig_prefix.lower()
2845+
new_prefix = orig_prefix.replace("F", "f").replace("B", "b").replace("U", "u")
28462846
if remove_u_prefix:
28472847
new_prefix = new_prefix.replace("u", "")
28482848
leaf.value = f"{new_prefix}{match.group(2)}"

tests/data/string_prefixes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
name = R"Łukasz"
44
F"hello {name}"
55
B"hello"
6+
r"hello"
7+
fR"hello"
68

79
# output
810

911

1012
#!/usr/bin/env python3.6
1113

12-
name = r"Łukasz"
14+
name = R"Łukasz"
1315
f"hello {name}"
1416
b"hello"
17+
r"hello"
18+
fR"hello"

0 commit comments

Comments
 (0)