-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Docparams does not recognize class docstring when placed in __init__ #6692
Comments
Regarding the So: """MyModule"""
class MyClass:
"""_summary_
Args:
variable (int): _description_
"""
def __init__(self, variable: int) -> None:
"""_summary_
Args:
variable (int): _description_
"""
self.my_variable = variable
def method1(self) -> bool:
"""_summary_"""
return bool(self.my_variable)
def method2(self) -> int:
"""_summary_"""
return 2 if self.my_variable else 1 should raise something because |
So this means that if I want to put the constructor docstring in
In case anyone else is trying to accomplish something similar...ultimately I am trying to enforce the presence of class docstrings and also validate their content (using darglint). However, darglint can only validate constructors when they are in Anyway thanks for looking into this. I personally don't care about the missing |
What's the consensus on implementation? Is fixing the issue as stated originally the way to go? |
The issue as originally stated is not a false positive, what should be implemented now is the check talked about in the last comment. |
Bug description
The documentation states that "Constructor parameters can be documented in either the class docstring or the init docstring, but not both.
However, I see that the docstring is only recognized when in the class docstring.
Consider this simple
main.py
:This will raise a missing-class-docstring error.
If I move the docstring from
__init
to the Class, it passes.Also of note, if I put the docstring in both places, I do not get multiple-constructor-doc error.
Configuration
Command used
Pylint output
************* Module main main.py:3:0: C0115: Missing class docstring (missing-class-docstring) ------------------------------------------------------------------ Your code has been rated at 8.57/10 (previous run: 8.57/10, +0.00)
Expected behavior
I expect to not receive this error when the docstring is in
__init__
Also, I expect to receive multiple-constructor-doc if I put the docstring in both places.
Pylint version
OS / Environment
Windows Git Bash
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: