--- id: confection version: "1.3.3" license: MIT license_treatment: permissive maintenance: active --- # confection — The sweetest config system for Python License: permissive · Maintenance: active · Downloads: 20.5M/mo ## 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 above — 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 pip install confection uv add confection 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_current - Install friction: low - Maintenance: active - Downloads: 20.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags config file parser, ini configuration system, nested config management, registry-based object instantiation, hyperparameter configuration, machine learning config, function registry decorator, configuration-management, machine-learning, registry-pattern [View on SkillFed](https://skillfed.io/packages/confection) · [View on PyPI](https://pypi.org/project/confection/)