"""Fix the contradictory line 204 in error_handling.md."""
from __future__ import annotations

import sys
from pathlib import Path

DOC = Path("conductor/code_styleguides/error_handling.md")

OLD = "  grok); `send()` is the new public API; `send()` is `@deprecated`."

NEW = "  grok); `send(...) -> Result[str, ErrorInfo]` is the public API."


def main() -> int:
 with DOC.open("r", encoding="utf-8", newline="") as f:
  content = f.read()
 if OLD not in content:
  print(f"NOT FOUND: {OLD!r}", file=sys.stderr)
  return 1
 new_content = content.replace(OLD, NEW, 1)
 with DOC.open("w", encoding="utf-8", newline="") as f:
  f.write(new_content)
 print("Line 204 fixed.")
 return 0


if __name__ == "__main__":
 raise SystemExit(main())
