Skip to content

Black formatter : src error #18557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Laufron opened this issue Feb 22, 2022 · 2 comments
Closed

Black formatter : src error #18557

Laufron opened this issue Feb 22, 2022 · 2 comments
Assignees
Labels
area-formatting bug Issue identified by VS Code Team member as probable bug

Comments

@Laufron
Copy link

Laufron commented Feb 22, 2022

Issue Type: Bug

my settings are the following :
"python.formatting.provider": "black",
"python.formatting.blackPath": "C:/SafApp/Python/Python3.10-64/Scripts/black.exe",
"python.formatting.blackArgs": [
"--preview"
],
"[python]": {
"editor.defaultFormatter": null
},
"editor.formatOnSave": true,

black works perfectly when used by command line, but the command launched by the formatOnSave seems wrong to me. As a result black doesn't format my files on save.

when saving the file pandas_loc.py :
Output tab [Python]:

C:/SafApp/Python/Python3.10-64/Scripts/black.exe --preview --diff --quiet .\pandas_loc.py.40996521066352b2ddb99ea0eda2de46.tmp
cwd: .
... and my file is not formatted

i tried the command in the vscode integrated terminal and got :

Usage: black [OPTIONS] SRC ...
Try 'black -h' for help.

Error: Invalid value for 'SRC ...': Path '.\pandas_loc.py.40996521066352b2ddb99ea0eda2de46.tmp' does not exist.

I guess the tmp file should be the output but black is trying to format the unexisting tmp file.
Hope you can help

Extension version: 2022.0.1814523869
VS Code version: Code 1.64.2 (f80445acd5a3dadef24aa209168452a3d97cc326, 2022-02-09T22:02:28.252Z)
OS version: Windows_NT x64 10.0.19042
Restricted Mode: No

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i5-11500H @ 2.90GHz (12 x 2918)
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.73GB (6.07GB free)
Process Argv --crash-reporter-id 2b922bf5-16af-4ccd-bc73-c682c088cd49
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30425749
pythontb:30283811
pythonvspyt551:30345470
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
pythondataviewer:30285071
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30433507
vsclayoutctrc:30437038
vsrem710:30416614
dsvsc009:30440023
vsbas813:30436447
vscscmwlcmt:30438805
helix:30440343

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 22, 2022
@karthiknadig karthiknadig self-assigned this Feb 22, 2022
@karthiknadig karthiknadig added area-formatting bug Issue identified by VS Code Team member as probable bug triage and removed triage-needed Needs assignment to the proper sub-team labels Feb 22, 2022
@karthiknadig
Copy link
Member

@Laufron This occurs because we try to figure out the formatting changes on a file, using a temp file. If the temp file creation failed for some reason, then you run into this error.

We have been working on creating black formatter extension that will handle this differently. This issue will be addressed by that extension when it gets released. If you want to try it out, you can find it here. psf/black#2883

@karthiknadig
Copy link
Member

Should be addressed by #17918

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-formatting bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

2 participants