Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_settings_yaml-0.1.1.dev0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

pydantic_settings_yaml-0.1.1.dev0-py2.py3-none-any.whl (5.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pydantic_settings_yaml-0.1.1.dev0.tar.gz.

File metadata

File hashes

Hashes for pydantic_settings_yaml-0.1.1.dev0.tar.gz
Algorithm Hash digest
SHA256 b0436e5bfe93e22e588f91573d450c088d842b5adf30e529aa75b1709e9291fc
MD5 59b396c2e87fc9c2ee7120d6ab56e379
BLAKE2b-256 8ed5581edc0d929ed22598cd4a4208c6e1919800c8bf0ee1e539031b3c15332c

See more details on using hashes here.

File details

Details for the file pydantic_settings_yaml-0.1.1.dev0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_settings_yaml-0.1.1.dev0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fb5fec913db8773dfa81a4593679dde82455607c5aad178c1a2e751db5aaae5f
MD5 38a56ecdb0ab7add33561c82dbc2a1ad
BLAKE2b-256 e64b384c8e99cd9114da7fe346133852e0749df2fdad291142de764304d4e79b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page