{"id":21744,"library":"pydantic-settings-yaml","title":"Pydantic Settings YAML","description":"Adds YAML support to pydantic-settings, enabling loading settings from YAML files via the BaseSettings model. Currently at version 0.2.0, requires Python >=3.8. Released irregularly as a small utility package.","status":"active","version":"0.2.0","language":"python","source_language":"en","source_url":"https://github.com/nicholasio/pydantic-settings-yaml","tags":["pydantic","settings","yaml","configuration"],"install":[{"cmd":"pip install pydantic-settings-yaml","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core library for settings management; pydantic-settings-yaml extends it.","package":"pydantic-settings","optional":false},{"reason":"Required for YAML parsing.","package":"pyyaml","optional":false}],"imports":[{"note":"Old name before 0.2.0 was 'YamlSettingsSource'; renamed to 'YamlConfigSettingsSource' in 0.2.0.","wrong":"from pydantic_settings_yaml import YamlSettingsSource","symbol":"YamlConfigSettingsSource","correct":"from pydantic_settings_yaml import YamlConfigSettingsSource"}],"quickstart":{"code":"from pydantic_settings import BaseSettings, SettingsConfigDict\nfrom pydantic_settings_yaml import YamlConfigSettingsSource\n\nclass Settings(BaseSettings):\n    model_config = SettingsConfigDict(yaml_file='config.yaml')\n\n    app_name: str = \"MyApp\"\n    debug: bool = False\n\nsettings = Settings()\nprint(settings.app_name)\nprint(settings.debug)","lang":"python","description":"Define a Pydantic model with a YAML configuration source. The YAML file 'config.yaml' can contain keys like `app_name` and `debug`."},"warnings":[{"fix":"Update imports: from pydantic_settings_yaml import YamlConfigSettingsSource","message":"In version 0.2.0, the class was renamed from YamlSettingsSource to YamlConfigSettingsSource. Existing code using the old name will break.","severity":"breaking","affected_versions":"<0.2.0 -> >=0.2.0"},{"fix":"Call Settings() again or implement a reload mechanism.","message":"The YAML file is loaded only during initialization. If the file changes later, the settings are not refreshed automatically.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure field names in model and YAML keys match exactly.","message":"Settings are case-sensitive. YAML keys must exactly match the model field names.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use: from pydantic_settings_yaml import YamlConfigSettingsSource","cause":"The class was renamed to YamlConfigSettingsSource in v0.2.0.","error":"ImportError: cannot import name 'YamlSettingsSource' from 'pydantic_settings_yaml'"},{"fix":"Ensure YamlConfigSettingsSource is imported and passed to settings_customise_sources if needed.","cause":"The custom settings source is not correctly registered or imported.","error":"pydantic_settings.sources.SettingsError: Unknown settings source type: <class '...'>"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}