Catalog PyPI
PACKAGE EXPLORERView in registry

aio-conf

PyPI
Versions collected1
Direct dependencies4From release 1.0.0.dev7
Last observed21 Oct, 11:44 UTC

README

Version 1.0.0.dev7 documentation

AIO-Conf

AIO-Conf is a tiny configuration system that unifies values from multiple sources: command-line arguments, environment variables, configuration files and defaults. Specifications are declared up front so each option knows how to be parsed and coerced into the correct Python type.

Installation

This project uses Poetry. From the project directory install dependencies with:

poetry install

Defining a specification

You can declare options programmatically using OptionSpec and ConfigSpec:

from aio_conf.core import ConfigSpec, OptionSpec

spec = ConfigSpec([
    OptionSpec("port", int, default=8000, env="APP_PORT", cli="--port"),
    OptionSpec("debug", bool, default=False, env="APP_DEBUG", cli="--debug"),
])

The spec can also be stored in JSON and loaded with ConfigSpec.from_json_file() or via AIOConfig.load_from_spec().

Loading configuration

AIOConfig merges all sources with the following precedence:

  1. CLI arguments
  2. Environment variables
  3. File values (json or yaml)
  4. Defaults defined in the spec
from aio_conf import AIOConfig

cfg = AIOConfig(spec)
cfg.load(
    cli_args=["--port", "9000"],
    env={"APP_DEBUG": "true"},
    file_path="config.json",
)
print(cfg.as_dict())

The env parameter accepts a mapping of environment variables and defaults to os.environ when omitted.

Configuration can be written to an INI file:

cfg.save_ini("settings.ini")

Testing

Run the test suite with:

pytest -q

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.0.dev712 Aug 20254

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 11:44 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:e48e61d9d39078f12a044cf11c72be6fb2b1d64813d016fa851de02a938f3f06