_toml¶
rhiza_hooks._toml
¶
Shared lenient TOML loader.
Every hook that reads a TOML file — pyproject.toml, Cargo.toml,
rust-toolchain.toml, .bumpversion.toml — treats a missing, malformed or
unreadable file as "unspecified": a broken manifest is somebody else's error to
report, not a reason to crash the commit. That stance used to be implemented
separately in five modules, whose except tuples drifted apart until two of
them crashed on invalid UTF-8 (#396). This module is now the only place that
calls :func:tomllib.load.
load_toml(path)
¶
Parse a TOML file, treating unreadable or malformed input as absent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
File to parse. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The parsed mapping, or None if the file is missing, malformed, not valid |
dict[str, Any] | None
|
UTF-8, or cannot be opened (for example, the path is a directory). |