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.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0436e5bfe93e22e588f91573d450c088d842b5adf30e529aa75b1709e9291fc |
|
MD5 | 59b396c2e87fc9c2ee7120d6ab56e379 |
|
BLAKE2b-256 | 8ed5581edc0d929ed22598cd4a4208c6e1919800c8bf0ee1e539031b3c15332c |
Close
Hashes for pydantic_settings_yaml-0.1.1.dev0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb5fec913db8773dfa81a4593679dde82455607c5aad178c1a2e751db5aaae5f |
|
MD5 | 38a56ecdb0ab7add33561c82dbc2a1ad |
|
BLAKE2b-256 | e64b384c8e99cd9114da7fe346133852e0749df2fdad291142de764304d4e79b |