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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67ed4ee44e4a46dd546ce1dec91004973942631b8220cc2e9a7587ad1b090ef2 |
|
MD5 | 28c8fa2577ca65bc5b07a28bc7196876 |
|
BLAKE2b-256 | c2ce6986160962572459551713827cd0d29f55fb5a7113e1e718629f3cb7db6c |
Close
Hashes for pydantic_settings_yaml-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 576ecd82d0345ee92ea29369a994519f31d6ea64c3a51e5fffd33376af2e8618 |
|
MD5 | ee8edb9ae420125f16603ca408bc2a14 |
|
BLAKE2b-256 | 49350dba45cc5935d49dfb3adea4f693e7625c5670984b0312ace1ccf184f838 |