Overview

Pydantic Settings 2.1, released on December 15, 2023, adds native YAML file support as a configuration source.

Main Features

The new YamlConfigSettingsSource lets you load configuration from a YAML file with Pydantic validation.

python
from pydantic_settings import BaseSettings

class Config(BaseSettings):
    db_host: str = 'localhost'
    db_port: int = 5432

    model_config = {'yaml_file': 'config.yaml'}

Sources