skillfed

confection

The sweetest config system for Python

confection v1.3.3 20.5M downloads/30d#1,033 on PyPI193
Permissive license MIT Active released

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 confection

uv

uv add confection

poetry

poetry add confection

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering

Tags

config file parserini configuration systemnested config managementregistry-based object instantiationhyperparameter configurationmachine learning configfunction registry decorator
configuration-managementmachine-learningregistry-pattern

More Scientific/Engineering packages