Skip to content

Fails to parse backslash on line by itself #4261

@JelleZijlstra

Description

@JelleZijlstra
% cat parse.py 
class Plotter:
\
    pass
% black parse.py 
error: cannot format parse.py: Cannot parse: 3:4:     pass

Oh no! 💥 💔 💥
1 file failed to reformat.
% black --version
black, 24.2.0 (compiled: yes)
Python (CPython) 3.12.0
% python parse.py
% 

Saw this in astral-sh/ruff#10099; the example is minified from the repro case in that issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: parserHow we parse code. Or fail to parse it.T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions