core: fix _parse_google_docstring mishandling continuation lines with colons#35680
Open
Alvin Tang (alvinttang) wants to merge 1 commit intolangchain-ai:masterfrom
Open
Conversation
Merging this PR will not alter performance
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
_parse_google_docstringincorrectly parses multi-line argument descriptions when a continuation line contains a colon. The continuation line is treated as a new argument definition instead of being appended to the current argument's description.Example
Before (broken): The parser creates 3 args:
query,for finding things,top_kAfter (fixed): The parser correctly creates 2 args:
query(with full description including "for finding things: important ones"),top_kRoot Cause
The parser used
if ":" in lineto detect new argument lines without considering indentation. In Google-style docstrings, continuation lines have deeper indentation than argument definition lines.Fix
Detect the base indentation level from the first argument line and treat any line with deeper indentation as a continuation of the current argument's description, regardless of whether it contains a colon.
Issue
Fixes #35679
Dependencies
None.
Testing
Added 4 unit tests in
test_function_calling.py::TestParseGoogleDocstring:test_continuation_line_with_colon— the core bug scenariotest_simple_args_still_work— regression check for basic argstest_continuation_line_without_colon— multi-line descriptions without colonstest_multiple_continuation_lines_with_colons— multiple continuation lines each containing colonsAll tests pass locally with Python 3.12.