Settings with pydantic-settings

noun

say it: “SET-ingz with py-DAN-tik SET-ingz” /ˈsɛtɪŋz wɪð paɪˈdæntɪk ˈsɛtɪŋz/

Using the pydantic-settings package to load an app's configuration from environment variables or a .env file into a typed class that's checked at startup.

What is Settings with pydantic-settings?

pydantic-settings loads configuration from environment variables (and .env files) into a typed settings class.

class Settings(BaseSettings):
    database_url: str
    debug: bool = False

settings = Settings()  # reads DATABASE_URL and DEBUG

In a sentence

  • “With pydantic-settings, settings.debug is a real bool, not the text "false".”
  • “pydantic-settings refused to start the app when JWT_SECRET was missing.”

Level: Journeyman · More FastAPI terms at this level

Updated