Closed StarLightPL closed 1 year ago
@StarLightPL Do not use --diff
with this extension. The extension handles this for you, we use black in a mode that allows us to get formatted content directly without using diff.
@karthiknadig --diff
is set by the extension itself (these are black log outputs), so I'd suggest reopening this issue. The only one added by me is --no-color
. Diff is also not being set in pyproject.toml
either. VSCode should then add both --no-diff
and --no-color
by default, otherwise it breaks on current versions of the code and editor.
@StarLightPL Extension does not set --diff
, see below args
are empty by default:
https://github.com/microsoft/vscode-black-formatter/blob/b19ba19cd7fa77489d9341ce9a09768eeb8202eb/package.json#L80-L88
In your screen shot you only checked user settings. Please also check workspace and remote settings:
@karthiknadig checked the two, there's nothing in the arguments there. However, I also went through settings.json
, and it looks like there was a leftover from previous config (before installing the extension):
"python.formatting.blackArgs": [
"--diff"
],
As these arguments are not available in the UI anymore, it went unnoticed. Removed it and it now works as expected.
black, 23.3.0 (compiled: yes) Python (CPython) 3.7.16 vscode and extension up to date.
When I use "Format document", the file gets garbled with diff output. If I add
--no-color
option to black args in extension settings, everything works normally.test file:
Result:
Black extension log output:
Command used:
2023-10-05 14:33:05.821 [info] black --diff --stdin-filename /home/test-user/projects/test-project/black_issue.py -
And if I add
--no-color
to black args in extension settings, it works as expected.