confuse
Painless YAML config files
What it is and what it does
Confuse is a configuration library that wraps YAML files with a validation and layering system. It lets you read configuration from multiple sources—built-in defaults, system-wide files, user-specific overrides, environment variables, and command-line arguments—and merge them into a single validated configuration object. The library handles the boilerplate of type checking, file location discovery across different operating systems, and human-readable error messages.
You use it by creating a Configuration object, then accessing values through a dictionary-like API that validates types on retrieval. For example, `config['num_goats'].get(int)` fetches the value and ensures it's an integer. It integrates with argparse and optparse from the standard library, supports environment variable substitution with automatic type conversion, and knows where to look for config files on Unix, macOS, and Windows without you having to write platform-specific code.
Use it for:
- Build a CLI tool that reads user settings from ~/.config on Unix or %APPDATA% on Windows without platform-specific logic.
- Layer application defaults with user overrides and command-line flags, where each layer can be specified as YAML.
- Validate that configuration values are the correct type (integer, string, list, etc.) and provide clear error messages when they aren't.
- Support environment variable configuration for containerized or cloud-deployed applications with automatic type conversion.
- Initialize a default configuration file on first run using an in-package YAML template.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Confuse is a YAML configuration library that handles defaults, type validation, layering, platform-specific file locations, and command-line/environment variable integration for Python applications.
Yes. Confuse is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a common problem (configuration management) with a clean API. It's suitable for any Python application that needs to read YAML config files with validation and layering. The MIT license poses no restrictions.
Install
confuse on PyPI
pip
pip install confuseuv
uv add confusepoetry
poetry add confuseInstalling confuse
Before you install
Low install friction with only two runtime dependencies (pyyaml and typing_extensions). The project is actively maintained with a recent release 26 days ago and steady repository activity since its initial release in 2015.
License in practice
MIT license (permissive) means you can use this freely in commercial and private projects with minimal restrictions, requiring only attribution.
Quickstart
pip install confuse
import confuse
config = confuse.Configuration('myapp', read=False)
config['num_goats'].get(int)
Requires Python 3.10 or later.
Verify before relying
- Whether the package's type validation covers all common Python types or only a subset.
- Performance characteristics when dealing with large or deeply nested configuration files.
- Whether environment variable expansion supports all standard shell syntax.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — pyyaml, typing_extensions |
| Maintenance | actively maintained — 26 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,657,496/month — #3,677 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: confuse-2.2.1-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
yaml-configReads configuration from YAML files and…
unclear · top 5,000 on PyPI
config-parserMerges configuration from YAML/JSON files,…
agpl · top 5,000 on PyPI
sconfsconf is a YAML-based configuration library…
permissive · top 15,000 on PyPI
configuratorBuilds a configuration store by layering…
permissive · top 15,000 on PyPI
yacsYACS is a lightweight configuration management…
permissive · top 5,000 on PyPI
pyaml-envParses YAML configuration files and resolves…
permissive · top 15,000 on PyPI
lib-layered-configLoads and merges configuration from multiple…
permissive · top 15,000 on PyPI
ConfigArgParseExtends Python's argparse to parse command-line…
permissive · top 1,000 on PyPI
donfigDonfig provides a unified configuration system…
permissive · top 5,000 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI