Skip to main content

ConfigKit

Thread-safe singleton JSON/YAML configuration loader with JSON Schema validation for Python applications.

Features

  • JSON & YAML support - Load configuration from .json, .yaml, or .yml files
  • Thread-safe singleton - One instance per configuration class
  • JSON Schema validation - Draft 2020-12 support via jsonschema
  • Dot-notation access - config.get("database.host")
  • Runtime reload - Update configuration without restart
  • Type-safe - Full type hints with py.typed marker
  • Extensible - Custom validation via additional_checks()

Installation

From PyPI

pip install pyConfigKit

From Git repository

pip install git+https://github.com/miichoow/ConfigKit.git

Development mode

git clone https://github.com/miichoow/ConfigKit.git
cd ConfigKit
pip install -e ".[dev]"

Quick Start

1. Create your configuration class

from configkit import ConfigKit


class AppConfig(ConfigKit):
    def additional_checks(self) -> None:
        # Custom validation logic
        if self.data.get("debug") and self.data.get("env") == "production":
            raise ValueError("Debug mode not allowed in production")

    def get_database_url(self) -> str:
        host = self.get("database.host")
        port = self.get("database.port", default=5432)
        name = self.get("database.name")
        return f"postgresql://{host}:{port}/{name}"

2. Create configuration files

config.json

{
  "env": "development",
  "debug": true,
  "database": {
    "host": "localhost",
    "port": 5432,
    "name": "myapp"
  }
}

Or config.yaml

env: development
debug: true
database:
  host: localhost
  port: 5432
  name: myapp

schema.json (schema files are always JSON)

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": ["env", "database"],
  "properties": {
    "env": {
      "type": "string",
      "enum": ["development", "staging", "production"]
    },
    "debug": {
      "type": "boolean"
    },
    "database": {
      "type": "object",
      "required": ["host", "name"],
      "properties": {
        "host": { "type": "string" },
        "port": { "type": "integer", "minimum": 1, "maximum": 65535 },
        "name": { "type": "string" }
      }
    }
  }
}

3. Use in your application

# Initialize once at startup (JSON)
config = AppConfig(config_file="config.json", schema_file="schema.json")

# Or with YAML
config = AppConfig(config_file="config.yaml", schema_file="schema.json")

# Access anywhere - returns the same instance
config = AppConfig()
print(config.get_database_url())

API Reference

ConfigKit

Base class for configuration. Subclass and implement additional_checks().

Constructor

ConfigKit(*, config_file: str | Path, schema_file: str | Path)
  • config_file - Path to configuration file (.json, .yaml, or .yml)
  • schema_file - Path to JSON Schema file

Properties

Property Type Description
data dict[str, Any] Loaded configuration dictionary
schema dict[str, Any] Loaded JSON Schema dictionary

Methods

Method Description
get(path, *, default=None) Get value by dot-notation path
reload() Reload and re-validate from disk
additional_checks() Override for custom validation

ConfigKitMeta

Metaclass providing singleton behavior.

Method Description
reset() Clear all singleton instances (for testing)

Design Principles

  • Fail fast - Invalid configuration raises exceptions immediately
  • Single source of truth - One instance per configuration class
  • Explicit contracts - Required files on first instantiation
  • No magic - Clear, predictable behavior

Publishing

pip install -e ".[dev]"
python -m build
twine upload dist/*

License

MIT License - see LICENSE for details.

Release files for pyConfigKit 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyConfigKit 1.1.0
File Size Uploaded
pyconfigkit-1.1.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyConfigKit 1.1.0
File Interpreter ABI Platform
pyconfigkit-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.0 kB

Release files / pyconfigkit-1.1.0.tar.gz

Download URL pyconfigkit-1.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
287dd55970068a3f6b0ecd4921eacf06b910b56bffa378d0266e1b52e972fc1a
BLAKE2b-256 checksum
How to use checksums
ce196e4417d6f12b9ed8bfd96a4db3ee07c8083bee19c6d97f81a0cd97b3cbe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 8, 2026.

Transparency log

Release files / pyconfigkit-1.1.0-py3-none-any.whl

Download URL pyconfigkit-1.1.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1881866412fcc89480a314d90c195a17c879188cf49ba7319e40e8c22fd77737
BLAKE2b-256 checksum
How to use checksums
ab406f3d94751212cc54337545442e77c544581f3c2e156dfdece12813b3de8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page