hydromodpy.core.toml_io.error_locator#

Map Pydantic ValidationError paths back to TOML source lines.

Pydantic emits errors with a tuple loc such as ("flow", "param_list", 0, "kind"). When the payload comes from a TOML file, this module turns that tuple into a file:line pointer so users can jump straight to the offending section.

The lookup is heuristic: it does not require tomlkit and works on the raw text. It scans for [section.subsection] headers and key = assignments, falling back to the closest known location when an exact match is not found.

Functions

format_loc(loc)

Render a Pydantic loc tuple as a.b[0].c.

format_validation_error(error, *[, ...])

Return a multi-line message mapping each error to a TOML location.

locate_loc(text, loc)

Return the 1-based line number for the deepest known token in loc.