-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Can't resolve relative imports #124
Comments
Can you provide more repro steps? What other files or subdirectories are present in the same directory as this file? |
After some digging, they are not the problems as #58 and #59. These problems only happen when there's Minimal test case: main.py: if __name__ == "__main__":
pass
class some_class:
pass
def some_func():
pass
from . import some_class
from .module1 import some_func
some_obj = some_class()
some_func()
{
"venvPath": "C:/Dev/BasicTools/python/miniconda3/envs",
"venv": "datascience"
} |
Thanks for the details, but I'm still not able to repro what you're seeing. There must be something else I'm missing. Could you open the Output window and look at the Pyright output? There should be some additional information provided there. Look for something like "Attempting to resolve relative import". I'm interested in the lines that follow. Thanks! |
OK. Pyright output:
|
OK, thanks. It looks like it's a Windows-specific path issue. That explains why I wasn't seeing it, since my main development machine is a Mac. I'll switch over to a Windows machine and try to repro it there. |
Found the problem. As I suspected, it had to do with processing Windows-specific file paths with the old DOS-style drive letter at the start. I've switched to a standard library for doing the parsing in a cross-platform way. This should be fixed in the next version of pyright. Thanks again for reporting the bug! |
This should now be fixed in version 1.0.28, which I just published. Thanks for reporting the issue! |
d4c0c0c made LS to automatically add "src" as one of extra path to find imports. (microsoft#552) git-subtree-dir: server/pyright git-subtree-split: d4c0c0c
Pyright can't resolve relative imports as below correctly.
They look like the same problems as #58 and #59, maybe there're some regressions.
Pyright 1.0.27 with VS Code 1.33.1 and Python 3.7 virtual environment.
The text was updated successfully, but these errors were encountered: