Import resolution in notebooks
Description
I have been using basedpyright in vscode and vscodium and I have noticed that it does not correctly resolve import statements in jupyter notebooks with conda environments. If I use a .py file instead, this works perfectly with the same interpreter selected. Am I missing something obvious here?
are you able to provide a minimal example? are you trying to import from other notebooks? from my understanding doing that isn't possible (but i have no experience with notebooks so i may be wrong?)
Weirdly it just started working after I left vscode alone for 5 minutes. However, there are issues with numpy functions on hover
what's the issue? i can't tell from that screenshot. i tested it and the hover text is the same in regular .py files
Maybe that is a separate issue, but in my case the issue is that cross-cell import / usage doesn't resolve at all. Mind you that it's a remote - SSH connection and the jupyter kernel is not ran by vscode (I connect to it through a localhost link), so it might not actually have the needed info (e.g. venv paths) for this. Though I believe it's not an issue since it doesn't say "couldn't resolve"
Any help would be appreciated :)
can you check the log by selecting "basedpyright" in the output tab and see if there are any errors?
i'm not sure how remote SSH dev environments work in vscode but i suspect it probably works similar to live share,see https://github.com/DetachHead/basedpyright/issues/939#issuecomment-2526971160
I too am gettign this issue in notebook. there are no errors in the output. it works in normal python files
It looks like you haven't imported BaseModel from pydantic, so it looks like that error is correct
Or is it imported in a separate cell? Could you provide a minimal repro or the full notebook file so I can investigate
in the above case with pylance, i get a option that allows me to quick fix => import pydantic
this isn't the case with basedpyright in notebooks.
i will attempt to make a repo later this week
what version of basedpyright are you using? there was an issue with code actions in notebooks that was fixed in 1.30.1 (#1384)
I am using basedpyright = 1.31.0
Hmm, yeah I'll need a minimal repro to investigate
@DetachHead i was mistaken, it was not running the environment version, it is fixed in 1.31
closing this since there's not enough info about the original issue from OP. @Hyperthetical happy to reopen if you provide more details