Open besil opened 1 month ago
Related SO question opened by me
can you run clear all persisted indices
command and reload window
and see whether that fixed the issue? oh, and don't forget to wait until initial indexing is done. you can see it from output - python language server
I tried, but issue persists
I think what is happening is when we dedup import symbols, we think one from third party is better since it has shorter import path. without those third party lib installed, I get what you want.
https://github.com/user-attachments/assets/94fc5345-6154-4c2f-913d-91785518fb84
let's improve our logic so, we only dedup between different packages within stdlib
I think the root issue is this setting that basically says just blindly include all symbols to the indices
, rather you could configure it to be more specific
"python.analysis.packageIndexDepths": [
{
"name": "",
"depth": 10,
"includeAllSymbols": true
},
],
for example, if you add
{
"name": "django_tables2",
"depth": 10,
"includeAllSymbols": false
},
ListView
in django_tables2
won't be picked up. same for the hijack
. basically that includeAllSymbols: true
cause all imported symbols from other packages
are included as well.
...
that said, I think we can improve user experience on this.
Thank you @heejaechang
Changing my settings.json from
...
"python.analysis.packageIndexDepths": [
{
"name": "",
"depth": 10,
"includeAllSymbols": true
}
],
...
to
...
"python.analysis.packageIndexDepths": [
{
"name": "",
"depth": 10,
"includeAllSymbols": false
}
],
...
removed any 3rd party duplicated import and correctly references the right library.
Hi guys, thank you for your work on Pylance.
I'm trying VSCode for Python development to move away from PyCharm, but I'm having a strange issue and I don't know if it's a bug or not.
So far, I'm able to get import suggestions like this:
and selecting the class will import it correctly.
But, if I try with other django core views, such as
ListView
orLoginRequiredMixin
, this happens:where
django_tables2.views
andhijack.views
are third party libraries, which import themselves thedjango.views.generic.ListView
class.As you can imagine,
ListView
andUpdateView
are in the same Django package (django.views.generic
). They are in 2 different python files (update.py
andlist.py
respectively), but they are both exported in__init__.py
at package level.I already customized
python.analysis.packageIndexDepths
as suggested in other issues, but it's quite strange to me that UpdateView is resolved and ListView not. I can successfully import other classes in the samedjango.views.generic.list.py
file, as expected.Is this a bug or I'm just missing something very basic?
Please find my full settings.json: