You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that when trying to enable ruff formatting in Jupyter notebooks with import sorting enabled as well, the Ruff native server doesn't correctly format the cells, leading to garbled imports and sometimes completely missing lines of code.
When I change "ruff.nativeServer": true to "ruff.nativeServer": false to disable the native server, format on save works correctly without any problem.
Note: the code doesn't have to be the same in both cells, and it doesn't have to just be 2 cells in the notebook, but this is a minimal example I've found where the issue happens. The issue doesn't seem to happen when there is just 1 cell in the notebook.
I noticed that when trying to enable ruff formatting in Jupyter notebooks with import sorting enabled as well, the Ruff native server doesn't correctly format the cells, leading to garbled imports and sometimes completely missing lines of code.
When I change
"ruff.nativeServer": trueto"ruff.nativeServer": falseto disable the native server, format on save works correctly without any problem.ruff.toml:.vscode/settings.json{ "editor.formatOnSave": true, "[python]": { "editor.defaultFormatter": "charliermarsh.ruff", "editor.codeActionsOnSave": { "source.organizeImports": "explicit" } }, "ruff.nativeServer": true, "notebook.formatOnSave.enabled": true, "notebook.codeActionsOnSave": { "source.organizeImports": "explicit" }, "notebook.defaultFormatter": "charliermarsh.ruff", "ruff.trace.server": "verbose" }Environment details:
Extension version:
v2024.54.0Extension uses Ruff version:
0.7.1VS Code version:
1.95.1OS: MacOS Sequoia
15.1Python Version:
3.12.7Code sample:
A new blank notebook with this example code in 2 cells:
Note: the code doesn't have to be the same in both cells, and it doesn't have to just be 2 cells in the notebook, but this is a minimal example I've found where the issue happens. The issue doesn't seem to happen when there is just 1 cell in the notebook.
Raw json contents of notebook:
```json { "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from typing import Optional\n", "from typing import Literal\n", "from typing import TypedDict\n", "\n", "# Comment\n", "Test = Literal[\"test\"]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from typing import Optional\n", "from typing import Literal\n", "from typing import TypedDict\n", "\n", "# Comment\n", "Test = Literal[\"test\"]" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 2 } ```Extension logs: https://pastebin.com/pvXc9HZY
Video (with native server enabled):
Screen.Recording.2024-11-07.at.10.08.45.mov
Video (with native server disabled):
Screen.Recording.2024-11-07.at.10.10.51.mov
If you need any more information or need to clarify anything else with me please let me know, thanks.