I'm trying out VSCode for Django development instead of PyCharm. I'm quite happy with the new configuration, but there's an issue which is driving me mad: VSCode fails to suggest only specific classes from django lib.
So far, I'm able to get import suggestions like this:
and selecting the class will import it correctly.
But, if I try with ListView
or LoginRequiredMixin
, this happens:
where django_tables2.views
and hijack.views
are third party libraries.
If I search for additional import matches, the two classes are not found
This is my VSCode workspace configuration:
{
"python.testing.pytestArgs": [
"."
],
"python.testing.unittestEnabled": false,
"python.languageServer": "Pylance",
"python.testing.pytestEnabled": true,
"python.analysis.autoFormatStrings": true,
"python.analysis.autoSearchPaths": false,
"python.analysis.autoImportCompletions": true,
"python.analysis.inlayHints.callArgumentNames": "off",
"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.userFileIndexingLimit": -1,
"python.analysis.indexing": true,
"python.analysis.stubPath": "",
"python.analysis.inlayHints.variableTypes": true,
"python.analysis.typeCheckingMode": "off",
"python.autoComplete.addBrackets": true,
"python.analysis.completeFunctionParens": true,
"python.analysis.packageIndexDepths": [
{
"name": "",
"depth": 10,
"includeAllSymbols": true
},
],
"python.experiments.enabled": false,
}
Is this a bug or something?
I found many issues on the Pylance repository, but in my case the files are correctly indexed (I can find UpdateView
and other django classes).
I also tried to uninstall the 3rd party libraries except for Django, but the LoginRequiredMixin
and CreateView
are not found anyway.
I have Microsoft official extensions only, everything else is disabled.
At the end, the problem was related to the "includeAllSymbols": true
, which blindly import everything from everywhere.
Changing it to false
solved the issue.
Relevant GitHub issue here