Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Improve rendering of function overloads #135

Open
pawamoy opened this issue Feb 21, 2024 · 0 comments
Open

feature: Improve rendering of function overloads #135

pawamoy opened this issue Feb 21, 2024 · 0 comments
Assignees
Labels
feature New feature or request fund Issue priority can be boosted insiders Candidate for Insiders

Comments

@pawamoy
Copy link
Member

pawamoy commented Feb 21, 2024

Is your feature request related to a problem? Please describe.

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?

Describe the solution you'd like

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:

  • we can have only one entry in the object inventory for function f
  • we can have only one entry in the object inventory for each parameter (a, b, c, d, x)
  • but maybe we can suffix links and ids such that parameters from overload 1 link to descriptions in overload 1, etc.

Describe alternatives you've considered

/

Additional context

Discussion in Ruff: astral-sh/ruff#10071

Boost priority

  • Boost priority in our backlog through Polar.sh. Higher pledge, higher priority.
  • Minimum pledge by user/organization is $5, minimum amount for boost is $30.
  • View all issues with pledges.
  • We receive the funds once the issue is completed and confirmed by you.
  • Features with the insiders label are released to sponsors first, and tied to a funding goal.
Fund with Polar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request fund Issue priority can be boosted insiders Candidate for Insiders
Projects
None yet
Development

No branches or pull requests

1 participant