I am currently able to use quick fix to auto import python functions from external typings such as from typing import List
.
Python module quick fix import
However, I am unable to detect local functions/classes for import. For example: If I have the data class SampleDataClass
in dataclasses.py
, and I reference it in a function in test_file.py
, VSCode is unable to detect it and I have to manually type out the import path for the dataclass.
I have the following extensions enabled:
- Python
- Pylance
- Intellicode
My settings.json includes:
{
"python.envFile": "${workspaceFolder}/.env",
"python.languageServer": "Pylance",
"python.analysis.indexing": true,
"python.formatting.provider": "black",
"python.analysis.autoImportCompletions": true,
"python.analysis.autoSearchPaths": true,
"python.autoComplete.extraPaths": ["~/Development/<django repo name>/server"],
"python.analysis.extraPaths": ["~/Development/<django repo name>/server"],
"vsintellicode.features.python.deepLearning": "enabled",
}
I am using poetry for my virtual environment which is located at ~/Development/<django repo name>/.venv
Is there something that I’m missing?
2
Answers
Turns out the latest versions for Pylance broke quick-fix imports and any extra path settings for VSCode. When I rolled back the version to
v2022.8.50
it now works again.I filed an issue here: https://github.com/microsoft/pylance-release/issues/3353.
According to an issue I raised in github earlier, the developer gave a reply.
Custom code will not be added to the autocomplete list at this time (unless it has already been imported). This is done to prevent users from having too many custom modules, which may lead to too long loading time.
If necessary, you can start a discussion in github and vote for it.
Add: