INNER CODE UNIT · Python

parse_guide_yaml

llm-d/llm-d · scripts/guide.py:218

def parse_guide_yaml(text: str) -> tuple[Any, Finding | None]:
    """Parse guide YAML strictly.

    Returns ``(data, None)`` on success, or ``(None, Finding)`` if the document
    could not be parsed. Parse failures are returned rather than raised so that
    batch validation can report every guide instead of aborting on the first.
    """
    try:
        return yaml.load(text, Loader=_StrictLoader), None
    except yaml.constructor.ConstructorError as e:
        mark = e.problem_mark
        return None, Finding(e.problem, "yaml", mark.line + 1 if mark else None)
    except yaml.YAMLError as e:
        return None, Finding(f"could not parse YAML: {e}", "yaml")


# --------------------------------------------------------------------------
# Marker grammar and YAML path navigation

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…