lsp notebooks and jupyter.runStartupCommands
Environment data
- Language Server version: 2022.8.30
- OS and version: Ubunto 20.04
- Python version (& distribution if applicable, e.g. Anaconda): 3.9
Code Snippet
loads("{1: 2}")
Repro Steps
- Add the line
jupyter.runStartupCommands: ["from json import loads"]to thesettings.jsonfile. - Make sure lspNotebooks are enabled
"python.pylanceLspNotebooksEnabled": true(removing the lspNotebooks fixes this problem). - Open a notebook containing a cell with the above code.
Expected behavior
Pylance should recognise the loads function (for example add semantic coloring).
Actual behavior
Pylance doesn't recognise the loads function (and even adds a warning for the basic analysis level).
When Jupyter starts Pylance, this is handled by NotebookMiddlewareAddon (by passing the commands directly to the NotebookConverter) or PylanceMiddlewareAddon (by passing the commands to Pylance as the python.notebookHeader setting).
But Jupyter doesn't start Pylance when LSP notebooks are enabled.
We should be able to support this. Need to think about the cleanest way to add it do the cell document chain though.
Navigating to settings UI using vscode API: https://stackoverflow.com/questions/53584266/opening-vs-code-settings-window-from-extension-with-specific-search-query
This issue has been fixed in prerelease version 2022.11.41, which we've just released. You can find the changelog here: CHANGELOG.md