_yaml¶
rhiza_hooks._yaml
¶
Shared helper for loading a YAML file into a top-level mapping.
Every rhiza-hooks entry point that reads a YAML config — the template-bundles
loader (:mod:rhiza_hooks._bundles_fetch), the .rhiza/template.yml reader
(:mod:rhiza_hooks._bundles_config), and the rhiza-config checker
(:mod:rhiza_hooks.check_rhiza_config) — shares the same open →
yaml.safe_load → "is it a non-empty mapping?" sequence. Only the wording of
their error messages differs. This module centralises that sequence and reports
the failure mode as a small enum so each caller phrases its own message (or,
like :func:rhiza_hooks._bundles_config.get_config_data, ignores the reason
and simply treats any failure as "absent").
YamlError
¶
YamlFailure
dataclass
¶
A failed :func:load_yaml_mapping.
kind is the failure mode; detail carries the parser exception text
when kind is :attr:YamlError.INVALID (empty otherwise).
Source code in rhiza_hooks/_yaml.py
load_yaml_mapping(path)
¶
Load path and return its top-level YAML mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
File to read. |
required |
Returns:
| Type | Description |
|---|---|
dict[Any, Any] | YamlFailure
|
The parsed mapping on success, or a :class: |
dict[Any, Any] | YamlFailure
|
the file is missing, unreadable, invalid, empty, or not a mapping. |
dict[Any, Any] | YamlFailure
|
Callers |
dict[Any, Any] | YamlFailure
|
the type checker. |