Skip to main content

Painless YAML config files

Project description

https://github.com/beetbox/confuse/actions/workflows/main.yml/badge.svg http://img.shields.io/pypi/v/confuse.svg

Confuse is a configuration library for Python that uses YAML. It takes care of defaults, overrides, type checking, command-line integration, environment variable support, human-readable errors, and standard OS-specific locations.

What It Does

Here’s what Confuse brings to the table:

  • An utterly sensible API resembling dictionary-and-list structures but providing transparent validation without lots of boilerplate code. Type config['num_goats'].get(int) to get the configured number of goats and ensure that it’s an integer.

  • Combine configuration data from multiple sources. Using layering, Confuse allows user-specific configuration to seamlessly override system-wide configuration, which in turn overrides built-in defaults. An in-package config_default.yaml can be used to provide bottom-layer defaults using the same syntax that users will see. A runtime overlay allows the program to programmatically override and add configuration values.

  • Look for configuration files in platform-specific paths. Like $XDG_CONFIG_HOME or ~/.config on Unix; “Application Support” on macOS; %APPDATA% on Windows. Your program gets its own directory, which you can use to store additional data. You can transparently create this directory on demand if, for example, you need to initialize the configuration file on first run. And an environment variable can be used to override the directory’s location.

  • Integration with command-line arguments via argparse or optparse from the standard library. Use argparse’s declarative API to allow command-line options to override configured defaults.

  • Include configuration values from environment variables. Values undergo automatic type conversion, and nested dicts and lists are supported.

Installation

Confuse is available on PyPI and can be installed using pip:

pip install confuse

Using Confuse

Confuse’s documentation describes its API in detail.

Credits

Confuse was made to power beets. Like beets, it is available under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

confuse-2.1.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

confuse-2.1.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file confuse-2.1.0.tar.gz.

File metadata

  • Download URL: confuse-2.1.0.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for confuse-2.1.0.tar.gz
Algorithm Hash digest
SHA256 abb9674a99c7a6efaef84e2fc84403ecd2dd304503073ff76ea18ed4176e218d
MD5 8f12861ce346f309e0c6a214db29ea21
BLAKE2b-256 24017d24e53986959b6148da5d0ffbce3e02e844110ac126bb42f46cad645ec9

See more details on using hashes here.

Provenance

The following attestation bundles were made for confuse-2.1.0.tar.gz:

Publisher: make_release.yaml on beetbox/confuse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file confuse-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: confuse-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for confuse-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 502be1299aa6bf7c48f7719f56795720c073fb28550c0c7a37394366c9d30316
MD5 c8aff950b7c7d4ac99cf9e445ffa5641
BLAKE2b-256 ea6a60e8d4a0e48559ff05aa7c9c65449c3a29c32ffe9f0690dc94b526c73c1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for confuse-2.1.0-py3-none-any.whl:

Publisher: make_release.yaml on beetbox/confuse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page