Loading src/black/__init__.py +3 −2 Changes for src/black/__init__.py: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -6006,13 +6006,14 @@ def _stringify_ast( else: # Constant strings may be indented across newlines, if they are # docstrings; fold spaces after newlines when comparing # docstrings; fold spaces after newlines when comparing. Similarly, # trailing and leading space may be removed. if ( isinstance(node, ast.Constant) and field == "value" and isinstance(value, str) ): normalized = re.sub(r"\n[ \t]+", "\n ", value) normalized = re.sub(r" *\n[ \t]+", "\n ", value).strip() else: normalized = value yield f"{' ' * (depth+2)}{normalized!r}, # {value.__class__.__name__}" Loading tests/data/docstring.py +12 −0 Changes for tests/data/docstring.py: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -66,6 +66,13 @@ def over_indent(): """ pass def single_line(): """But with a newline after it! """ pass # output class MyClass: Loading Loading @@ -136,3 +143,8 @@ def over_indent(): - And the closing quote is too deep """ pass def single_line(): """But with a newline after it!""" pass Loading
src/black/__init__.py +3 −2 Changes for src/black/__init__.py: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -6006,13 +6006,14 @@ def _stringify_ast( else: # Constant strings may be indented across newlines, if they are # docstrings; fold spaces after newlines when comparing # docstrings; fold spaces after newlines when comparing. Similarly, # trailing and leading space may be removed. if ( isinstance(node, ast.Constant) and field == "value" and isinstance(value, str) ): normalized = re.sub(r"\n[ \t]+", "\n ", value) normalized = re.sub(r" *\n[ \t]+", "\n ", value).strip() else: normalized = value yield f"{' ' * (depth+2)}{normalized!r}, # {value.__class__.__name__}" Loading
tests/data/docstring.py +12 −0 Changes for tests/data/docstring.py: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -66,6 +66,13 @@ def over_indent(): """ pass def single_line(): """But with a newline after it! """ pass # output class MyClass: Loading Loading @@ -136,3 +143,8 @@ def over_indent(): - And the closing quote is too deep """ pass def single_line(): """But with a newline after it!""" pass