Typed, dependency-free configuration objects with CLI, environment, and file parsing (a scriptconfig successor).
Project description
kwconf provides typed, dependency-free configuration objects that parse consistently from Python keyword arguments, the command line, the environment, and config files. It is a successor to scriptconfig, keeping the useful ergonomics while dropping the footguns (most notably, comma-strings no longer silently split into lists).
Read the Docs |
|
Github |
|
Pypi |
Features
One model, many inputs. CLI, kwargs, env, and files map onto the same field model.
Trust at the Python boundary, parse at the text boundary. Config(x='1') keeps '1'; --x=1 parses it. Defaults are WYSIWYG.
Progressive typing. Stays simple untyped; add annotations to harden. Value / Flag are typed so x: int = Value(None) is a static error on ty, mypy, and pyright. Ships py.typed.
Zero required dependencies. YAML and the ubelt-backed niceties are optional extras.
Modal subcommand CLIs, nested configs with dotted overrides, argparse round-tripping, and YAML/JSON load/dump.
Installation
pip install kwconf
# optional extras
pip install kwconf[yaml] # YAML config load/dump and parser='yaml'
pip install kwconf[ubelt] # rich repr, Config.__json__, port_to_argparse
Quickstart
import kwconf as kw
class DemoConfig(kw.Config):
count: int = 1
mode: str = kw.Value('fast', choices=['fast', 'safe'])
tags: list[str] = kw.Value(default_factory=list, nargs='+')
cfg = DemoConfig.cli(argv=['--count=3', '--mode=safe', '--tags', 'a', 'b'])
assert cfg.count == 3
assert cfg.mode == 'safe'
assert cfg.tags == ['a', 'b']
See the documentation for the coercion model, nested configs, modal CLIs, and a scriptconfig migration guide.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kwconf-0.10.0.tar.gz.
File metadata
- Download URL: kwconf-0.10.0.tar.gz
- Upload date:
- Size: 119.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb4bd0586fc2fd015d5738d65231163a81840815235fc588d13dcc139a843239
|
|
| MD5 |
0903092ea3f7669a536fcfd9f43f1cc8
|
|
| BLAKE2b-256 |
a8608c9001edf2683355343806382c2606890c3ccb6373ee17b821e7f1b3141e
|
Provenance
The following attestation bundles were made for kwconf-0.10.0.tar.gz:
Publisher:
release.yml on Erotemic/kwconf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kwconf-0.10.0.tar.gz -
Subject digest:
eb4bd0586fc2fd015d5738d65231163a81840815235fc588d13dcc139a843239 - Sigstore transparency entry: 1872514937
- Sigstore integration time:
-
Permalink:
Erotemic/kwconf@5b206d7c2a91ee19b1797eb40c4dc8172fa3eb94 -
Branch / Tag:
refs/heads/release - Owner: https://github.com/Erotemic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5b206d7c2a91ee19b1797eb40c4dc8172fa3eb94 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kwconf-0.10.0-py3-none-any.whl.
File metadata
- Download URL: kwconf-0.10.0-py3-none-any.whl
- Upload date:
- Size: 92.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4ef2dd871748acdf565de61bfbcca028b9736de37ff2d6483757a114bdbde49
|
|
| MD5 |
00b23fba27a6d19c4f7371c8965ebff7
|
|
| BLAKE2b-256 |
de8419e8037d5d99896a48bf94d85199edba4f331c92a82a2d3ccbb35c431ebd
|
Provenance
The following attestation bundles were made for kwconf-0.10.0-py3-none-any.whl:
Publisher:
release.yml on Erotemic/kwconf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kwconf-0.10.0-py3-none-any.whl -
Subject digest:
f4ef2dd871748acdf565de61bfbcca028b9736de37ff2d6483757a114bdbde49 - Sigstore transparency entry: 1872515051
- Sigstore integration time:
-
Permalink:
Erotemic/kwconf@5b206d7c2a91ee19b1797eb40c4dc8172fa3eb94 -
Branch / Tag:
refs/heads/release - Owner: https://github.com/Erotemic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5b206d7c2a91ee19b1797eb40c4dc8172fa3eb94 -
Trigger Event:
push
-
Statement type: