Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Show class attribute documentation on hover, similar to how parameter documentation is displayed #6017

Closed
macintacos opened this issue Jun 15, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@macintacos
Copy link

When hovering over a class attribute, it would be great if it showed documentation for that attribute, similar to how documentation hover works for parameters within a method.

Here's an example (using the syntax resolved in #3347 - I'm currently using the pre-release version of Pylance, v2024.6.100 (pre-release)):

class Foo:
    """Documentation for Foo.

    Parameters:
        bar (str): This is the docstring for `bar`.
        baz (int): This is the docstring for `baz`.
    """

    def __init__(self, bar: str, baz: int) -> None:
        self.bar = bar
        self.baz = baz

    def some_method(self, thing: str) -> None:
        """A summary for some_method.

        Args:
            thing (str): This is documentation for the `thing` param.
        """
        print(thing)


test = Foo(bar="something", baz=123)

print(test.bar)

Here's what I see when I hover my mouse over bar in the last print(test.bar) line:

CleanShot 2024-06-15 at 19 33 46@2x

And here's what I see when I hover my mouse over thing in Food.some_method:

CleanShot 2024-06-15 at 19 34 22@2x

I know that Pylance is "aware" of these parameters and their documentation, because it does get shown to me as I type:

CleanShot 2024-06-15 at 19 36 38@2x

As such, it would be great if that same documentation bits for class attributes could be shown in the hover window like parameters' documentation is shown for methods.

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Jun 15, 2024
@debonte debonte added enhancement New feature or request and removed needs repro Issue has not been reproduced yet labels Jun 17, 2024
@debonte
Copy link
Contributor

debonte commented Jun 17, 2024

The bar parameter on Foo.__init__ and the Foo.bar instance attribute are technically two different things, but I can see that in many cases you'd want them to both have the same docstring.

Moving this issue to discussions as an enhancement request for comments and upvotes.

@microsoft microsoft locked and limited conversation to collaborators Jun 17, 2024
@debonte debonte converted this issue into discussion #6023 Jun 17, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants