Skip to content

black stopped formatting my code #16905

@Marmeladenbrot

Description

@Marmeladenbrot

Environment data

  • VS Code version: 1.59.0
  • Extension version (available under the Extensions sidebar):
    • Bracket Pair Colorizer v1.0.61
    • Field Lights Theme v0.0.11
    • GitLens v11.6.0
    • Jupyter v2021.8.1195043623
    • Pylance v2021.8.0
    • Python v2021.8.1105858891
    • Remote - WSL v0.58.2
    • vscode-icons v11.6.0
  • OS and version: Windows 10 Professional 64bit 21H1
  • Python version (& distribution if applicable, e.g. Anaconda): miniconda 3, conda 4.10.3, python 3.9.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: black 19.10b0
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Value of the python.languageServer setting: Default

Expected behaviour

black formats my file when saving the file (CTRL+S).

Actual behaviour

"Formatting with black" appears in the middle bottom left, but the file remains unformatted.

Steps to reproduce:

  • VS Code Version: 1.59.0
  • OS Version: Windows 10 Professional 64bit 21H2 19043.1151
  1. Clean install of VS Code
  2. Clean install of Python 3.9.6
  3. pip install black (version 21.7b0)
  4. Install VS Code extension "Python" v2021.8.1105858891
  5. Install VS Code extension Pylance v2021.8.0
  6. in VS Code set formatter to "black"
  7. in VS Code set Format on Save to "True"
  8. open project folder
  9. open test.py file from project
  10. save unformatted file with CTRL+S --> "Formatting with black" appears in the bottom corner but nothing happens

user settings.json
{
"python.formatting.provider": "black",
"editor.formatOnSave": true
}

workspace settings.json
{
"python.formatting.provider": "black"
}

It works when I call "black" via CMD > "black test.py"

reformatted test.py
All done! ✨ 🍰 ✨
1 file reformatted.

Logs

User belongs to experiment group 'pythonaa'
User belongs to experiment group 'pythonJoinMailingListVar2'
User belongs to experiment group 'pythonJediLSP'
User belongs to experiment group 'pythonDiscoveryModuleWithoutWatcher'
User belongs to experiment group 'pythonTensorboardExperiment'
User belongs to experiment group 'pythonSurveyNotificationcf'
User belongs to experiment group 'PythonPyTorchProfiler'
User belongs to experiment group 'pythonDeprecatePythonPath'
User belongs to experiment group 'pythonSortEnvs'
Python interpreter path: ~\AppData\Local\Programs\Python\Python39\python.exe
Starting Pylance language server.
> conda --version

Details

I work with a conda virtual environment namend "work" which is set as the Python interpreter path in the bottom left corner.

User settings.json
{
"workbench.colorTheme": "Field Lights",
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"editor.fontFamily": "'Fira Code'",
"editor.fontLigatures": true,
"jupyter.interactiveWindowMode": "perFile",
"editor.formatOnPaste": true,
"workbench.iconTheme": "vscode-icons",
"workbench.editor.enablePreview": false,
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
"vsicons.dontShowNewVersionMessage": true,
"python.analysis.completeFunctionParens": true,
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"editor.formatOnSaveTimeout": 5000,
"terminal.integrated.profiles.windows": {
"Command Prompt": {
"path": [
"${env:windir}\Sysnative\cmd.exe",
"${env:windir}\System32\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
},
"terminal.integrated.defaultProfile.windows": "Command Prompt",
}

Workspace settings.json:
{}

.condarc:
channels:
- defaults
channel_priority: flexible

conda list:

Name Version Build Channel

appdirs 1.4.4 py_0
attrs 21.2.0 pyhd3eb1b0_0
backcall 0.2.0 pyhd3eb1b0_0
black 19.10b0 py_0
blas 1.0 mkl
bottleneck 1.3.2 py39h7cc1a96_1
ca-certificates 2021.7.5 haa95532_1
certifi 2021.5.30 py39haa95532_0
click 8.0.1 pyhd3eb1b0_0
colorama 0.4.4 pyhd3eb1b0_0
decorator 5.0.9 pyhd3eb1b0_0
et_xmlfile 1.1.0 py39haa95532_0
flake8 3.9.2 pyhd3eb1b0_0
importlib-metadata 3.10.0 py39haa95532_0
intel-openmp 2021.3.0 haa95532_3372
ipykernel 5.3.4 py39h7b7c402_0
ipython 7.26.0 py39hd4e2768_0
ipython_genutils 0.2.0 pyhd3eb1b0_1
jdcal 1.4.1 py_0
jedi 0.18.0 py39haa95532_1
jupyter_client 6.1.12 pyhd3eb1b0_0
jupyter_core 4.7.1 py39haa95532_0
libsodium 1.0.18 h62dcd97_0
matplotlib-inline 0.1.2 pyhd3eb1b0_2
mccabe 0.6.1 py39haa95532_1
mkl 2021.3.0 haa95532_524
mkl-service 2.4.0 py39h2bbff1b_0
mkl_fft 1.3.0 py39h277e83a_2
mkl_random 1.2.2 py39hf11a4ad_0
mypy_extensions 0.4.3 py39haa95532_0
numexpr 2.7.3 py39hb80d3ca_1
numpy 1.20.3 py39ha4e8547_0
numpy-base 1.20.3 py39hc2deb75_0
openpyxl 3.0.7 pyhd3eb1b0_0
openssl 1.1.1k h2bbff1b_0
pandas 1.3.1 py39h6214cd6_0
parso 0.8.2 pyhd3eb1b0_0
pathspec 0.7.0 py_0
pickleshare 0.7.5 pyhd3eb1b0_1003
pip 21.2.2 py39haa95532_0
prompt-toolkit 3.0.17 pyh06a4308_0
pycodestyle 2.7.0 pyhd3eb1b0_0
pyflakes 2.3.1 pyhd3eb1b0_0
pygments 2.9.0 pyhd3eb1b0_0
python 3.9.6 h6244533_0
python-dateutil 2.8.2 pyhd3eb1b0_0
pytz 2021.1 pyhd3eb1b0_0
pywin32 228 py39hbaba5e8_1
pyzmq 20.0.0 py39hd77b12b_1
regex 2021.8.3 py39h2bbff1b_0
setuptools 52.0.0 py39haa95532_0
six 1.16.0 pyhd3eb1b0_0
sqlite 3.36.0 h2bbff1b_0
toml 0.10.2 pyhd3eb1b0_0
tornado 6.1 py39h2bbff1b_0
traitlets 5.0.5 pyhd3eb1b0_0
typed-ast 1.4.3 py39h2bbff1b_1
typing_extensions 3.10.0.0 pyh06a4308_0
tzdata 2021a h52ac0ba_0
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
wcwidth 0.2.5 py_0
wheel 0.36.2 pyhd3eb1b0_0
wincertstore 0.2 py39h2bbff1b_0
zeromq 4.3.3 ha925a31_3
zipp 3.5.0 pyhd3eb1b0_0

Metadata

Metadata

Assignees

Labels

area-formattingbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions