Originally discussed here: mmacy/openai-python#7
It can be useful to have docstrings in overloads as well as in the implementation. For example VSCode understands those and will show/autocomplete the right parameters based on what you already typed.
mkdocstrings-python currently only renders signatures of overloads, and expects a docstring to only appear in the implementation. Maybe we can do better?
Not exactly sure. Copying the comment from the linked discussion:
from typing import overload
@overload
def f(a: int, x: bool) -> str:
"""Specific summary.
Specific body.
Args:
a: Specific description.
x: Common description.
"""
...
@overload
def f(b: str, x: bool) -> str:
"""Specific summary.
Specific body.
Args:
b: Specific description.
x: Common description.
"""
...
def f(
x: bool,
a: int | None = None,
b: str | None = None,
) -> str:
"""Generic summary.
Generic body.
Args:
a: Generic description.
b: Generic description.
x: Common description.
"""
return ...
A few things to take into account for mkdocstrings:
f
/
Discussion in Ruff: astral-sh/ruff#10071
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too