Skip to content

Google docstring that starts with "Args:" is parsed as REST with no params #115

Description

@HardMax71

If a Google-style docstring has no summary line and opens directly with Args:, parse() in auto mode returns a REST parse with zero params, silently. Explicit style=GOOGLE shows why:

docstring_parser 0.18.0
opens with 'Args:': style=DocstringStyle.REST short='Args:' params=[]
summary line then 'Args:': style=DocstringStyle.GOOGLE short='Send an email.' params=[('to', 'Recipient address.'), ('reason', 'One sentence explaining why this send is warranted.')]
opens with 'Args:' + explicit GOOGLE: ParseError: No specification for "Args": ""

Repro: https://gist.github.com/HardMax71/85992abc250e897dee92d0638cd820e2

Mechanism in docstring_parser/google.py (0.18.0 is the latest, same on master): inspect.cleandoc at line 219 strips the first line's indentation and dedents the rest by the common indent, so when Args: is line 1 the parameter lines lose their indent; the section cut at 261-264 (re.search(r"\n\S", meta_details)) then finds an empty chunk and line 288 raises ParseError. In auto style parser.py:36-48 swallows that and returns the parser with the most meta, which is REST with nothing.

It bites anyone generating tool schemas from docstrings: the descriptions are right there in the source and the model never sees them.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions