pyknf
Load and merge layered JSON and TOML configuration files into a dict. This is the same
Rust merge the knf command line runs, called
natively.
pip install pyknf # the module, and the `knf` executable
from knf import load
config = load(["base.toml", "prod.toml"])
config["server"]["port"] = 8080
Discover and filter paths before loading them:
from knf import accumulate, filter_paths, load
files = accumulate("services/api/prod.toml", base_dir=project_root)
files = filter_paths(files, "{defaults,prod}.toml", filename_only=True)
config = load(files, interpolate=True)
Both helpers accept strings and os.PathLike objects and return pathlib.Path
objects. accumulate discovers same-format files along the relative target's
directories, excluding files directly in the base directory, sorting each
directory by filename and placing the target last. It does not parse contents.
Without base_dir, results are relative to the working directory; an explicit
base produces absolute paths without changing the working directory or
canonicalizing symlinks. Absolute targets, .., stdin and unsupported
extensions are rejected.
filter_paths filters existing candidates without filesystem access and
preserves order and duplicates. Patterns match entire paths unless
filename_only=True; matching uses the command line's case-sensitive glob
syntax. Matching precedes conversion to Path, which normalizes components
such as ./. Invalid targets/patterns and other non-regular targets raise
ValueError; discovery I/O failures raise OSError subclasses with .errno
and .filename, including IsADirectoryError for directory targets.
Pass interpolate=True to resolve references after all files have been merged:
config = load(["base.toml", "prod.toml"], interpolate=True)
${key.path} reads a value from the final config, including nested keys and
array elements such as ${servers[0].host}. A reference that occupies the
whole string keeps the value's type: "${server.port}" can become an int,
and "${server}" can become a dict. Within other text, it becomes a string:
"http://${server.host}:${server.port}/". ${env:NAME} reads the process
environment; a whole-string environment reference parses a native JSON or TOML value with string
fallback, matching the CLI's inline typing, while an embedded one inserts raw text. Use $$ for a literal
$. Interpolation is off by default, leaving reference strings untouched.
Invalid or missing references and cycles raise knf.InterpolationError, a
ValueError, with the affected key paths.
Files are merged left to right, exactly like knf base.toml prod.toml.
Objects merge key by key. Arrays, scalars and None replace wholesale. Make
additional changes to the returned dict in Python; for example,
config["server"]["port"] = 8080 updates a nested setting.
A file that can't be read raises FileNotFoundError, PermissionError or
IsADirectoryError, as open() would. Invalid JSON or TOML raises
knf.ParseError, a ValueError like json.JSONDecodeError. TOML datetimes
return native datetime.datetime, datetime.date, or datetime.time objects,
matching Python's tomllib type mapping. Offset datetimes retain fixed UTC
offsets; local datetimes and times have no timezone. Fractional seconds truncate
to microseconds. A date/time Python cannot represent raises ValueError naming
its key path.
All inputs must use one format. Mixed JSON/TOML extensions raise ValueError
before document contents are read. An empty file list returns {}. JSON nulls
and large unsigned integers, and TOML non-finite floats, retain their values.
This changes the previous datetime-string and mixed-input behavior. The CLI
also now uses -f/--format for parsing, inline typing and output together;
--input-format and --null-as have been removed. No JSON/TOML conversion is
performed. Parsed values are preserved; source whitespace and comments are not.
See the project README for the merge semantics in full.
Metadata
Release files for pyknf 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 5.9 MB
Release files / pyknf-0.4.0-cp39-abi3-win_arm64.whl
| Download URL | pyknf-0.4.0-cp39-abi3-win_arm64.whl |
|---|---|
| Size | 628.0 kB |
| Tags | CPython 3.9 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
177136e0cd8f5a0d96665e1bcd4f4215acc57ddd0ffbf4eef9e56df07d5a69ce
|
|
BLAKE2b-256 checksum How to use checksums |
65084f6087d5798edaf6141c738688861934d25c49f814f9fa91f8fe05631336
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyknf-0.4.0-cp39-abi3-win_amd64.whl
| Download URL | pyknf-0.4.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 663.3 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5e02af6bd7a70e0ea6f4e9440479dd5da0d5279dd59f9eb36393e67a5f84d034
|
|
BLAKE2b-256 checksum How to use checksums |
3e39822c40e9691d9c3082e2691d29d3288a7b415d75020a961c0da6827a7348
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyknf-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl
| Download URL | pyknf-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 957.6 kB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5c3aed391adc0800bafe69ac2d3953dfa8f24f680757769bf2e2cabda8a2385e
|
|
BLAKE2b-256 checksum How to use checksums |
92a9a645cc5ca8494fff7512fd82e2be739dec8043984f62959e93abd4a8e077
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyknf-0.4.0-cp39-abi3-musllinux_1_2_aarch64.whl
| Download URL | pyknf-0.4.0-cp39-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 880.1 kB |
| Tags | CPython 3.9 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
00082757c11cfc411be95192c2d557af1f4548c0230cae34d447d08cac981999
|
|
BLAKE2b-256 checksum How to use checksums |
d6ec925996ad7941c6b0feb86236a82cc85c73f33458bcb96491dd83272c278b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyknf-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyknf-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 743.1 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
711e2962b86b0360c7072b12e7dfe23ff379b1b217f04832b5f0e37c48d283de
|
|
BLAKE2b-256 checksum How to use checksums |
06c60a781ade9cec06bc319cc8b900e23598091446dd6d4f62a8d315289105c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyknf-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pyknf-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 701.0 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
4948b2836f26b44e11fc8c903952977b7ca9cc4270fcdfd6702aaf7a3cc0604c
|
|
BLAKE2b-256 checksum How to use checksums |
5ec38ffc833b70031fdeabf57e2bd48f336d0c018e86cbcf9188e54032180c41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyknf-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | pyknf-0.4.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 677.9 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4c4628273b089b1dbd77a3a46df4b5c66197ff4790f0f412e41701f0e96a0d2c
|
|
BLAKE2b-256 checksum How to use checksums |
582949ab40ae157ce0c1b0ed86774bdcd89460f1b79f8c472b005e6ddc86d502
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyknf-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | pyknf-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 696.2 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
250bf014ba3a2a41a2993284f8db5aaba5a528acb22f88b60fccb95cab5bd2d6
|
|
BLAKE2b-256 checksum How to use checksums |
6e35d693c5c2230b8bbc077dfe5d896e1c636a531b86ddbd251fe1d3fe2b5c33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pyknf 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.