The core idea is to leverage Python’s typing.Annotated to embed params documentation directly within function parameter and return type hints.

Example:

from typing import Annotated, Any

def foo(
    x: Annotated[int, "Represents the horizontal coordinate."],
) -> Annotated[float, "Calculated y-coordinate."]:
    return float(x * 2)

Drawback: the comment within Annotated should not be too long, otherwise it will decrease function signature readability.