Skip to main content

Binding Python various formats configurations to classes with type validation, environment variables, and nested classes.

Project description

config-binder

downloads PyPI version License versions

Configuration parsing with recursive class binding, environment variables resolution and type safety.

Installation

pip install config-binder

Simple example

input.yaml

host: ${MYAPP_HOST:localhost}
port: 5432
username: admin
password: ${MYAPP_PASSWORD}
export MYAPP_PASSWORD=123

With binding:

class MySettings:
    host: str
    port: int
    username: str
    password: str
    source_urls: List[str]


config = ConfigBinder.load('input.yaml')
print(f"type: {type(config).__name__}, config: host:{config.host} port:{config.port} source_urls:{config.source_urls}")

# Output:
# type: MySettings, config: host:localhost port:5432 source_urls:['some-url.com', 'another-url.com']

Without binding

config = ConfigBinder.load('input.yaml')
print(f"type: {type(config).__name__}, config: {config}")

# Output:
# type: dict, config: {'host': 'localhost', 'port': 5432, 'username': 'admin', 'password': '123', 'source_urls': ['some-url.com', 'another-url.com']}

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

config_binder-0.1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

config_binder-0.1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file config_binder-0.1.1.tar.gz.

File metadata

  • Download URL: config_binder-0.1.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.9.12-200.fc40.x86_64

File hashes

Hashes for config_binder-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ea7ffea17d88e92f7868b71025c7f66185b70ff915cc14cd92da44f22fb256d
MD5 baa3f4bb144bde820de8c53ad394ec1b
BLAKE2b-256 9d33a7da2ac9bdea1982e368a303d8cfc9bda7c9aea813fa75caf3b64a23e42a

See more details on using hashes here.

File details

Details for the file config_binder-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: config_binder-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.9.12-200.fc40.x86_64

File hashes

Hashes for config_binder-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0e6ef11495b6a8157d162b2f801b15f1ddbe94b809f5175e5db3d24dcfc4ea5
MD5 1e8531c55ffaf6c4cad2460505a3d809
BLAKE2b-256 8ed69ca7e4d6f9cdca3e9a7b3b4d9afeed819c01ed7bd692c62f509965cdcf17

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