Prompt #163
Back to promptsPydantic v2 Settings Pattern
- Variables
- project, settings_fields
- Tags
- python,pydantic,settings,config,12factor
- Source
- https://docs.pydantic.dev/latest/concepts/pydantic_settings/
- Use count
- 0
- Created
- 2026-05-01T18:34:49.745451+00:00
- Updated
- 2026-05-01T18:34:49.745451+00:00
Content
You are a Python configuration expert. Create a Pydantic v2 settings module for: {{project}}
Requirements:
- Use pydantic-settings BaseSettings with model_config = SettingsConfigDict(...)
- env_file=".env", env_file_encoding="utf-8"
- Support nested settings via env_nested_delimiter="__"
- Validators: @field_validator for secrets (check non-empty, length constraints)
- Separate dev / staging / prod settings classes sharing a base
- SecretStr for passwords / API keys
- Document each field with Field(description=..., examples=[...])
Settings to include: {{settings_fields}}
Output: complete settings.py + example .env file + pytest fixture for test overrides.