Skip to content

bug: Return type in docstring rendered like a parameter name #2

@jayqi

Description

@jayqi

Description of the bug

When using Google-style docstrings with the optional return type, the return type is rendered as if it's a parameter name.

To Reproduce

This docstring:

def format_version(version: Version, format_string: str) -> str:
    """Format a version using a format string.

    Args:
        version (packaging.version.Version): The version to format.
        format_string (str): The format string to use.

    Returns:
        str: The formatted version.
    """

Produces this output:

### vspect.format_version

```python
format_version(version, format_string)
```

Format a version using a format string.

**Parameters:**

- **version** (<code>[Version](#packaging.version.Version)</code>) – The version to format.
- **format_string** (<code>[str](#str)</code>) – The format string to use.

**Returns:**

- **str** (<code>[str](#str)</code>) – The formatted version.

The package that I ran this on can be found here

Expected behavior

I expect the rendered return to look something like this:

- <code>[str](#str)</code> – The formatted version.

which is what get if my original docstring excluded the optional return type.

Environment information

  • System: macOS-14.7.2-x86_64-i386-64bit-Mach-O
  • Python: cpython 3.13.0 (/Users/jqi/vspect/.venv/bin/python3)
  • Environment variables:
  • Installed packages:
    • griffe2md v1.1.0

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions