Skip to main content

A flexible, type-safe configuration management library for Python

Project description

Configr

A flexible, type-safe configuration management library for Python.

Configr simplifies configuration management by leveraging Python's dataclasses and type hints to provide a robust, type-safe approach to application configuration.

Python Versions PyPI version License: MIT Tests

  • Type Safety: Leverage Python's type hints for configuration validation
  • Dataclass Integration: Seamlessly map configuration files to Python dataclasses
  • Multiple Format Support: Load configuration from JSON and YAML files
  • Extendable: Easily add support for custom configuration formats
  • Simple API: Convenient decorator-based approach for defining configuration classes

Requirements

  • Python 3.10 or higher

Installation

pip install py-configr

# For YAML support
pip install py-configr[yaml]

Quick Start

Define your configuration class:

from configr import config_class, ConfigBase

@config_class(file_name="database.json")
class DatabaseConfig:
    username: str
    password: str
    database: str
    host: str
    port: int = 5432

# Load configuration
db_config = ConfigBase.load(DatabaseConfig)

# Use configuration
print(f"Connecting to {db_config.database} at {db_config.host}:{db_config.port}")

Create a configuration file in _config/database.json:

{
  "host": "localhost",
  "username": "admin",
  "password": "secure_password",
  "database": "my_app"
}

Documentation

For complete documentation, visit our documentation site.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

py_configr-0.5.0.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

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

py_configr-0.5.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file py_configr-0.5.0.tar.gz.

File metadata

  • Download URL: py_configr-0.5.0.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for py_configr-0.5.0.tar.gz
Algorithm Hash digest
SHA256 4d77394b1af0c099b8e4e7d76d459fd61e18c8274e4bd0a5a6b8acc30268a90e
MD5 b56faaa890d1f858de0c0b550c4e92ee
BLAKE2b-256 a5a6691954323378684a968541e38304d4aeb55dc7ef4af061201fabf42b0a42

See more details on using hashes here.

File details

Details for the file py_configr-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: py_configr-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for py_configr-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2aa0e58a31c86cf1573021088dfe26dc9b2f0a6843eb162bc386893f4aa1abf
MD5 6e6994e00f896ffb91f2014e6bc07298
BLAKE2b-256 ecc7274e0d1b92e0214184c580423c89af29e8006d37b0c05ce543b08d2cf1a4

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