string prefixes: don't normalise capital R-strings (#1271)
Resolves #1244 Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
bbe5ae70c1
commit
6d8b90167b
2
black.py
2
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)}"
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user