Skip to main content

Super config for python

Project description

SuperConf

A powerful and flexible configuration management library for Python, inspired by ClassyConf. SuperConf provides a clean, type-safe, and intuitive way to handle configuration from multiple sources including environment variables, configuration files, and dictionaries.

Inspired from cafram and Cafram

Features

  • 🔒 Type-safe configuration with built-in validation
  • 🔄 Multiple configuration sources (environment variables, files, dictionaries)
  • 📦 Nested configuration support
  • 🎯 Default values and custom casting
  • 🚀 Easy to use and extend
  • 🔍 Strict type checking mode
  • 📝 Comprehensive field types (Boolean, Integer, String, List, Dict, etc.)
  • 🎨 Support for custom field types

Quickstart

Installation

Install using pip:

pip install superconf

Or install from source:

git clone https://github.com/mrjk/python-superconf2.git
cd python-superconf2
pip install -e .

Basic Usage

Here's a simple example of how to use SuperConf:

from superconf.configuration import Configuration
from superconf.fields import FieldString, FieldInt, FieldBool, FieldList

class AppConfig(Configuration):
    class Meta:
        loaders = [Environment()]  # Load from environment variables
    
    debug = FieldBool(default=False, help="Enable debug mode")
    port = FieldInt(default=8080, help="Server port")
    app_name = FieldString(default="myapp", help="Application name")
    plugins = FieldList(default=[], help="Enabled plugins")

# Create and use the configuration
config = AppConfig()
print(config.debug)  # False
print(config.port)   # 8080

# Use environment variables to override defaults
# export APP_PORT=9000
# export APP_DEBUG=true

Overview

Requirements

  • Python 3.9 or higher
  • Dependencies:
    • pyaml >= 24.12.1
    • classyconf >= 0.5.2

FAQ

Q: How is SuperConf different from other configuration libraries?
A: SuperConf combines the best features of existing libraries with strong type safety, nested configurations, and a clean API.

Q: Can I use multiple configuration sources?
A: Yes, SuperConf supports multiple loaders that can be prioritized in order.

Q: Is it possible to extend SuperConf with custom field types?
A: Yes, you can create custom field types by extending the Field class.

Known Issues

  • String parsing for dictionary fields is not implemented yet
  • Cache settings need refinement
  • Some features are marked as WIP (Work in Progress)

Development

Setup Development Environment

  1. Clone the repository:
git clone https://github.com/mrjk/python-superconf2.git
cd python-superconf2
  1. Install development dependencies:
poetry install

Development Commands

SuperConf uses Taskfile for development tasks:

  • Run tests: task test
  • Run linting: task test_lint
  • Fix linting issues: task fix_lint
  • Generate documentation: task gen_doc_class_graph

Running Tests

task test        # Run all tests
task test_pytest # Run pytest suite
task test_recap  # View test coverage report

Project Information

License

This project is licensed under the GPLv3 License.

Author

Support

For support, please:

  1. Check the documentation
  2. Open an issue on GitHub

Related Projects

Roadmap

  • Implement string parsing for dictionary fields
  • Improve caching mechanism
  • Add more configuration sources
  • Create comprehensive documentation site
  • Add more examples and use cases
  • Implement configuration validation hooks

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

superconf-0.1.1.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

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

superconf-0.1.1-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: superconf-0.1.1.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.10.11 Linux/6.6.47-1-MANJARO

File hashes

Hashes for superconf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b13a133446d7f08ea9ad7404e400b1c873d545e297d33f2a43867e80c1bd7752
MD5 02fbb2b0bb06a9ef3d733e3a475b3c71
BLAKE2b-256 99d208c81a913bc524db7c5e283ecc8dfeb798cf4287d7d34d007d066866f9b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: superconf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.10.11 Linux/6.6.47-1-MANJARO

File hashes

Hashes for superconf-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8aeb98d438578c097e0b025ddfac86af5a9244d113bdd59c826af09073a78f2
MD5 32a9292b9bcea402f3bd5f7f7ba1475e
BLAKE2b-256 efc2e0b02751dfd5946f057147932a6e071ab93a566eb76bb971df85bb3b1554

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