Registry / serialization / pydantic-settings-yaml

pydantic-settings-yaml

JSON →
library0.2.0pypypi✓ verified 85d ago

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.

pip install pydantic-settings-yaml
INSTALL
IMPORT
SIG · PYDANTIC-SETTINGS-
P
pydantic-settings-yaml
serializationpythonv0.2.0
Install
3.6s avg
Import
Disk
29MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 30.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.6s · import 0.000s · 31MB
29MB installed
● package 29MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

YamlBaseSettings
from pydantic_settings_yaml import YamlBaseSettings
from pydantic_settings_yaml import YamlConfigSettingsSource
base_settings
from pydantic_settings_yaml import base_settings

Define a Pydantic model with a YAML configuration source. The YAML file 'config.yaml' can contain keys like `app_name` and `debug`.

from pydantic_settings import BaseSettings, SettingsConfigDict from pydantic_settings_yaml import YamlConfigSettingsSource class Settings(BaseSettings): model_config = SettingsConfigDict(yaml_file='config.yaml') app_name: str = "MyApp" debug: bool = False settings = Settings() print(settings.app_name) print(settings.debug)
Debug
Known issues
breakingIn version 0.2.0, the class was renamed from YamlSettingsSource to YamlConfigSettingsSource. Existing code using the old name will break.
fix
Update imports: from pydantic_settings_yaml import YamlConfigSettingsSource
affects: <0.2.0 -> >=0.2.0
gotchaThe YAML file is loaded only during initialization. If the file changes later, the settings are not refreshed automatically.
fix
Call Settings() again or implement a reload mechanism.
affects: all
gotchaSettings are case-sensitive. YAML keys must exactly match the model field names.
fix
Ensure field names in model and YAML keys match exactly.
affects: all
Upgrade
Version history
0.2.0latest on PyPI · released Jul 20, 2023
Audit
Dependencies
pydantic-settingsrequiredCore library for settings management; pydantic-settings-yaml extends it.
pyyamlrequiredRequired for YAML parsing.
Agent activity
4 hits · last 30 days
node
4
Resources
pydantic-settings-yaml — pip install pydantic-settings-yaml · libregistry