-
Notifications
You must be signed in to change notification settings - Fork 56
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
notebook.source.organizeImports setting does not seem to work when imports are below markdown cell #593
Comments
Huh, that is indeed the case. I wonder if it's a bug in VS Code, let me check if the editor is sending the request in the first place. |
Hmm, VS Code isn't sending the code action request when a markdown cell is present. This is a bit worrying and could be related to the notebook selector filter here: https://github.com/astral-sh/ruff/blob/3e9c7adeeee639043686a1717a1683f6620efd2a/crates/ruff_server/src/server.rs#L335-L344 |
Let me look at this later today. Thanks for raising this issue! |
Thanks for taking a look so quickly! |
This might be related to microsoft/vscode#216653 |
@bolliger32 Thanks for mentioning |
I commented on the potentially related issue as well, but I'm experiencing the same issue; manually saving kicks off the importing, but doesn't actually organize the imports and instead creates gibberish. Important to note though, our setup uses the following, unlike the original poster: "notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"source.organizeImports": "explicit"
}, Unfortunately, the VSCode issue doesn't seemed to have gained any traction quite yet, but fingers crossed! |
It took me a little while, but I finally figured out the use of
notebook.source.fixAll
andnotebook.source.organizeImports
settings (instead of theirsource.*
counterparts) to prevent vscode from turning my import cells in jupyter notebooks into gibberish when using ruff as the formatter. However, it appears that when a notebook starts with a markdown cell (say, to title the notebook) and then has a python cell with imports after the markdown,notebook.source.organizeImports
doesn't work. Here are my relevant vscode settings:And here's the relevant part of my
pyproject.toml
file in the workspace open in vscode:I'm using ruff 0.6.2.
Side Note:
If I use
source.organizeImports
instead ofnotebook.source.organizeImports
, it "works" in the sense that something happens, but the effect is to introduce gibberish. Here's an example of the "gibberish" that occurs when usingsource.*
instead ofnotebook.source.*
. The first screenshot is from "pre-save", the second is after saving once, and the third after saving a second timeThe text was updated successfully, but these errors were encountered: