Repository navigation
Parse HookToolset :param descriptions by indentation - #76701
Conversation
HookToolset matched each :param description with a regex that ran until the next line starting with ":" or the end of the docstring. So the last parameter absorbed everything after it (601 characters, including a code block, for apply_wildcard in S3Hook.list_keys, the docs' own example), a continuation line starting with a role such as :class: cut a description short, and a parameter with no description took the next field as its own. Follow reStructuredText field lists instead: a description continues while lines are indented deeper than its :param line. Generated-by: Claude Code following the guidelines
|
An empty Sphinx field can now suppress the Google-style fallback entirely. On bd208da, the following returns doc = "Read records.\n\nArgs:\n path: Path to read.\n\n:param undocumented:"
assert _parse_param_docs(doc) == {"path": "Path to read."}The final line creates an entry in |
An empty :param field still left an entry in params, so the Google-style fallback was skipped and then the empty entry was filtered out, returning nothing. Drop empty descriptions before deciding whether to fall back. Reported by @himanshuchawla0807-gif. Generated-by: Claude Code following the guidelines
|
Thanks, confirmed on bd208da. Fixed in d7e1087: empty descriptions are now dropped before deciding whether to fall back to Args. I also added your docstring as a test. It fails before the fix and passes after. |
…k line GoogleDisplayVideo360Hook.erf_uri's entity_type continuation line sat at the same indent as its :param line, so the field ended after the first line, and partner_id was missing its colon. A scan of every provider hook found no other docstring with either problem. The new parser case covers a description whose second paragraph follows a blank line, shaped like S3Hook.copy_object's source_bucket_key. Generated-by: Claude Code following the guidelines
Human Summary
HookToolset builds the tool descriptions it sends to the LLM from hook docstrings, and some parameter descriptions come out wrong in three ways:
As a result, the model gets wrong or noisy parameter descriptions. This change parses the docstrings the way reStructuredText does: a description keeps going as long as the next lines are indented deeper. It changes 61 of the 1,690 hook-method descriptions, and I checked each one.
AI Summary
Click here
HookToolsetbuilds each tool's parameter descriptions from the hook method's:paramdocs, using a regex that runs until the next line starting with:or the end of the docstring. That goes wrong in three ways:S3Hook.list_keys(the example in the HookToolset docs),apply_wildcardgets a 601-character description that includes an example and a code block.FTPHook.retrieve_filegivesblock_size850 characters.BigQueryHook.create_routine,routineis described only as "The routine to create. Either a", because the next line starts with:class:.:return:line becomes the parameter's description.This follows how reStructuredText field lists work instead: a description continues while lines are indented deeper than its
:paramline, and empty descriptions are left out.Across all 1,690 provider hook methods with
:paramdocs, 61 descriptions change: 23 are trimmed, 27 are completed and 11 empty ones are dropped. I read through the changed ones.Tests: three new cases in
TestParseParamDocs(trailing text after the last param, a continuation line starting with a role, and a param without a description). All three fail on main and pass here. The fulltest_hook.pypasses (106 passed). The Google-styleArgs:branch is unchanged.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines