When attempting to format the attached (problematic) file, black outputs INTERNAL ERROR: Black produced code that is not equivalent to the source
To Reproduce
Take the attached file
Run Black on it with these arguments run black -l 120 --target-version py38 src (where src is the parent directory of the file)
See error
error: cannot format <my file path>/_instrumentation.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/f8/9fz_qgqs5d7ctybtrblxzkpc0000gn/T/blk_3xx4g81a.log
Expected behavior
Either the file gets correctly formatted, or an error message is returned that the file cannot be formatted
Environment (please complete the following information):
Version: black, version 19.10b0, and black, version 21.8b0
OS and Python version:
Python 3.8.6 (default, Oct 24 2020, 20:45:42)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
OSX: 10.14.6
Does this bug also happen on main?
Using the online formatter, the following error is produced:
cannot use --safe with this file; failed to parse source file. AST error message: The requested source code has invalid Python 3 syntax.
If you are trying to format Python 2 files please reinstall Black with the 'python2' extra: `python3 -m pip install black[python2]`.
Additional context
The attached file is not valid because it mixes tabs and spaces, so it is reasonable that it doesn't format - it's the error feedback that is probably the real issue
Describe the bug
When attempting to format the attached (problematic) file, black outputs
INTERNAL ERROR: Black produced code that is not equivalent to the source
To Reproduce
run black -l 120 --target-version py38 src
(wheresrc
is the parent directory of the file)error: cannot format <my file path>/_instrumentation.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/f8/9fz_qgqs5d7ctybtrblxzkpc0000gn/T/blk_3xx4g81a.log
Expected behavior
Either the file gets correctly formatted, or an error message is returned that the file cannot be formatted
Environment (please complete the following information):
OSX: 10.14.6
Does this bug also happen on main?
Using the online formatter, the following error is produced:
Additional context
The attached file is not valid because it mixes tabs and spaces, so it is reasonable that it doesn't format - it's the error feedback that is probably the real issue
Log file (taken from the 21.8b0 run) blk_eik4al6v.log
File being formatted example.txt