-
Notifications
You must be signed in to change notification settings - Fork 767
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
Parent class's __init__ docstring shown when child has a class docstring #1047
Comments
Will investigate showing the most appropriate docstring. Thanks for the report. |
The next release changes our docstring code to ignore ... but won't fix something like this: class A:
"""Class doc for A"""
def __init__(self):
"""__init__ doc for A"""
class B(A):
"""Class doc for B"""
B() As we search down the Fixing this is a much more involved change. |
This also begs the question of whether or not the class doc is the most appropriate doc in the above example; the method doc may have useful information on how to call it that the class doc would effectively hide. I'm thinking this issue was really only reported due to the 2021.3.0 fixing #550/#877, and previously 2020.9.6 added support for the builtin's docstrings (including object's pesky docs). Perhaps the "right" solution is to call this fixed and see if anyone believes we should be showing B's doc in the example above later.
|
Yeah, I'm going to call this fixed for now. It seems like it's more consistent to not offer this doc if a parent |
This issue has been fixed in version 2021.9.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202191-8-september-2021 |
EDIT: NO BUG. very tricky This Bug isn't fixed yet. isn't it? Excellent test case by the way! Oh, sorry... i understand why... now
So it makes sense linting to __init__ when B() is called instead of class B |
Environment data
Expected behaviour
In this case
Hello
should be displayed when cursor is hovered onfoo()
.Actual behaviour
The very first doc of
__init__
is displayed, other than theHello
, if we add'''Hello'''
in the__init__
's spec then it will be displayed. And if we remove the__init__
definition, the class's docstring will be displayed.This may cause inconvenience when reviewing large code blocks with objects, since docstrings are not directly displayed, and the case is inevitable even in packages like
pandas
because most code will not add same, or independent docstring for__init__
, and it's repetitive if such a docstring is required other than a class's own docstring.The text was updated successfully, but these errors were encountered: