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

__init__ docstring is ignored if @overload is used #4042

Closed
wise0704 opened this issue Mar 4, 2023 · 4 comments
Closed

__init__ docstring is ignored if @overload is used #4042

wise0704 opened this issue Mar 4, 2023 · 4 comments
Assignees
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@wise0704
Copy link

wise0704 commented Mar 4, 2023

Environment data

  • Language Server version: 2023.3.10 (pyright 773a7cde)
  • OS and version: Microsoft Windows [Version 10.0.19045.2604]
  • Python version: Python 3.11.2

Code Snippet

class Test:
    """
    class docstring
    """

    @overload
    def __init__(self, x: int) -> None: ...
    @overload
    def __init__(self, x: str) -> None: ...
    def __init__(self, x) -> None:
        """
        init docstring
        """
        ...

Repro Steps

  1. A class with docstring + overloaded __init__ with docstring.

Seems to be a combination of #2948 and #1047.

Expected behavior

Shows the method docstring.

image

Actual behavior

Shows the class docstring instead

image

@wise0704
Copy link
Author

wise0704 commented Mar 4, 2023

On a second look it seems #1047 is unrelated.
Although the issue clarifies that intended behaviour is __init__ docstring chain before class docstring chain, and that info can be used to provides more detail:

image

So, docstrings of overloaded __init__ methods are just simply skipped.
I hope it means the logic is less complex and easier to fix.

@wise0704 wise0704 changed the title Class docstring instead of __init__ docstring if @overload is used __init__ docstring is ignored if @overload is used Mar 5, 2023
@judej judej added the needs investigation Could be an issue - needs investigation label Mar 6, 2023
@bschnurr
Copy link
Member

bschnurr commented Mar 7, 2023

Seems related this this pyright change. No longer seeing the implementation function when calling bindFunctionToClassOrObject
microsoft/pyright@85c043d

erictraut pushed a commit to microsoft/pyright that referenced this issue Mar 7, 2023
…ed method would adopt its class docstring rather than the docstring for its own implementation. This addresses microsoft/pylance-release#4042.
@erictraut
Copy link
Contributor

This will be fixed in the next release.

@bschnurr bschnurr added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Mar 7, 2023
@debonte
Copy link
Contributor

debonte commented Mar 9, 2023

This issue has been fixed in prerelease version 2023.3.21, which we've just released. You can find the changelog here: CHANGELOG.md

@debonte debonte closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

5 participants