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

Autocompletion doesn't work (pipenv)

Open hodunov opened this issue 3 years ago • 2 comments

Environment data

  • Language Server version: 2022.8.20 (pyright 888eb243)
  • OS and version:Ubuntu 22.04 LTS on Windows 10 x86_64
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.9.13, pipenv, version 2022.6.7

Info

Hi! Thank you for your work, you're doing a great job. But to completely switch to VSCODE, I miss the prompts of the improts. I have this problem on both the latest Fedora and WSL, I have tried all the prompts I found on the internet and they have not solved my problem. Such as: https://github.com/microsoft/pylance-release/issues/673 https://stackoverflow.com/questions/50389852/visual-studio-code-intellisense-not-working https://dev.to/climentea/how-to-solve-pylance-missing-imports-in-vscode-359b

TL;DR:

Import works pretty bad, the same pyright in neovim handles all the problems that arise with pylance vscode. The project is big, some of the logs at the bottom are cut off, which are repeated and there is just an indexing of the project files.

Expected behavior

  1. Import hints from libraries in the environment (such as Django) should work as a quick fix.
  2. Improt model hints from nearby modules should work automatically as a quick fix

.vscode/settings.json:

{
    "python.pythonPath": "/home/hodunov/.local/share/virtualenvs/FleetCentre-kIcWcTIr/bin/python",
    "python.defaultInterpreterPath": "/home/hodunov/.local/share/virtualenvs/FleetCentre-kIcWcTIr/bin/python",
    "python.languageServer": "Pylance",
    "python.analysis.extraPaths": [
        "/home/hodunov/.local/share/virtualenvs/FleetCentre-kIcWcTIr/lib/python3.9/site-packages"
    ],
}

Actual behavior

  1. The import hint for libraries installed in Pipenv does not work at all, while the interpreter is installed correctly and go to defenition works flawlessly if the path is already spelt out for the library:

example: from django.db import models does not underline, go to defenition works. but if you remove the import, it won't show up when you hover over models. class MyAwesomeClass(models.Model):

  1. Just as bad work tips on imports from the project itself.

Either they do not see everything, or there are no import prompts until I open the file in which the class I need.

Logs

attached as a file, as they are large pylance-logs.txt

hodunov avatar Aug 13 '22 10:08 hodunov

for 1. By default we only index top level imports due to perf issues. to override and to go further into django you can customize indexing.

   ["", 1],     <-default library indexing
   ["django", 3],  <- 3 levels

ie.

    "python.analysis.packageIndexDepths":[
        ["", 1],     
        ["django", 3],
    ], 

bschnurr avatar Aug 15 '22 21:08 bschnurr

more info here. https://github.com/microsoft/pylance-release/issues/2991#issuecomment-1176560066

bschnurr avatar Aug 15 '22 21:08 bschnurr

Closing old issue. If this is still a problem, please reopen with the information requested. thanks

judej avatar Oct 13 '22 19:10 judej

@hodunov You might want to add this line to settings.json as well:

"python.analysis.autoImportCompletions": true 

(its default is false)

nguyenit67 avatar Nov 15 '22 04:11 nguyenit67