confection
The sweetest config system for Python
What it is and what it does
Confection solves the problem of managing complex, nested configurations in Python applications—especially machine-learning projects where hyperparameters and component settings need to be exposed without breaking intermediate function interfaces. It parses `.cfg` files using an INI-like format enhanced with JSON-typed values, dot-notation for nested sections, and cross-section variable references using `${section.key}` syntax. The package also integrates with function registries (via decorators) to instantiate configured objects with type validation.
You define configuration blocks in a `.cfg` file, load them with `Config().from_disk()`, resolve them through a registry, and receive a dictionary of initialized objects or plain settings. The system is designed to let you version functions and change defaults without breaking backward compatibility—a key concern when configuration becomes part of your API surface.
Use it for:
- Define machine-learning training pipelines with shared hyperparameters across multiple components using cross-section references.
- Manage optimizer, model, and data-loader configurations for deep-learning projects without hardcoding parameters.
- Build CLI or REST API applications where configuration needs to flow through many intermediate functions without modifying their signatures.
- Version function implementations in a registry so improvements can be deployed without breaking existing configuration files.
- Parse and validate complex nested object hierarchies from configuration files with automatic type checking against function signatures.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Confection is a configuration system for Python that parses INI-style `.cfg` files into nested dictionaries, with support for JSON values, cross-section references, and registry-based function instantiation.
Yes. Confection is actively maintained, has no known vulnerabilities, and installs with minimal friction. It is well-suited for machine-learning and complex application configuration where you need to avoid tight coupling between configuration and function signatures. The MIT license imposes no restrictions. Install it if you are building systems where configuration complexity and versioning matter; skip it for simple flat-file or environment-variable configuration.
Install
confection on PyPI
pip
pip install confectionuv
uv add confectionpoetry
poetry add confectionInstalling confection
Before you install
Installation is straightforward with low friction—a pure Python wheel with only typing_extensions as a runtime dependency. The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it suitable for most projects without licensing concerns.
Quickstart
pip install confection
from confection import Config
config = Config({"training": {"patience": 10, "dropout": 0.2}})
# or load from disk:
# config = Config().from_disk("./config.cfg")
print(config)
Requires Python 3.10 or later. Registry-based function instantiation requires the catalogue package to be installed separately.
Verify before relying
- Whether catalogue integration is required for all use cases or optional for registry functionality
- Performance characteristics when parsing large or deeply nested configuration files
- Backward compatibility guarantees across minor version updates
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing_extensions |
| Maintenance | actively maintained — 143 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 20,544,828/month — #1,033 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: confection-1.3.3-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
config-formatterAutomatically formats .ini and .cfg…
permissive · top 15,000 on PyPI
gin-configGin provides a lightweight configuration…
permissive · top 15,000 on PyPI
catalogueProvides lightweight function registries that…
permissive · top 1,000 on PyPI
INIToolsINITools parses and manipulates INI-style…
permissive · top 15,000 on PyPI
commented-configparserExtends Python's standard ConfigParser to…
permissive · top 15,000 on PyPI
imperfectParses and edits configparser-compatible INI…
permissive · top 15,000 on PyPI
draccusDraccus parses command-line arguments and…
permissive · top 5,000 on PyPI
configobjConfigObj reads, writes, and validates…
permissive · top 5,000 on PyPI
ConfigUpdaterConfigUpdater reads and modifies INI…
permissive · top 5,000 on PyPI
python-boxBox wraps Python dictionaries to enable…
permissive · top 5,000 on PyPI