Search code examples
pythonspyderpython-decoratorsdocstring

Spyder doesn't display docstring when using @property decorator


Using Ctrl + i in Spyder generally displays the docstring for the object the cursor is at, but for the B method in the following code, it returns a red "No further documentation available" message:

class A():
    @property
    def B(self):
        ''' This is a docstring. '''

If the @property decorator is commented out, it works fine. I get that property is wrapping around B somehow, but it seems like there should be an easy, built-in way to get the docstring to pass through and I can't find an answer.

Is there a way to get around this? What's the best way to get the Spyder interactive help to display the docstring for potentially many class methods that each have the @property decorator?

This question certainly seems related, and may help answer why it behaves in this way, but does that mean I need to subclass the property built-in in some way?

EDIT: Maybe it's something internal to Spyder, because this works with @property:

>>> print(A.B.__doc__)    
 This is a docstring. 

Solution

  • I found that upgrading from Spyder 2.3.8 to Spyder 3.0.1 fixes this issue. The docstring now displays properly.