Skip to main content

Configuration file provider that uses pydantic and type hints.

Project description

Pydaconf

Modern python configuration file manager using Pydantic and python type hints.

GitHub Workflow Status GitHub last commit GitHub GitHub Docs

What is PydaConf

Pydaconf is a simple yet powerful open-source Python library for loading application configurations. It leverages modern Python features, including type hints and the awesome data validation Pydantic models for clarity and maintainability. Pydaconf provides seamless configuration loading from YAML, TOML, and JSON files while supporting dynamic secret injection via a pluggable architecture.

Installation

Install using pip install pydaconf[all]
For more installation options see the Install section in the documentation.

A Simple Example

  • Create config file in toml, yaml or json
domain: pydaconf.com
openai_token: ENV:///OPENAI_TOKEN
database:
  host: eu-central-db01.{{ domain }}
  username: svc_db01
  password: SEALED:///gAAAAABnpRqHdho_dFB7iMs_Ufv5nu59LwqQfE3YCjaDTyg-YrYsEpK8bfvdKsdrj6kCxrAjezCGAdVM0FhzwyfYFIgqnquw8w==
  • Create Pydantic Model and load the configuration
from pydaconf import PydaConf
from pydantic import BaseModel

class DbConfig(BaseModel):
    host: str
    username: str
    password: str

class Config(BaseModel):
    domain: str
    openai_token: str
    database: DbConfig

provider = PydaConf[Config]()
provider.from_file("config.yaml")
print(provider.config.database.password)

Help

See documentation for more details.

Interpolation

Templates Example
contact_email: user@{{ domain }}
db_server: {{ backend.server }}
first_username: {{ users[0].username }}

Builtin plugins

Plugin Description
ENV Inject secret from environment variable
SEALED Inject a sealed secret. Secrets can be encrypted with a symmetric key and stored in a file. The provider expects the key in the PYDACONF_SEALED_KEY environment variable.
FILE_CONTENT Inject content from a file. This is useful in scenarios where the secret is mounted on the file system, such as in k8s containers.

Official plugins

Plugin Description

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

pydaconf-0.2.0.tar.gz (87.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydaconf-0.2.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file pydaconf-0.2.0.tar.gz.

File metadata

  • Download URL: pydaconf-0.2.0.tar.gz
  • Upload date:
  • Size: 87.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for pydaconf-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4a14c60f0488365ca20bd779982546b9d81ca0a7979f7d4a41910a0cd27e85f8
MD5 0fd29f9e6cbe211fae21495f06258981
BLAKE2b-256 945160d19055a8f9c9bbd87b61e3887e6338c7e1c8435892a5496eb5ff9ace28

See more details on using hashes here.

File details

Details for the file pydaconf-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pydaconf-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for pydaconf-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1b12fa0debea0756fe9ac61c483cc182fbb52d493c1a7024f0f5dc23fd38134
MD5 85ed86cd43e381493d2f087d81627c11
BLAKE2b-256 d5bba63a46ab44aec77b3d9c3d6e9173f972dab0496c059e8f5526f81949d88a

See more details on using hashes here.

Supported by

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