Yaml support for Pydantic settings
Project description
pydantic-settings-yaml
Yaml support for Pydantic settings. Load a yaml config file as nested Pydantic models.
Allows to use file:xxxx placeholders in the yaml config file for secrets. A placeholder is replaced with the contents of the file. Paths are relative to the 'secrets_dir' setting (see below).
Usage
$cat /config/config.yaml
database:
password: <file:database_password>
username: my_database_username
$cat /secrets/database_password
my_secret_database_password
Python code example:
from pydantic import BaseModel
from pydantic_settings_yaml import YamlBaseSettings
class Database(BaseModel):
username: str
password: str
class Settings(YamlBaseSettings):
database: Database
class Config:
secrets_dir = "/secrets"
yaml_file = "/config/config.yaml"
settings = Settings()
assert settings.dict() == {
"database": {
"password": "my_secret_database_password",
"username": "my_database_username"
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for pydantic_settings_yaml-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24b6a9e269c973c07ad1a9db187cf4047fde32aec05b26e39ad3e2ec7142f040 |
|
MD5 | 0bdd99dba5b9306e3a026b03ceeb9b75 |
|
BLAKE2b-256 | 6bdb3cf95943a8ab5a38c630e0d2d14e19eaf972eff72e33f18b6f6991286731 |
Close
Hashes for pydantic_settings_yaml-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90535511ad96a11557518ed10863cc655d19deb32d0c0e271c911c856fa2b57d |
|
MD5 | 1a7179edf6bbd97082e6c10840f905bb |
|
BLAKE2b-256 | 36602040c15c7fccba52064a7670cd81214fba2f2349386a090b2ab2ebb592de |