Open aannara opened 11 months ago
This would be a breaking change due to previous disables people have used not working anymore for magic methods. Before releasing that it would probably be worthwhile to consider the other rule codes. These should be straight forward to implement based on the linked PR. The ones I would consider are:
DCO020
(making it DCO026
)DCO023
(making it DCO027
)DCO030
(making it DCO033
)DCO040
(making it DCO043
)DCO050
(making it DCO057
)DCO053
(making it DCO058
)I would also create a shared function which determines whether a method is a magic method somewhere
@jdkandersson To my mind, __init__
is a special magic method, considering that several projects merge the class docstring and the __init__
docstring into the class docstring (leading to __init__
having no docstring at all).
For instance, Google styleguide states:
The
__init__
method may be documented in either the class level docstring, or as a docstring on the__init__
method itself. Either form is acceptable, but the two should not be mixed. Choose one convention to document the__init__
method and be consistent with it.
So, I think there are 3 cases:
__init__
What do you think about the paragraph in Google styleguide?
I think it is a fair request to have a specific rule to target __init__
. Personally, I think it is worthwhile to document arguments to __init__
since they are arguments to the constructor. In version 2 of flake8-docstrings-complete
it will be possible to disable a specific rule which will remove the requirement for a docstring on __init__
, see #23. I also looked at a few other rules and I think it makes sense to treat them differently for magic methods too. I just haven't gotten around to implementing that yet, though #23 should be relatively easy to follow to implement the rest of the rules noted above. PRs welcome 🙂
Currently if
__init__
does not have a docstring. We get this error:DCO010 docstring should be defined for a function/ method/ class, more information: https://github.com/jdkandersson/flake8-docstrings-complete#fix-dco010
.Need an ability to avoid adding docstring for
__init__
.If this linter is able to detect
__init__
and other dunder/magic methods, then it can be added as a new DOC rule and it can be ignored either by flake8 or by the tool itself.