Skip to content
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

import other python files in the same directory as the compiled file #749

Closed
Hakoyu opened this issue Dec 16, 2020 · 4 comments
Closed

import other python files in the same directory as the compiled file #749

Hakoyu opened this issue Dec 16, 2020 · 4 comments
Labels
waiting for user response Requires more information from user

Comments

@Hakoyu
Copy link

Hakoyu commented Dec 16, 2020

I have multiple python projects under my workspace.
They are in different subfolders.
I want to call files from the same directory in a subfolder.
But Pylance will only be defined to the workspace directory.
I can use "python.analysis.extraPaths" to add absolute paths, but it's a pain in the ass.
I would like to be able to customize the location of the directory.
For example, use "${fileDirname}" or "${workspaceFolder}", etc.

@jakebailey
Copy link
Member

extraPaths supports relative paths to the workspace. You can put in a path ./some/path, and the path will be rooted at the workspace. Does it not work for you?

@jakebailey jakebailey added the waiting for user response Requires more information from user label Dec 16, 2020
@github-actions github-actions bot removed the triage label Dec 16, 2020
@Hakoyu
Copy link
Author

Hakoyu commented Dec 17, 2020

extraPaths supports relative paths to the workspace. You can put in a path ./some/path, and the path will be rooted at the workspace. Does it not work for you?

I have multiple subfolders in my workspace folder, if I use this method I need to add many relative directories of folders.
The python compiler will automatically link to other files in the same directory as the compiled file, the project will compile normally, but using Pylance will prompt an error, and the auto-completion of other files will not work.

@jakebailey
Copy link
Member

Are you saying that you're trying to do an absolute import of the compiled code, or a relative one? If you import relatively, then there isn't a need for the import root. If you're doing absolute imports, you may be hitting #253 which impacts imports that scripts may do due to scripts having their own special import path behavior.

@jakebailey
Copy link
Member

This issue has been open with the "waiting for info" label for over a month, so I'm going to close it. If you can answer the questions above and it's not #253, I'm happy to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for user response Requires more information from user
Projects
None yet
Development

No branches or pull requests

2 participants