pytoolconfig is a Python library designed for simple and declarative definition of tool configurations, typically read from `pyproject.toml` or other config files. It provides a `ToolConfig` class to define configuration schemas with type hints and default values. The current version is 1.3.1, and it maintains a moderate release cadence, with minor updates every few months addressing features and maintenance.
pip install pytoolconfigVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a configuration schema using `ToolConfig` and `Field`. It then shows how to load configuration data, respecting default values and showing how environment variables or file-based settings would override defaults. `pytoolconfig` automatically looks for configuration in various places like `pyproject.toml` or `.{app_name}.yaml` when `ToolConfig.load()` is called without `config_data`.
Upgrade Python to version 3.8 or higher. If unable to upgrade, pin pytoolconfig to `<1.3.1` (e.g., `pytoolconfig<1.3.1`).
Consult the official documentation for the precise loading order. Typically, CLI arguments take precedence over environment variables, which take precedence over configuration files, which in turn override schema defaults. Explicitly pass `config_data` to `ToolConfig.load()` for specific control.
Always import `Field` from `pytoolconfig` and refer to `pytoolconfig`'s documentation for the correct arguments and usage, especially for `default` and `default_factory`.