Closed mika457 closed 3 months ago
@mika457 Can you check Output > Black Formatter? see if it actually triggers formatting.
@karthiknadig Hello! Thanks for your reply. Here are the logs of both v2023.6.0 and v2024.0.0. v2023.6.0 works well while v2024.0.0 fails to work in jupyter notebook.
v2024.0.0:
2024-02-06 10:07:00.415 [info] e:\Python\python.exe -m black --skip-string-normalization --stdin-filename e:\VS Code Projects\Python & R\Scripts\jupyter_test.py -
2024-02-06 10:07:00.415 [info] CWD formatter: e:\VS Code Projects\Python & R
2024-02-06 10:07:00.425 [info] reformatted e:\VS Code Projects\Python & R\Scripts\jupyter_test.py
All done! ✨ 🍰 ✨
1 file reformatted.
2024-02-06 10:07:14.376 [info] [Info - 10:07:14 AM] Connection to server got closed. Server will restart.
2024-02-06 10:07:14.376 [info] true
2024-02-06 10:07:14.509 [info] [Error - 10:07:14 AM] Server process exited with code 1.
2024-02-06 10:07:14.983 [info] CWD Server: e:\VS Code Projects\LaTeX
2024-02-06 10:07:14.990 [info] e:\Python\python.exe -m black --version
2024-02-06 10:07:14.990 [info] CWD formatter: e:\VS Code Projects\LaTeX
2024-02-06 10:07:15.132 [info] Version info for formatter running for E:\VS Code Projects\LaTeX:
black, 24.1.1 (compiled: no)
Python (CPython) 3.11.7
2024-02-06 10:07:15.132 [info] SUPPORTED black>=22.3.0
FOUND black==24.1.1
2024-02-06 10:07:15.133 [info] e:\Python\python.exe -m black --version
2024-02-06 10:07:15.133 [info] CWD formatter: e:\VS Code Projects\Markdown
2024-02-06 10:07:15.133 [info] Version info for formatter running for E:\VS Code Projects\Markdown:
black, 24.1.1 (compiled: no)
Python (CPython) 3.11.7
2024-02-06 10:07:15.134 [info] SUPPORTED black>=22.3.0
FOUND black==24.1.1
2024-02-06 10:07:15.134 [info] e:\Python\python.exe -m black --version
2024-02-06 10:07:15.134 [info] CWD formatter: e:\VS Code Projects\Python & R
2024-02-06 10:07:15.135 [info] Version info for formatter running for E:\VS Code Projects\Python & R:
black, 24.1.1 (compiled: no)
Python (CPython) 3.11.7
2024-02-06 10:07:15.136 [info] SUPPORTED black>=22.3.0
FOUND black==24.1.1
2024-02-06 10:07:15.136 [info] e:\Python\python.exe -m black --version
2024-02-06 10:07:15.136 [info] CWD formatter: e:\VS Code Projects\Drawio
2024-02-06 10:07:15.138 [info] Version info for formatter running for E:\VS Code Projects\Drawio:
black, 24.1.1 (compiled: no)
Python (CPython) 3.11.7
2024-02-06 10:07:15.138 [info] SUPPORTED black>=22.3.0
FOUND black==24.1.1
2024-02-06 10:07:15.139 [info] Settings used to run Server:
[
{
"cwd": "e:\\VS Code Projects\\LaTeX",
"workspace": "file:///e%3A/VS%20Code%20Projects/LaTeX",
"args": [
"--skip-string-normalization"
],
"path": [],
"interpreter": [
"e:\\Python\\python.exe"
],
"importStrategy": "useBundled",
"showNotifications": "off"
},
{
"cwd": "e:\\VS Code Projects\\Markdown",
"workspace": "file:///e%3A/VS%20Code%20Projects/Markdown",
"args": [
"--skip-string-normalization"
],
"path": [],
"interpreter": [
"e:\\Python\\python.exe"
],
"importStrategy": "useBundled",
"showNotifications": "off"
},
{
"cwd": "e:\\VS Code Projects\\Python & R",
"workspace": "file:///e%3A/VS%20Code%20Projects/Python%20%26%20R",
"args": [
"--skip-string-normalization"
],
"path": [],
"interpreter": [
"e:\\Python\\python.exe"
],
"importStrategy": "useBundled",
"showNotifications": "off"
},
{
"cwd": "e:\\VS Code Projects\\Drawio",
"workspace": "file:///e%3A/VS%20Code%20Projects/Drawio",
"args": [
"--skip-string-normalization"
],
"path": [],
"interpreter": [
"e:\\Python\\python.exe"
],
"importStrategy": "useBundled",
"showNotifications": "off"
}
]
2024-02-06 10:07:15.139 [info] Global settings:
{
"cwd": "E:\\Microsoft VS Code",
"workspace": "E:\\Microsoft VS Code",
"args": [
"--skip-string-normalization"
],
"path": [],
"interpreter": [],
"importStrategy": "useBundled",
"showNotifications": "off"
}
2024-02-06 10:07:15.139 [info] sys.path used to run Server:
c:\Users\ZedLv\.vscode\extensions\ms-python.black-formatter-2024.0.0\bundled\libs
c:\Users\ZedLv\.vscode\extensions\ms-python.black-formatter-2024.0.0\bundled\tool
e:\Python\python311.zip
e:\Python\DLLs
e:\Python\Lib
e:\Python
e:\Python\Lib\site-packages
e:\Python\Lib\site-packages\win32
e:\Python\Lib\site-packages\win32\lib
e:\Python\Lib\site-packages\Pythonwin
v2023.6.0:
2024-02-06 10:09:49.721 [info] [Trace - 10:09:49 AM] Sending notification 'textDocument/didChange'.
2024-02-06 10:09:49.774 [info] [Trace - 10:09:49 AM] Sending notification 'textDocument/didChange'.
2024-02-06 10:09:49.784 [info] [Trace - 10:09:49 AM] Sending notification 'textDocument/didChange'.
2024-02-06 10:09:49.802 [info] [Trace - 10:09:49 AM] Sending request 'textDocument/formatting - (5)'.
2024-02-06 10:09:49.803 [info] [Trace - 10:09:49 AM] Sending request 'textDocument/formatting - (6)'.
2024-02-06 10:09:49.803 [info] [Trace - 10:09:49 AM] Sending request 'textDocument/formatting - (7)'.
2024-02-06 10:09:49.803 [info] [Trace - 10:09:49 AM] Sending request 'textDocument/formatting - (8)'.
2024-02-06 10:09:49.807 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.808 [info] e:\Python\python.exe -m black --skip-string-normalization --stdin-filename e:\VS Code Projects\Python & R\Scripts\jupyter_test.py -
2024-02-06 10:09:49.808 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.808 [info] CWD formatter: e:\VS Code Projects\Python & R
2024-02-06 10:09:49.813 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.813 [info] reformatted e:\VS Code Projects\Python & R\Scripts\jupyter_test.py
All done! ✨ 🍰 ✨
1 file reformatted.
2024-02-06 10:09:49.813 [info] [Trace - 10:09:49 AM] Received response 'textDocument/formatting - (5)' in 10ms.
2024-02-06 10:09:49.816 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.816 [info] e:\Python\python.exe -m black --skip-string-normalization --stdin-filename e:\VS Code Projects\Python & R\Scripts\jupyter_test.py -
2024-02-06 10:09:49.816 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.817 [info] CWD formatter: e:\VS Code Projects\Python & R
2024-02-06 10:09:49.829 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.829 [info] reformatted e:\VS Code Projects\Python & R\Scripts\jupyter_test.py
All done! ✨ 🍰 ✨
1 file reformatted.
2024-02-06 10:09:49.833 [info] [Trace - 10:09:49 AM] Received response 'textDocument/formatting - (6)' in 30ms.
2024-02-06 10:09:49.838 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.838 [info] e:\Python\python.exe -m black --skip-string-normalization --stdin-filename e:\VS Code Projects\Python & R\Scripts\jupyter_test.py -
2024-02-06 10:09:49.838 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.838 [info] CWD formatter: e:\VS Code Projects\Python & R
2024-02-06 10:09:49.847 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.847 [info] reformatted e:\VS Code Projects\Python & R\Scripts\jupyter_test.py
All done! ✨ 🍰 ✨
1 file reformatted.
2024-02-06 10:09:49.848 [info] [Trace - 10:09:49 AM] Received response 'textDocument/formatting - (7)' in 45ms.
2024-02-06 10:09:49.850 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.851 [info] e:\Python\python.exe -m black --skip-string-normalization --stdin-filename e:\VS Code Projects\Python & R\Scripts\jupyter_test.py -
2024-02-06 10:09:49.851 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.851 [info] CWD formatter: e:\VS Code Projects\Python & R
2024-02-06 10:09:49.855 [info] [Trace - 10:09:49 AM] Received notification 'window/logMessage'.
2024-02-06 10:09:49.855 [info] All done! ✨ 🍰 ✨
1 file left unchanged.
2024-02-06 10:09:49.855 [info] [Trace - 10:09:49 AM] Received response 'textDocument/formatting - (8)' in 52ms.
2024-02-06 10:09:49.913 [info] [Trace - 10:09:49 AM] Sending notification 'textDocument/didChange'.
Same here, I noticed that saving Jupyter notebooks became very slow as VS code was waiting for the black formatter to finish. It does format, but it takes a while as it's restarting the server process.
Te notebook I have has 2 cells and VS code is configured to format on save.
When I switch the black extension to the pre-release v2024.1.10371008
the extension works normally (it seems).
VS Code info:
Version: 1.86.0 (system setup)
Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
Date: 2024-01-31T10:28:19.990Z
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Windows_NT x64 10.0.14393
@mika457 try the pre-release version. This might also be related to https://github.com/psf/black/issues/4205 where black just ignores formatting some files.
@karthiknadig OK, thanks
I don't know why the latest version can not detect the conda env what I choose.
@GF-Huang You have not selected a python for your workspace. Please select one using Python: Select Interpreter
.
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.
After I updated Black formatter to v2024.0.0, whenever I save the notebook, a notification of "Saving xx.ipynb: formatting" will show up while the formatting will never be done. However, Black formatter v2023.6.0 still works well in terms of formatting on save.![Weixin Image_20240205133559](https://github.com/microsoft/vscode-black-formatter/assets/140952362/52291c25-41d5-477a-80ac-0fd28df691cb)