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

Docstring for function with decorators (@property) not displayed in IntelliSense #696

Closed
fsktom opened this issue Dec 6, 2020 · 9 comments
Labels
docstrings fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@fsktom
Copy link

fsktom commented Dec 6, 2020

Environment data

  • VS Code version: 1.51.1
  • Extension version: 2020.11.371526539
  • OS and version: Windows 10 20H2
  • Python version: 3.9.0

Expected behaviour

IntelliSense should show the docstring for a @property function when hovering over it, but doesn't.
It should display something like this:

Actual behaviour

It displays just its type.

Steps to reproduce:

class MyClass(object):
    """
    MyClass Docstring
    """

    def __init__(self, length):
        self._length = length

    @property
    def length(self):
        """
        This should be displayed, but isn't
        """
        return self._length

    @length.setter
    def length(self, value):
        if value < 0:
            raise ValueError("The length cannot be negative!")
        else:
            self._length = value


one = MyClass(3)
one.length = -2
  1. Put this code into VS Code
  2. Hover over length in one.length in the last line
  3. See that it displays length: int instead of This should be displayed, but isn't

Maybe I'm just doing it wrong, if so please enlighten me. (I'm learning Python and it's my first time using @property)

@luabud
Copy link
Member

luabud commented Dec 7, 2020

Hey there, it looks like you're using Pylance, so I'm transferring it to pylance's repo. If that's not it, please do try it out and see if that fixes your issue!

@luabud luabud transferred this issue from microsoft/vscode-python Dec 7, 2020
@github-actions github-actions bot added the triage label Dec 7, 2020
@judej judej added bug Something isn't working needs investigation Could be an issue - needs investigation labels Dec 7, 2020
@erictraut
Copy link
Contributor

It doesn't appear that you're using Pylance. Perhaps you have MPLS or Jedi configured instead?

Here's what Pylance displays in this case:
Screen Shot 2020-12-07 at 10 47 40 AM

@fsktom
Copy link
Author

fsktom commented Dec 8, 2020

Seems like @erictraut was right: Jedi was selected as the Python language server

I installed Pylance as @luabud suggested and now it displays properly like in the screenshot above. I guess I'll use Pylance from now on.

Though I'm not sure if that's the optimal outcome. But thanks for helping me :D

@fsktom
Copy link
Author

fsktom commented Dec 8, 2020

I just noticed one thing (relating to Pylance). I don't know if that's desired behavior or not, but in the autocompletion tooltip the docstring for the property is not displayed, only for the class.
image
image

@jakebailey
Copy link
Member

Does it work if you complete it and hover over length, i.e. does it only break when it's in the completion tooltip?

@jakebailey jakebailey reopened this Dec 8, 2020
@fsktom
Copy link
Author

fsktom commented Dec 9, 2020

Indeed. That's the case. I could make a video/gif showcasing that if you need it

@savannahostrowski
Copy link
Contributor

This will be fixed in the next version of Pylance.

@bschnurr

@savannahostrowski savannahostrowski added fixed in next version (main) A fix has been implemented and will appear in an upcoming version docstrings and removed bug Something isn't working needs investigation Could be an issue - needs investigation labels Feb 2, 2021
@fsktom
Copy link
Author

fsktom commented Feb 2, 2021

Thank you! :D

@jakebailey
Copy link
Member

This issue has been fixed in version 2021.2.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202120-3-february-2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docstrings 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

6 participants