Mรณdulo 11 ยท Routers & Dependency Injection โ Lecciรณn 3 de 4 ยท ~6 min
Typed settings
Configuration is just another Pydantic model
Every app needs configuration: a database URL, a JWT signing secret, feature flags. The tempting Python way is scattered os.getenv("SOME_VAR") calls all over the codebase โ no validation, no defaults in one place, and a typo in the env var name fails silently at 2am. pydantic-settings fixes this the same way Pydantic fixed request bodies in module 23: define a model, and loading becomes validation.
app/config.py defines one Settings class. Fields with a default (like app_name) are optional; a field with NO default, like jwt_secret, means the app refuses to start unless it's actually set โ a real deployment can't silently boot without a signing key.