-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pylance unable to resolve local import placed in the same directory #1167
Comments
This is a dupe of #68 or #253, and is working as it's currently designed (but we're working on it). It's expected to that extraPaths needs to be set (and globs aren't supported, #973). See: https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#unresolved-import-warnings But, if you could try out this WIP option, it may help your case:
I'm going to close this as a dupe of those other issues. |
@jakebailey One thing I want to add though is that some of my friends using VSCode take this as Pylance's bug and stopped using it and reverted to Jedi. I think #68 (comment) made an excellent point because even though Pylance fails to import the script, it runs without any problem in the importing script. Also, I tried |
Is your project available somewhere so we could test it? Or could you provide a tree listing of how the project is laid out so we can see how your case differs from others? That option is hidden, it's expected for it to be grayed out. |
@jakebailey Oops, uploaded the wrong screenshot. Changed it. |
Hm, can you give an example of an import that doesn't work? Is it as simple as |
Sure, here an example of only adding one directory to the Oops, there's a typo in the description.
|
Ah, you have |
Oh, I tried removing
To point out though, I only had Removing the whole |
Yes, you can't use both at the moment; we need to ensure that we don't apply this heuristic for non-user code, and extraPaths interferes with those checks (as they can reasonably point anywhere). |
I'm going to close this issue (as before) as things are working as intended, and other work will be in the scope of the other issues. |
I was getting similar issue when I imported bot3 it threw an error <Import "boto3" could not be resolvedPylance> I did try Ctrl+Shitf+` To reset my path directory. |
Environment data
Expected behaviour
Pylance imports .py files placed in the same directory and show code hints etc like Jedi.
Actual behaviour
Pylance fails to do so and gives:
Import "dataset" could not be resolved (Pylance report MissingImports)
The only way to resolve this (temporarily) is adding
to
settings.json
file but the problem is that I have to add every single nested directory like./code/baseline
. Glob pattern like./code/**
does not work at all.This is particularly annoying when you have many subfolders in your
code/
directory.For example:
If my main source code is running in
code/
, it is impossible to import any of the local .py files from baseline/, utils/, foo/, ...I have to manually add all of them one by one in
settings.json
.Is this a bug?
Logs
Code Snippet / Additional information
The text was updated successfully, but these errors were encountered: