Skip to content

Crash with line-length 18 and backslash in docstring #3425

@JelleZijlstra

Description

@JelleZijlstra

Code:

def multiline_backslash_2():
    """
    hey there \ """

On Black 22.12.0:

% black --preview --diff tests/data/miscellaneous/docstring_no_string_normalization.py -l 18
error: cannot format tests/data/miscellaneous/docstring_no_string_normalization.py: INTERNAL ERROR: Black produced code that is not equivalent to the source.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/3b/k964cnv10097wzj3h7w07fww0000gp/T/blk_jh8pb654.log

Oh no! 💥 💔 💥
1 file would fail to reformat.
% cat /var/folders/3b/k964cnv10097wzj3h7w07fww0000gp/T/blk_jh8pb654.log

--- src
+++ dst
@@ -18,11 +18,11 @@
           value=
             Constant(
               kind=
                 None,  # NoneType
               value=
-                'hey there \\',  # str
+                'hey there',  # str
             )  # /Constant
         )  # /Expr
       decorator_list=
       name=
         'multiline_backslash_2',  # str

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: crashBlack is crashingC: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.F: docstringsHow we format docstringsT: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions