Skip to content

bug: merge_init_into_class does not merge overloads #212

Closed

Description

@kaktus42

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

Activity

  1. pawamoy commented on Nov 26, 2024

    @pawamoy
    Member

    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.

  2. added
    bugSomething isn't working
    and removed
    unconfirmedThis bug was not reproduced yet
    on Nov 26, 2024
  3. transferred this issue frommkdocstrings/griffeon Dec 3, 2024
  4. pawamoy commented on Dec 3, 2024

    @pawamoy
    Member

    Here's how it will look.

    • separate signature
      afoo-separate
    • signature in heading
      afoo-no-separate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtemplatesJinja templates

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions