Commit 7f367888 authored by Zsolt Dollenstein's avatar Zsolt Dollenstein Committed by Łukasz Langa
Browse files

fix handling of empty triple quoted strings (#314)

parent 75a94474
Loading
Loading
Loading
Loading
+1 −0
Changes for README.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -813,6 +813,7 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).

* fixed improper unmodified file caching when `-S` was used

* fixed formatting of empty triple quoted strings (#313)

### 18.6b1

+1 −1
Changes for black.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -2546,7 +2546,7 @@ def normalize_string_quotes(leaf: Leaf) -> None:
            leaf.value = f"{prefix}{orig_quote}{body}{orig_quote}"
        new_body = sub_twice(escaped_orig_quote, rf"\1\2{orig_quote}", new_body)
        new_body = sub_twice(unescaped_new_quote, rf"\1\\{new_quote}", new_body)
    if new_quote == '"""' and new_body[-1] == '"':
    if new_quote == '"""' and new_body[-1:] == '"':
        # edge case:
        new_body = new_body[:-1] + '\\"'
    orig_escape_count = body.count("\\")
+2 −0
Changes for tests/data/string_quotes.py: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
''''''
'\''
'"'
"'"
@@ -45,6 +46,7 @@

# output

""""""
"'"
'"'
"'"