diff --git a/CHANGES.md b/CHANGES.md index 63c7a2cf30d..562b28d8039 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ - Restored compatibility with Click 8.0 on Python 3.6 when LANG=C used (#2227) - Add extra uvloop install + import support if in python env (#2258) - Fix --experimental-string-processing crash when matching parens are not found (#2283) +- Fix regression where `R` prefixes would be lowercased for docstrings (#2285) ### _Blackd_ diff --git a/src/black/strings.py b/src/black/strings.py index 5b443ddebc9..80f588f5119 100644 --- a/src/black/strings.py +++ b/src/black/strings.py @@ -87,7 +87,7 @@ def get_string_prefix(string: str) -> str: prefix = "" prefix_idx = 0 while string[prefix_idx] in STRING_PREFIX_CHARS: - prefix += string[prefix_idx].lower() + prefix += string[prefix_idx] prefix_idx += 1 return prefix diff --git a/tests/data/string_prefixes.py b/tests/data/string_prefixes.py index 0ca3686a2b6..9ddc2b540fc 100644 --- a/tests/data/string_prefixes.py +++ b/tests/data/string_prefixes.py @@ -6,6 +6,17 @@ r"hello" fR"hello" + +def docstring_singleline(): + R"""2020 was one hell of a year. The good news is that we were able to""" + + +def docstring_multiline(): + R""" + clear out all of the issues opened in that time :p + """ + + # output @@ -16,3 +27,13 @@ b"hello" r"hello" fR"hello" + + +def docstring_singleline(): + R"""2020 was one hell of a year. The good news is that we were able to""" + + +def docstring_multiline(): + R""" + clear out all of the issues opened in that time :p + """