pylance-release
pylance-release copied to clipboard
Dictionary Intellisense only works with two sets of brackets in Jupyter Notebooks
Description
Intellisense seems to require a second set of brackets to autocomplete Python dictionary keys. The issue is only happening for me in Jupyter Notebooks. Autocomplete works as intended if editing a standard py
file.
Expected behaviour
The Intellisense autocomplete should kick in as soon as the opening bracket of a dictionary indexer is typed.
Actual behaviour
Autocomplete will only trigger when a second bracket is typed. This would, unfortunately, produce a TypeError
for passing a list to the indexer.
Environment data
VS Code
- Version: 1.64.2
- Commit: f80445acd5a3dadef24aa209168452a3d97cc326
- Electron: 13.5.2
- Chromium: 91.0.4472.164
- Node.js: 14.16.0
- V8: 9.1.269.39-electron.0
- OS: Darwin x64 21.1.0
Jupyter/Python
- Language Server: Pylance
- Jupyter Extension version: v2022.1.1201831736
- Python Extension version: v2022.0.1814523869
- OS and version: MacOSX 12.0.1
- Python and/or Anaconda version: 3.9.7
- Type of virtual environment used: conda
- Jupyter server running: Local
I believe this would be entirely handled by pylance?
When you type the first square bracket character (after the x
) do you see the following completion suggestions? Or are you seeing something different?
If the completion suggestion popup doesn't appear for you automatically after typing the square bracket, what happens if you manually trigger it to appear by pressing control-space?
A single square bracket does nothing and ctrl+space
only brings up the list of global variables.
This only occurs in notebooks, though. Python files work just like your screenshot. This is why I am unsure that it is Pylance. I assume I should expect the same behavior in both py
files and Jupiter notebooks if so.
Has there been any movement on this?
Commenting out the set of completionItem.textEdit
in _addStringLiteralToCompletions
causes the completions to appear. I'm not sure why or if that's the correct fix. Figured this out by comparing _addStringLiteralToCompletions
against _addNameToCompletions
which is the code path used in the double bracket part of the repro steps.
Hi, are there any updates?
Kind of the only thing needed for me to switch to VSCode completely...
@sharkweek @pukhov, looks like this works correctly after opting into the notebooks experiment that we shipped in Pylance 2022.5.3.
Give it a try:
- Use VS Code Insiders
- Install the latest Pre-Release builds of the Python and Jupyter extensions.
- Install latest Pylance build. Either stable or insiders, your choice.
- Set
"python.pylanceLspNotebooksEnabled": true
- Reload VS Code.
cc: @luabud
We're closing this issue since it is fixed when python.pylanceLspNotebooksEnabled
is set to true
and as of Python extension version 2022.14.0 that is now the default.
If you are setting python.pylanceLspNotebooksEnabled
to false
, we would like to understand why. Please file an issue.