Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletion doesn't work (pipenv) #3193

Closed
hodunov opened this issue Aug 13, 2022 · 4 comments
Closed

Autocompletion doesn't work (pipenv) #3193

hodunov opened this issue Aug 13, 2022 · 4 comments
Assignees
Labels
needs investigation Could be an issue - needs investigation

Comments

@hodunov
Copy link

hodunov commented Aug 13, 2022

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:
#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

@judej judej added the needs investigation Could be an issue - needs investigation label Aug 15, 2022
@bschnurr
Copy link
Member

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
Copy link
Member

more info here. #2991 (comment)

@judej
Copy link
Contributor

judej commented Oct 13, 2022

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

@judej judej closed this as completed Oct 13, 2022
@nguyenit67
Copy link

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

"python.analysis.autoImportCompletions": true 

(its default is false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation Could be an issue - needs investigation
Projects
None yet
Development

No branches or pull requests

4 participants