我在VSCode中有一个Python项目。它的结构
root
+-- docs
+-- some_other_folder
+-- src
+-- app
| +-- main.py
+-- tests
+-- conftest.py conftest.py具有导入
from app.main import app我的任务是将src设置为根文件夹,因为在否则我会收到一个警告Import 'app.main' could not be resolved
发布于 2020-06-16 16:58:18
在项目的根目录下创建pyrightconfig.json
添加以下配置:
{
"executionEnvironments": [
{"root": "src"}
]
}详情摘自:https://github.com/Microsoft/pyright/blob/master/docs/configuration.md
https://stackoverflow.com/questions/60820640
复制相似问题