microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 770 forks source link

Signature help isn't formatted beautifully when class docstring is reused for `__init__` #6012

Closed debonte closed 3 months ago

debonte commented 3 months ago

Environment data

Code Snippet

class Foo:
    """Does the thing.

    Attributes:
        bar (int): A short description
        buzz (str): A longer description that needs to be broken up over multiple lines,
            because there is additional context that I want to provide, and I don't
            want to go past the 88 line length limit for whatever reason.
    """
    bar: int
    buzz: str

    def __init__(self, bar, buzz):
        self.bar = bar
        self.buzz = buzz

Repro Steps

  1. Paste code above.
  2. Initiate signature help for __init__ by typing Foo(

Expected behavior

Current parameter's docstring is shown in markdown and there's a line separating the parameter docstring from the full docstring.

image

Actual behavior

Current parameter's docstring is shown in plaintext. No line separating it from the full docstring.

image

Apparently this is because we're using the class docstring for __init__ and the class docstring has an "Attributes" section instead of "Parameters". If you change it to "Parameters" it works as expected.

rchiodo commented 3 months ago

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