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.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

pydantic_settings_yaml-0.1.3-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pydantic_settings_yaml-0.1.3.tar.gz.

File metadata

File hashes

Hashes for pydantic_settings_yaml-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6543025bd84dd4de25b0f4e35012bbb8b4293d19b8ffc2a360b558ec748ac351
MD5 0d71a325138bd9ac1f4709c9e164c611
BLAKE2b-256 4c0a5cd7216462de107548bfd5aa417b1d6b4880632907542a32625d501c023e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantic_settings_yaml-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a9334700856e83b7db4005aaf4d71549934a167e8cb1be5d822a3a7351d70c42
MD5 60333e3a4c019a73da6b3c71ce128f6d
BLAKE2b-256 a104204ce2bf130fd53820c53010a4955ba76158685c3f5a44dd7ee92993baee

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