【发布时间】:2022-08-16 23:54:44
【问题描述】:
我有两个名为 .env 和 .test.env 的 .env 文件
我正在使用 env_file = \".test.env\" 加载我的 pydantic 设置,如下所示:
from pydantic import BaseSettings
class Settings(BaseSettings):
A: int
class Config:
env_file = \".test.env\"
env_file_encoding = \"utf-8\"
settings = Settings()
当我从终端运行脚本时,这很好用:
uvicorn run:app
但是,当我使用 VScode 调试或测试时,它会覆盖设置的 env 值.test.env值来自.env
我的启动.json:
{
\"version\": \"0.2.0\",
\"configurations\": [
{
\"name\": \"Python: Module\",
\"type\": \"python\",
\"request\": \"launch\",
\"module\": \"uvicorn\",
\"args\": [
\"run:app\",
\"--reload\"
],
\"justMyCode\": true
}
]
}
如何阻止 VScode 导出.env文件?
标签: python visual-studio-code pydantic