fix: convert remaining rst docstrings#1244
Conversation
Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
planetf1
left a comment
There was a problem hiding this comment.
A few gaps in the RST conversion — details inline.
Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
planetf1
left a comment
There was a problem hiding this comment.
Thanks for the follow-up commit — the issues I flagged in the first round are all resolved: the Example: and Deprecated: fences in interpreter.py are in place, the CONTRIBUTING.md fence nesting is correct (4-backtick outer, 3-backtick inner), and the documents type annotation in intrinsic/core.py is now present. Approving with a few small suggestions below.
| # Pattern for ``python ... `` blocks | ||
| python_blocks = re.findall(r"``python\s*\n(.*?)\n``", content, re.DOTALL) | ||
| # Pattern for ``python / ```python blocks (RST and Markdown) | ||
| python_blocks = re.findall(r"```?python\s*\n(.*?)\n```?", content, re.DOTALL) |
There was a problem hiding this comment.
Nice catch making the fences RST-aware. One gap: the optional third backtick means we now also match python `` blocks, but all the existing tests in test_reqlib_python.py use triple-backtick Markdown — which the old regex already matched. So the new double-backtick path has no coverage. Worth adding a test case that feeds in something like:
``python
def f():
return 1
``
...and asserts the block is extracted. That locks in the behaviour this change is actually for.
| Args: | ||
| response (str | None): Assistant response. When `None`, extracted from the | ||
| last assistant output in `context`. | ||
| documents (collections.abc.Iterable[str | Document]): Documents used to generate `response`. Each element may be a |
There was a problem hiding this comment.
Cosmetic only (ruff doesn't flag docstring prose), but this line runs long with the fully-qualified type inline. Breaking after the type keeps it aligned with the other args.
| documents (collections.abc.Iterable[str | Document]): Documents used to generate `response`. Each element may be a | |
| documents (collections.abc.Iterable[str | Document]): Documents used to | |
| generate `response`. Each element may be a |
| """Separate the system message from other messages. | ||
|
|
||
| :returns: Tuple of system message, if present, and remaining messages. | ||
| Returns: |
There was a problem hiding this comment.
Not a regression — the old :returns: was just as vague — but since we're touching this, the signature gives us the element types and the conversion was a chance to make the Returns line precise.
| Returns: | |
| tuple[SystemMessage | None, list]: The system message if present | |
| (else `None`), and the remaining non-system messages. |
| Note: Prefer `log_context` as the primary API — it guarantees cleanup | ||
| (including restoring outer values on same-key nesting) even on exceptions. |
There was a problem hiding this comment.
Tiny style nit while we're tidying these — Google style puts Note: on its own line with the body indented under it, matching how Args:/Raises: render. Inline works but is slightly inconsistent.
| Note: Prefer `log_context` as the primary API — it guarantees cleanup | |
| (including restoring outer values on same-key nesting) even on exceptions. | |
| Note: | |
| Prefer `log_context` as the primary API — it guarantees cleanup | |
| (including restoring outer values on same-key nesting) even on exceptions. |
Pull Request
Issue
Fixes #1172
Description
Converts remaining RST docstrings
Testing
Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.