Skip to content

Notebook document identification relies on .ipynb extension rather than LSP notification type #22809

@manzt

Description

@manzt

Summary

The Ruff language server uses file extension checking (.ipynb) to identify notebook documents, while ty server relies solely on the LSP notification type (notebookDocument/didOpen vs textDocument/didOpen). This requires clients to apply workarounds when working with notebook-like files that don't have the .ipynb extension.

In https://github.com/astral-sh/ruff/blob/main/crates/ruff_server/src/session/index.rs#L130-L132, key_from_url determines document type by checking the file extension:

  } else if Path::new(url.path())
      .extension()
      .is_some_and(|ext| ext.eq_ignore_ascii_case("ipynb"))

Cell URIs are handled correctly (checked against notebook_cells map), but the notebook document itself requires the .ipynb extension.

In https://github.com/marimo-team/marimo, notebooks are .py files opened as notebook documents in a "managed" Ruff language server (that doesn't allow conflicts with .py text documents - see astral-sh/ruff-vscode#893). To make ruff server recognize these as notebooks, we need to transform notebook URIs to append .ipynb... but this can create other issues since the transformed path doesn't exist on disk.

This workaround is not needed for ty server since it doesn't check extensions. It would be nice to have the same (lack of) requirement and avoid special treatment of URIs.

Version

ruff 0.14.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions especially welcomenotebookRelated to (Jupyter) notebooksserverRelated to the LSP server

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions