-
Notifications
You must be signed in to change notification settings - Fork 57
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 (notebook.*
) code actions does not work when first cell is markdown
#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! |
@Riezebos Does your issue gets resolved when using @matt-dies-tenet3 Can you try doing the same? Use |
@dhruvmanila yes, using |
Has the VS code extension access to the For anyone running into this. You can help that microsoft/vscode#216653 gains traction by upvoting it (please no |
Yes, it should. Although I want to look into why |
Using the following also works consistently! "notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.organizeImports.ruff": "explicit"
}, |
Oh wow, I just found out this:
which is basically what is happening here. |
cc @Yoyokrazy, apologies for the ping but if possible could you clarify if this was discussed further as I couldn't find any related issues. We're facing this issue here as we do select only Python code cells during initialization: |
It recently stopped working in jupyter notebook... Even when manually triggered by command, it still says no available imports organizer found. In the meanwhile, the formatting/linting features of ruff work well as normal in jupyter. And in regular python files, the imports organizer could be found. Has anyone else also run into the same issue? |
notebook.*
) code actions does not work when first cell is markdown
IIUC, this seems unrelated to what's being discussed here. Do you mind opening a new issue with all the details (refer to troubleshooting guide). |
I might try changing the notebook selector to include markdown cells on syncing, I think the server should be able to handle it. |
Nope, this doesn't seem to work either. I've tried the following "notebookDocumentSync": {
"notebookSelector": [
{
"cells": [
{
"language": "python"
},
{
"language": "markdown"
}
],
"notebook": {
"notebook_type": "jupyter-notebook"
}
}
],
"save": false
}, "notebookDocumentSync": {
"notebookSelector": [
{
"cells": [
{
"language": "python"
},
{
"language": "markdown"
}
]
}
],
"save": false
}, "notebookDocumentSync": {
"notebookSelector": [
{
"cells": [
{
"language": "*"
}
]
}
],
"save": false
}, |
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: