-
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
Docstrings display broken for dataclasses #640
Comments
Thanks for the suggestion. Pylance doesn't display class docstrings for constructors in any class, so this issue isn't specific to dataclasses. I guess it's more of an issue with dataclasses because the constructor is implicit. Maybe Pylance should always display the class docstring if the constructor ( |
FWIW This suggestion gets a definite yes from me. If a programmer has made the effort of actually writing a docstring, it should be displayed if it is even remotely relevant. I cannot imagine a single instance where a programmer did not write a docstring for their constructor because they explicitly did not want a docstring to be displayed for the constructor. It simply means that they are lazy and felt that they explained everything in the class docstring. And if a unicorn programmer should exist that explicitly does not want any docstring being shown for their constructor, they can always write an empty docstring for their constructor. |
@savannahostrowski That's great. Many thanks! |
@savannahostrowski Was this change included in Pylance v2021.6.1 or has it not been released yet? I can repeat the example you showed above, but I cannot get the class docstring to appear if the Additionally, no docstrings will show up in the constructor if the class is decorated as |
This will be fixed in the next release. |
This issue has been fixed in version 2021.6.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202162-16-june-2021 |
Environment data
Actual behaviour
Docstrings of dataclasses are not show for class instantiation:
You should attach the class docstring to your internally synthesized
__init__
function.Expected behaviour
Display docstrings for dataclass instantiation like you already do for normal classes:
![image](https://user-images.githubusercontent.com/5834577/99908660-1c116600-2ce4-11eb-8324-3dd71cc01b3e.png)
The text was updated successfully, but these errors were encountered: