cannot format with black
See original GitHub issueIssue 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
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Cannot format file (black produced different code on ... - GitHub
I'm unable to format some files with black version 20.8b1.
Read more >Python Black failed to format `print("\n", end='')` - Stack Overflow
Why can't black format this code? If I remove it, Black just fails again at the next point that it encounters a print...
Read more >black · PyPI
Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives...
Read more >Frequently Asked Questions - Black 22.12.0 documentation
Black is an autoformatter, not a Python linter or interpreter. Detecting all syntax errors is not a goal. It can format all code...
Read more >Setting up python Black on Visual Studio Code | by Marco Belo
Type “format on save” at the search bar on top of the Settings tab and check the box. Search for “python formatting provider”...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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"
Closing this in favor of the black formatter extension https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter