fix handling of empty triple quoted strings (#314)
This commit is contained in:
parent
75a9447448
commit
7f3678885f
@ -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
|
||||
|
||||
|
2
black.py
2
black.py
@ -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("\\")
|
||||
|
@ -1,3 +1,4 @@
|
||||
''''''
|
||||
'\''
|
||||
'"'
|
||||
"'"
|
||||
@ -45,6 +46,7 @@
|
||||
|
||||
# output
|
||||
|
||||
""""""
|
||||
"'"
|
||||
'"'
|
||||
"'"
|
||||
|
Loading…
Reference in New Issue
Block a user