[ty] Support for notebooks in VS Code by MichaReiser · Pull Request #21175 · astral-sh/ruff (original) (raw)
added server
Related to the LSP server
Multi-file analysis & type inference
labels
MichaReiser changed the base branch from main to micha/lsp-fallible-range-conversion
Base automatically changed from micha/lsp-fallible-range-conversion to main
MichaReiser changed the base branch from main to micha/refactor-notebook-index
Base automatically changed from micha/refactor-notebook-index to main
Implement comprehensive notebook document support:
Refactor NotebookDocument to simplify cell management
- Remove embedded TextDocuments, defer to index
- Add to_ruff_notebook() for converting to linter format
Implement LSP notification handlers for notebook lifecycle:
- did_open_notebook: Open notebook and cell documents
- did_close_notebook: Close notebook and cell documents
- did_change_notebook: Handle cell structure and content changes
Update all LSP request handlers to use new conversion APIs:
- Navigation (goto definition, references, declaration, type def)
- Information (hover, completion, inlay hints, signature help)
- Symbols (document and workspace symbols)
- All handlers now use to_local_range()/to_location() appropriately
Add notebook diagnostics support:
- Per-cell diagnostic publishing
- Workspace diagnostics for notebooks
Update session and index management:
- Track notebook documents and their cells
- Map cell URIs to parent notebooks
- Handle notebook file changes
Extend system path handling for notebook URIs
Enable notebook capabilities in server initialization
Add comprehensive E2E tests for notebooks
This enables the LSP server to work with Jupyter notebooks by treating each cell as a separate text document while maintaining the notebook context for type checking and cross-cell references.
Discard changes to crates/ty_ide/src/importer.rs
Discard changes to crates/ty_server/src/server/api/requests/diagnostic.rs
Discard changes to crates/ty_server/src/server/api/semantic_tokens.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})