BoundConfig
BoundConfig manages a TOML config file against one or more TOML defaults files. The current implementation can:
- add missing managed keys and sections with
init - validate managed content without writing with
validate - repair missing or invalid managed content through the Python API with
repair
Unknown user keys and sections are preserved during managed operations. Writes go
through tomlkit, so comments and ordering survive as well as that adapter
allows.
Current Public Surface
- CLI commands:
boundconfig init,boundconfig validate - Python API:
boundconfig.BoundConfig,boundconfig.register_validator - TOML only
- Python 3.10+
repair exists today, but only through the Python API. There is no CLI
repair subcommand in the current implementation.
Current Limits
- Defaults files must use top-level TOML sections only.
- Managed nested tables and arrays of tables in defaults files are out of scope.
- Managed inline-table defaults are validated only shallowly for table shape.
- There is no CLI hook for registering custom validators.
- Offset time values are not supported. Use TOML local time values instead.
Install From A Clone
python -m pip install -e .
After installation, the console script is boundconfig. The module entry point
also works:
python -m boundconfig --help
Quick Start
The sample set under samples/ is verified against the current test suite. The shortest walkthrough is samples/basic/.
Given a defaults file and a working config:
[service]
enabled = true
retries = 3
mode = { _default_value = "INFO", _allowed_values = ["DEBUG", "INFO"] }
point = { x = 1, y = 2 }
[ui]
theme = "dark"
[service]
enabled = "true"
mode = "DEBUG"
extra = "user"
[custom]
feature = true
Run init to add only missing managed content:
boundconfig init --config ./config.toml --defaults ./defaults.toml --verbose
Run validate to see what is still wrong:
boundconfig validate --config ./config.toml --defaults ./defaults.toml --verbose
Repair invalid managed values through the Python API:
from pathlib import Path
from boundconfig import BoundConfig
bound_config = BoundConfig(
config_path=Path("config.toml"),
defaults_paths=(Path("defaults.toml"),),
)
report = bound_config.validate()
repaired_document = bound_config.repair(dry_run=True)
init does not repair existing invalid managed values. repair does.
Guides
- Documentation index: docs/README.md
- Schema declarations: docs/schema-declarations.md
- Schema quick reference: docs/schema-quick-reference.md
initvsvalidatevsrepair: docs/init-validate-repair.md- Reserved sections and keys: docs/reserved-sections-and-keys.md
- Example files: samples/README.md
- TOML adapter ADR: docs/architecture/adr-0001-toml-adapter.md
Custom Validators
Custom validators are implemented, but the feature is intentionally narrow. A
schema can bind a field to a validator name with _validator, and Python code
can register a callable under that name.
[service]
name = { _default_value = "BoundConfig", _validator = "no-spaces" }
from pathlib import Path
from boundconfig import BoundConfig
bound_config = BoundConfig(
config_path=Path("config.toml"),
defaults_paths=(Path("defaults.toml"),),
)
bound_config.register_validator(
"no-spaces",
lambda value: "must not contain spaces" if " " in value else None,
)
report = bound_config.validate()
There is no CLI flag, plugin system, or import hook for validator registration
in the current implementation. If a defaults file uses _validator, the CLI
will only work if some wrapper code has already registered that validator in the
current Python process.
See samples/custom-validator/ for matching example files.
Notes On CLI Options
The CLI currently exposes the same option set on both subcommands because they share an argument parser:
--config--defaults--dry-run--verbose--suppress-warnings
Only part of that surface matters per command today:
inituses--dry-runand--verbose.--suppress-warningsis accepted but has no effect.validateuses--verboseand--suppress-warnings.--dry-runis accepted but redundant becausevalidatenever writes.--defaultscan be repeated or given multiple paths after one flag.
Metadata
Release files for boundconfig 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| boundconfig-0.1.0.tar.gz | 35.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| boundconfig-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 65.9 kB
Release files / boundconfig-0.1.0.tar.gz
| Download URL | boundconfig-0.1.0.tar.gz |
|---|---|
| Size | 35.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abbc2259765e3fd323e6b392dcae7758e066366db85604886e8c372199388a59
|
|
BLAKE2b-256 checksum How to use checksums |
100a0ed8d7de7b870fc899dfc04a6394fe1e7bf5689eb1d4d7bb120d2632f4b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / boundconfig-0.1.0-py3-none-any.whl
| Download URL | boundconfig-0.1.0-py3-none-any.whl |
|---|---|
| Size | 30.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5099d3032e2986e2f847506e13fc232a4f9b032c1e9d2ddd6dafbc9d310b63d9
|
|
BLAKE2b-256 checksum How to use checksums |
c1a6a93e655061cfcf353e259c49f0fc02d14579b85c2aa2c2668c8639be87ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|