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

bug: merge_init_into_class does not merge overloads #212

Closed
kaktus42 opened this issue Nov 20, 2024 · 2 comments
Closed

bug: merge_init_into_class does not merge overloads #212

kaktus42 opened this issue Nov 20, 2024 · 2 comments
Assignees
Labels
bug Something isn't working templates Jinja templates

Comments

@kaktus42
Copy link

kaktus42 commented Nov 20, 2024

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
  • System: macOS-14.7.1-x86_64-i386-64bit
  • Python: cpython 3.12.7 (/usr/local/Caskroom/miniconda/base/envs/medconb-client/bin/python3.12)
  • Environment variables:
  • Installed packages:
    • griffe v1.5.1

Additional context

@kaktus42 kaktus42 added the unconfirmed This bug was not reproduced yet label Nov 20, 2024
@pawamoy
Copy link
Member

pawamoy commented Nov 26, 2024

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:

  • separated signatures: render all signatures, just like for functions
  • heading-signatures: render the implementation signature in the heading, then further code blocks for each overload. I'm open to other suggestions, if you have any!

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

@pawamoy pawamoy added bug Something isn't working templates Jinja templates and removed unconfirmed This bug was not reproduced yet labels Nov 26, 2024
@pawamoy pawamoy transferred this issue from mkdocstrings/griffe Dec 3, 2024
@pawamoy
Copy link
Member

pawamoy commented Dec 3, 2024

Here's how it will look.

  • separate signature
    afoo-separate
  • signature in heading
    afoo-no-separate

pawamoy added a commit that referenced this issue Dec 3, 2024
@pawamoy pawamoy closed this as completed Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working templates Jinja templates
Projects
None yet
Development

No branches or pull requests

2 participants