-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
pydantic-settings reads first from env params, not from specified file. -> need to fix.
Also maybe toml instead of env?
Steps to Reproduce
Example:
import os
from pydantic_settings import BaseSettings, SettingsConfigDict
os.environ["S_THEORY"] = "Right"
with open(".env", "w") as f:
f.write("S_THEORY=Wrong")
class Config(BaseSettings):
model_config = SettingsConfigDict(env_file=".env")
s_theory: str
conf = Config()
print(f"Inside Pydantic: {conf.s_theory}") # Right
print(f"Inside OS Env: {os.getenv('S_THEORY')}") # Right
# Cleanup
os.remove(".env")
del os.environ["S_THEORY"]Expected Behavior
Should read from given file regardless what is in env
Component
Backend API
Environment
No response
Relevant Logs
Checklist
- I have searched existing issues to ensure this is not a duplicate
- I have included steps to reproduce the issue
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working