pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

lsp notebooks and jupyter.runStartupCommands

Open amotzop opened this issue 3 years ago • 1 comments

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

  1. Add the line jupyter.runStartupCommands: ["from json import loads"] to the settings.json file.
  2. Make sure lspNotebooks are enabled "python.pylanceLspNotebooksEnabled": true (removing the lspNotebooks fixes this problem).
  3. 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).

amotzop avatar Aug 19 '22 18:08 amotzop

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.

debonte avatar Aug 19 '22 19:08 debonte

Navigating to settings UI using vscode API: https://stackoverflow.com/questions/53584266/opening-vs-code-settings-window-from-extension-with-specific-search-query

debonte avatar Nov 23 '22 20:11 debonte

This issue has been fixed in prerelease version 2022.11.41, which we've just released. You can find the changelog here: CHANGELOG.md

rchiodo avatar Nov 30 '22 23:11 rchiodo