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
Environment names for complex types #2304
Comments
The issues #2232 (comment) and #1929 (comment) also touch on this. |
@daviskirk We certainly would be interested in this feature as well! |
+1 I also like the idea of using I think the JSON approach is counter-intuitive because you must set multiple variables via a single environment variable. |
* Environment names for complex types #2304 * nested env disabled by default * cleanup * nested env settings: simplified and mypy fixes * nested env settings: config, test, doc * nested env settings: changes file * nested env settings: cleanup * Apply suggestions from code review Co-authored-by: Samuel Colvin <samcolvin@gmail.com> * Apply suggested changes from code review * lint fix * changes from code review * simplify explosing env vars * linting Co-authored-by: Mark Trifonov <> Co-authored-by: Samuel Colvin <samcolvin@gmail.com> Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Parsing envs for nested field improved in FYI, pydantic-settings now is a separate package and is in alpha state. you can install it by Here is your example in pydantic-settings: from typing import Dict, Optional
from pydantic import BaseModel, Field
from pydantic_settings import BaseSettings
class Backend(BaseModel):
type: Optional[str] = None
dsn: Optional[str] = None
class Settings(BaseSettings):
backends: Dict[str, Backend] = Field(default_factory=dict) |
Checks
Feature Request
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:In order to manage these settings via envvars, nested components could be separated with
__
, like this:In order to remove
default
backend, following envvar could be set:Or list of dict keys could be given like this:
This would remove all backends, except
default
andsqlite
.I found similar issue about adding custom value parsers, so this could be used for lists and also for overriding keys.
The text was updated successfully, but these errors were encountered: