Reputation: 187
I place all my docstring for a module/class within the class's docstring; as opposed to splitting the docstring between the class docstring and init docstring. After reading though a couple guidelines, I determined that while python does not condone this style, it is commonly adopted. Unfortunately for subclassed modules, Pylance/VS Code only displays what is in the baseclass's init docstring (assuming the subclassed module has no docstring). I don't want to change my docstring style.
Is there a way to have PyLance display the class's docstring or is there a way to simply copy the docstring in a manner that PyLance recognizes? I tried copying the docstring of the baseclass into the subclass init docstring simply using subclass.__doc__ = baseclass.__doc__
, which copies the docstring, but this not recognized by PyLance. I tried a few variants of this approach and while they all copied the docstring as expected, none where recognized by PyLance.
Example:
class A:
'''
This should display in both Class A and Class B
but currently is only displayed in Class A
'''
def __init__(self):
pass
# class B has no docstring or is copied
class B(A):
def __init__(self):
# This copies the docstring but is not recognized by pylance
B.__init__.__doc__ = A.__doc__
Upvotes: 0
Views: 39