DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
https://docs.basedpyright.com
Other
1.07k stars 20 forks source link

vscode plugin not finding local imports in some cases #772

Open jorenham opened 3 days ago

jorenham commented 3 days ago

image_2024-10-14_05-32-23

This screenshot is from scipy-stubs, specifically in scipy-stubs/sparse/csgraph/_validation.pyi (the relevant code isn't pushed yet, but will be soon).

So here the basedpyright suggested to import sparray from scipy.sparse._base, which I accepted because it was the only available option. But in the screenshot you can see that it wasn't able to find spmatrix, even though it also is available in (at least) scipy.sparse._base.

Within scipy.sparse._base.__all__, only sparray is explicitly exported, and spmatrix is implicitly exported through from {} import spmatrix as spmatrix (blame scipy).

But the strange thing is that both spmatrix and sparray are both explicitly exported at the package level, i.e. through scipy.sparse.__init__.__all__. However, in both cases, the basedpyright plugin wasn't able to suggest this 🤔.

jorenham commented 3 days ago

the relevant code: https://github.com/jorenham/scipy-stubs/blob/d24baa3be2a311fdf85ca1be13eb5ed9420202ba/scipy-stubs/sparse/csgraph/_validation.pyi

DetachHead commented 3 days ago

looks like the only difference between sparray and spmatrix is that spmatrix is an explicit re-export (from ._matrix import spmatrix as spmatrix), maybe there's an issue with import suggestions with re-exports?

does the same thing happen with completions?

jorenham commented 3 days ago

maybe there's an issue with import suggestions with re-exports

Yea, I suppose that makes sense. Especially because sparray is actually defined in scipy.sparse._base, whereas spmatrix isn't.

does the same thing happen with completions?

Yea I believe so, but it's hard to tell because I'm also using codeium as an AI autocomplete assistant thingy