X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0a833b4b14953f98e81d632281a75318faa66170..a0b4e609a7393fac11ecc94eb859c1e85b540036:/src/black/__init__.py diff --git a/src/black/__init__.py b/src/black/__init__.py index 00d3729..051de5d 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -2186,7 +2186,13 @@ class LineGenerator(Visitor[Line]): if docstring[0] == quote_char: docstring = " " + docstring if docstring[-1] == quote_char: - docstring = docstring + " " + docstring += " " + if docstring[-1] == "\\": + backslash_count = len(docstring) - len(docstring.rstrip("\\")) + if backslash_count % 2: + # Odd number of tailing backslashes, add some padding to + # avoid escaping the closing string quote. + docstring += " " else: # Add some padding if the docstring is empty. docstring = " " @@ -5613,7 +5619,12 @@ def maybe_make_parens_invisible_in_atom(node: LN, parent: LN) -> bool: return False if is_walrus_assignment(node): - if parent.type in [syms.annassign, syms.expr_stmt]: + if parent.type in [ + syms.annassign, + syms.expr_stmt, + syms.assert_stmt, + syms.return_stmt, + ]: return False first = node.children[0]