Skip to main content

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.json"])
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.json"], 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 uses the CLI's JSON-or-string typing rule, 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.json. 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 come back as their TOML spelling in a str.

See the project README for the merge semantics in full.

Metadata

Release files for pyknf 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyknf 0.3.3
File Actions
pyknf-0.3.3-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for pyknf-0.3.3-cp39-abi3-win_arm64.whl
pyknf-0.3.3-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for pyknf-0.3.3-cp39-abi3-win_amd64.whl
pyknf-0.3.3-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for pyknf-0.3.3-cp39-abi3-musllinux_1_2_x86_64.whl
pyknf-0.3.3-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for pyknf-0.3.3-cp39-abi3-musllinux_1_2_aarch64.whl
pyknf-0.3.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for pyknf-0.3.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pyknf-0.3.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for pyknf-0.3.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
pyknf-0.3.3-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for pyknf-0.3.3-cp39-abi3-macosx_11_0_arm64.whl
pyknf-0.3.3-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for pyknf-0.3.3-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 5.9 MB

Release files / pyknf-0.3.3-cp39-abi3-win_arm64.whl

Download URL pyknf-0.3.3-cp39-abi3-win_arm64.whl
Size 621.5 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
d2bb6a9ce9df85a8105c22851ef7a0093852ce14907a87aa9261786b9191ab45
BLAKE2b-256 checksum
How to use checksums
3690bfc1e199f785f9cff3f9b58180ab97a368376aa6efd52fee429c0be06b1c
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.3.3-cp39-abi3-win_amd64.whl

Download URL pyknf-0.3.3-cp39-abi3-win_amd64.whl
Size 654.0 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c440a6125b44c2faa14b548637472cdbe2d2f9a49417fbf703ee6992e1a20181
BLAKE2b-256 checksum
How to use checksums
f682a84d15656629f9be85521d63a3a1a4e0cdba9a3cd44616959b8a368bc9bb
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.3.3-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL pyknf-0.3.3-cp39-abi3-musllinux_1_2_x86_64.whl
Size 949.5 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
70ec51fd5822a20c08323ea259dce6965b8f7bb8383f257374e7e9ad1140d513
BLAKE2b-256 checksum
How to use checksums
1cb113078f4134cb4d022560c33a37d1717cc1c3f157e47d72bba556703a96af
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.3.3-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL pyknf-0.3.3-cp39-abi3-musllinux_1_2_aarch64.whl
Size 872.8 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
6db106f70f4b927903e0b5c6e0029a03f83dd4bec65ab7429f90affa77a41bde
BLAKE2b-256 checksum
How to use checksums
a3abfcb5158922d50202456a8159d11756fbe3c052bb912ba50441bfa0d5e1f6
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.3.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyknf-0.3.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 733.8 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e868fdde3a4db0da5ac7bdd1e57587b892cbf5024a206e0f10bf8a970aa3756b
BLAKE2b-256 checksum
How to use checksums
a495c02951d1f5c847c6fe86474cea083e90992f668316a710ac77a4998c7c59
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.3.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyknf-0.3.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 695.4 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
b71541c81e70a01563fb2cdf95b522fbd4009a7b1485ccc5056fd229e2e471d2
BLAKE2b-256 checksum
How to use checksums
c94b013e73eedefb1f4d6a2ec791a3a84b3977f72507c9fd5e6529afec057f20
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.3.3-cp39-abi3-macosx_11_0_arm64.whl

Download URL pyknf-0.3.3-cp39-abi3-macosx_11_0_arm64.whl
Size 667.3 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
475b34e98e75f5465a5660a1d153c7914c980e3ba77d73d3424cc963bc15b6df
BLAKE2b-256 checksum
How to use checksums
2073fad491faddf8de2eda2b93a2d9c8c35b505345a56fb12c85a0e5af708fb2
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.3.3-cp39-abi3-macosx_10_12_x86_64.whl

Download URL pyknf-0.3.3-cp39-abi3-macosx_10_12_x86_64.whl
Size 687.8 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3d16316be562e1c97067b518523b26e728a561587117db68c4703208e4a4ca5f
BLAKE2b-256 checksum
How to use checksums
fd0b9874b085438022a39d341c57acaa0995a7235e2bd84c1651213a910a2c30
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.3.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page