microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.25k stars 275 forks source link

Intellisense not working with jupyter extension #15702

Open tmchartrand opened 1 month ago

tmchartrand commented 1 month ago

Applies To

What happened?

With a new python environment, created a new notebook and interactive window with a single import statement (import os). Intellisense does not work on this import (either hover hint or go to def). This is true for both Jedi and Pylance language server. Pylance does give an error in the log:

2024-05-21 10:07:22.134 [info] a [Error]: Request workspace/configuration failed with message: Cannot read properties of undefined (reading 'metadata')
    at /Users/tom.chartrand/.vscode/extensions/ms-python.vscode-pylance-2024.3.2/dist/vendor.bundle.js:2:1268722
    at oe (/Users/tom.chartrand/.vscode/extensions/ms-python.vscode-pylance-2024.3.2/dist/vendor.bundle.js:2:1269016)
    at /Users/tom.chartrand/.vscode/extensions/ms-python.vscode-pylance-2024.3.2/dist/vendor.bundle.js:2:1263775
    at Immediate.<anonymous> (/Users/tom.chartrand/.vscode/extensions/ms-python.vscode-pylance-2024.3.2/dist/vendor.bundle.js:2:1263795)
    at processImmediate (node:internal/timers:476:21) {
  code: -32603,
  data: undefined
}

Intellisense comes back in these windows if the jupyter extension is disabled. In some cases Pylance does work inconsistently, seemingly dependent on what is open when the window is reloaded (if only preferences are focused, I get no error and intellisense works, but not sure how consistent this is), but Jedi seems consistently blocked.

VS Code Version

1.89.1

Jupyter Extension Version

v2024.4.2024042601 (pre-release)

Jupyter logs

Visual Studio Code (1.89.1, undefined, desktop)
Jupyter Extension Version: 2024.4.2024042601.
Python Extension Version: 2024.6.0.
Pylance Extension Version: 2024.3.2.
Platform: darwin (arm64).
No workspace folder opened.
10:07:22.142 [info] Process Execution: ~/micromamba/bin/python -m pip list

Coding Language and Runtime Version

No response

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

amunger commented 1 month ago

Jedi doesn't currently support notebook models, so that's not expected to provide intellisense since IW is backed by a notebook.

Are you executing the import statement in the interactive window? Pylance doesn't provide intellisense until the first cell is executed (known issue)

tmchartrand commented 1 month ago

@amunger yes the behavior is no different for me before or after execution of a cell (in either notebook or interactive window). When checking this though, I did realize that the effect of the jupyter extension enabled vs not is also inconsistent, modified the original post to reflect this. The presence of the error log noted does seem to be consistently linked to the bug as far as I can tell, although only on the pylance side not jedi.

I'm confused by your comment on Jedi though, since it is working just fine for me in an older version (code 1.85.2, python 2024.2.1, jupyter 2023.9.100. Are you referring to features that use the active kernel vs just static analysis (eg jupyter.enableExtendedKernelCompletions)?

As a side note, it would be great if the respective notebook support for pylance and jedi was better documented in general!

amunger commented 1 month ago

@DonJayamanne Cannot read properties of undefined (reading 'metadata') sounds like it may be trying to access metadata through the custom field, is there a setting/experiment to toggle to verify that?

DonJayamanne commented 1 month ago

@bschnurr @heejaechang Please can you have a look at this. Last iteration we changed the way metadata is stored in the notebook, its no longer nested under metadata.metadata.

tmchartrand commented 1 month ago

After doing some coarse search of older versions, it seems like this issue was introduced with the 2023.11 version of the extension.

From: Don Jayamanne @.> Date: Tuesday, May 21, 2024 at 9:03 PM To: microsoft/vscode-jupyter @.> Cc: Tom Chartrand @.>, Author @.> Subject: Re: [microsoft/vscode-jupyter] Intellisense not working with jupyter extension (Issue #15702)

@bschnurrhttps://github.com/bschnurr @heejaechanghttps://github.com/heejaechang Please can you have a look at this. Last iteration we changed the way metadata is stored in the notebook, its no longer nested under metadata.metadata.

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/vscode-jupyter/issues/15702#issuecomment-2123824342, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADB2IIFMPV32Y7HI65BUWXLZDQKINAVCNFSM6AAAAABICA2OD6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRTHAZDIMZUGI. You are receiving this because you authored the thread.Message ID: @.***>