vscode-python: cannot format with black
Issue Type: Bug
Hi,
I cannot format with black anymore. It used to work, but now nothing happens when I run ‘Format Document’.
Looking at the output window, I get a message like:
> ~\Path\to\black --diff --quiet .\myfile.py
cwd: .
Nothing happens and it’s not clear if black runs at all. However running the exact same command in e.g. the Anaconda prompt, I do get the appropriate diff.
I’ve set the black path explicitly in the settings. If I don’t set it, it still doesn’t work but I get another error:
Formatting with black failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
My black
is installed in a conda environment.
Extension version: 2022.2.1924087327 VS Code version: Code 1.65.2 (c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1, 2022-03-10T14:33:55.248Z) OS version: Windows_NT x64 10.0.19042 Restricted Mode: No
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i7-8565U CPU @ 1.80GHz (8 x 1992) |
GPU Status | 2d_canvas: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: enabled opengl: enabled_on rasterization: enabled skia_renderer: enabled_on video_decode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled |
Load (avg) | undefined |
Memory (System) | 15.79GB (6.84GB free) |
Process Argv | –crash-reporter-id a6cf3bf2-573c-4551-964f-40f16776be01 |
Screen Reader | no |
VM | 0% |
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscoreces:30445986
pythondataviewer:30285071
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vsclayoutctrt:30451275
dsvsc009:30452663
pythonvsnew555:30450902
vscscmwlcmc:30438804
pynewfile477cf:30450039
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 16 (5 by maintainers)
Please try the new Black formatter extension, and see if it helps in your scenario: https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter
Be sure to disable formatting with python extension:
"python.formatting.provider": "none"