Skip to content

formatOnSave not working on notebook #571

@JordanHeintz

Description

@JordanHeintz

Description

As far as I can tell, I have applied the necessary configuration to use Ruff to format notebooks on save, but it just will not do anything. It does work on regular python files just fine.

Environment

Windows 10
Python: 3.12.4
VSCode Ruff Extension: v2024.36.0 (includes ruff 0.5.4)

I have the following in my settings.json:

{
    "notebook.formatOnSave.enabled": true,
    "notebook.defaultFormatter": "charliermarsh.ruff",
    "notebook.codeActionsOnSave": {
        "notebook.source.fixAll": "explicit",
        "notebook.source.organizeImports": "explicit",
    },
    "[python]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "charliermarsh.ruff",
        "editor.codeActionsOnSave": {
            "source.fixAll": "explicit",
            "source.organizeImports": "explicit",
        }
    },
}

I added a ruff.toml file to my workspace with the following setting:

[tool.ruff]
extend-include = ["*.ipynb"]

IIUC, the extension should find that file automatically, but I also tried specifying a path to ruff.toml in the extension settings, with no effect.

Expected Results

I expected Ruff to format my .ipynb files on save the same it does my .py files.

Actual Results

Nothing. VSCode Output shows the extension loading, resolving ruff.nativeServer: auto to use the native server, and a request to start the server, with no indications that any errors occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions