mkdocstrings / griffe

Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in your API.
https://mkdocstrings.github.io/griffe
ISC License
316 stars 44 forks source link

bug: merge_init_into_class does not merge overloads #335

Open kaktus42 opened 1 week ago

kaktus42 commented 1 week ago

Description of the bug

When using merge_init_into_class, signature overloads (typing.overload) are not merged into the class' docs.

To Reproduce

Example:

from typing import overload

class Foo:
    """
    Foo class docs
    """

    @overload
    def __init__(self, *, a: str): ...

    @overload
    def __init__(self, *, b: str): ...

    def __init__(self, **kwargs):
        """
        Foo constructor docs
        """
        pass
merge_init_into_class: true merge_init_into_class: false
Screenshot 2024-11-20 at 14 03 51 Screenshot 2024-11-20 at 14 03 15
WRITE MRE / INSTRUCTIONS HERE

Expected behavior

The overload defs should also be rendered.

Environment information

griffe --debug-info  # | xclip -selection clipboard
pawamoy commented 1 day ago

Thanks for the report @kaktus42. Even though we could consider it a new feature, the behavior doesn't match what the user can expect, so I'll mark this as a bug.

Here is how I see things could be rendered:

This will bring rudimentary support for such cases. We have other issues in our backlog to improve support for overloads.