-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Feature Request
- OS: macOS
- Python version
import sys; print(sys.version): 3.6.8 (default, Jun 24 2019, 16:49:13) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] - Pydantic version
import pydantic; print(pydantic.VERSION): 1.0b2
Hello, great work on the library! I can't find the reason, why environment variables don't work in nested settings. I have a class
class Credentials(pydantic.BaseModel):
host: str
user: str
database: str
password: pydantic.SecretStr
class Settings(pydantic.BaseSettings):
db: Credentials
class Config:
env_prefix = 'APP_'and I want to specify password as an environment variable
export APP_DB='{"password": ""}'
but pass other fields in as values in code. Right now BaseSettings does simple top-level merging of dictionaries that doesn't consider nested values
def _build_values(self, init_kwargs: Dict[str, Any]) -> Dict[str, Any]:
return {**self._build_environ(), **init_kwargs}but dictionaries could be merged recursively, so users could provide values for any of their settings in environment variables.
What do you think, would it be useful?