psf / black

The uncompromising Python code formatter
https://black.readthedocs.io/en/stable/
MIT License
38.86k stars 2.45k forks source link

File failed to reformat #3267

Closed KennedyRichard closed 2 years ago

KennedyRichard commented 2 years ago

Describe the bug

File failed to format. Both the file and diff are attached to this message.

Error present in both newest version of black (used pip install --upgrade black to make sure) and [online formatter] (https://black.vercel.app/?version=main).

Environment

Operating system: Linux (xubuntu 22.04 64bits) Python version: 3.10.4 black.__version__ == '22.8.0'

The resulting error

running black main.py produces the following error:

error: cannot format main.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: /tmp/blk_l5hj035o.log

Oh no! 💥 💔 💥
1 file failed to reformat.

issue_files.zip

Thank you for your selfless work.

KennedyRichard commented 2 years ago

Just another bit of information that might be useful:

The main.py file in question is a battle-hardened file which has been part of a public repository and in use for many years, even before being uploaded to github a couple of months ago, so there's probably no problem with the file itself. At least none that I can identify myself.

Here's an additional link to the file at the specific commit where I tried black main.py on it: main.py

felix-hilden commented 2 years ago

The issue is resolved (playground) when the space after \ in the class docstring is removed. This issue is already reported in #3079, so I'll close this as a duplicate. Thanks for reporting though!

KennedyRichard commented 2 years ago

After removing the character I'm able to black-format the file. I've subscribed to the original issue so I can be updated of the progress on the issue. Again, thank you for your selfless work.