Add Jupyter notebook cell support via LSP 3.17 Notebook Document Sync#473
Draft
Add Jupyter notebook cell support via LSP 3.17 Notebook Document Sync#473
Conversation
- Add NOTEBOOK_SYNC_OPTIONS and notebook_document_sync to LanguageServer - Add _get_document_path helper for resolving notebook cell URIs - Add notebook lifecycle handlers (didOpen, didChange, didSave, didClose) - Remove notebook-cell skip guard in _linting_helper - Add onNotebook:jupyter-notebook and onNotebook:interactive activation events Closes #86 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add NOTEBOOK_DOCUMENT_DID_* event constants and notebook-related type classes (NotebookDocumentSyncOptions, NotebookCellLanguage, etc.) to the lsprotocol.types mock so lsp_server.py can be imported in unit tests. Also update _MockLS to use Pygls 2.0 method names. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add test_notebook.py with 5 tests covering notebook lifecycle events (didOpen, didChange, didSave, didClose, cell kind filter). Add notify_notebook_did_* helpers to session.py test client. Add sample.ipynb test data fixture. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The repos use defaults.vscode_initialize_defaults() (a function), not defaults.VSCODE_DEFAULT_INITIALIZE (a constant). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Drain didOpen diagnostics before registering the close callback to avoid capturing stale open-diagnostics instead of the expected empty close-diagnostics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Skip cells with languageId != 'python' in structure.did_open to avoid running the linter on markdown or other non-Python cells. Also clear diagnostics on exception in mypy's _linting_helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds notebook (.ipynb) and Interactive Window support via LSP 3.17 Notebook Document Sync. Follows upstream template PR microsoft/vscode-python-tools-extension-template#265.
Changes:
NOTEBOOK_SYNC_OPTIONS,_get_document_path(), 4 notebook handlers (didOpen/Change/Save/Close), non-Python cell filter,_clear_diagnosticson exception, activation events, test infrastructure (test_notebook.py, session helpers, sample.ipynb, mock fixes).Closes #86
Closes #474
Manual Test Plan (use
notebook-support-infrabranch + Jupyter extension):package.jsonactivationEventsx: int = "hello"lsp_server.py:226notebook_did_open — checknb.cellsiterationx: int = 42, break →def f() -> int: return "a"lsp_server.py:241notebook_did_change — checktext_contentlooplsp_server.py:266notebook_did_save — check all cells re-lintedlsp_server.py:281notebook_did_close — check empty diagnostics publishedlsp_server.py:309_linting_helper — check publish per celllsp_server.py:253— checklanguage_id != "python"skiplsp_server.py:107_get_document_path — check URI resolutionx: int = "hello"in Interactivex = 1, 20+ cellslsp_server.py:390— check _clear_diagnostics in except block