-
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
Allow short docstrings in pydoclint #13086
Comments
Possibly related to #5860 EDIT: I should probably elaborate. The proposal to restrict docstring diagnostics based on docstring complexity (what you describe) is distinct to what I linked (which is a proposal to limited based on function complexity). However, they face overlapping design challenges, so it might make sense to link them. |
@valentincalomme or @augustelalande, would you be able to elaborate a bit more about why this config option is desirable? I don't feel like #13302 gives a great description of what the config option is for right now, but I'm not sure how to improve it as I don't fully feel like I understand why it would be useful. |
@AlexWaygood for me it is desirable in the very simple scenario where I want to add a "one-liner" docstring, just to explain briefly what my method does. I dont' want pydoclint to complain that I am missing descriptions for the parameters. Actually, a good description is how
Right now, the |
I, too, always use def square(x: float) -> float:
"""Square the given number."""
... I mean I guess it is a little weird to tie the requirement to document all parameters to the number of lines in the docstring, but I found this heuristic to work well. |
Maybe a better rule would actually be:
Instead of
|
Hey @AlexWaygood, Google's python style guide explicitly allows for one-liner docstrings to omit the special sections like
(Emphasis mine). Huge amounts of google-style python code follows this pattern for simple methods. The main purpose is to avoid having to litter your code with meaningless docstrings, for example: def clamp(value: float, lower_bound: float, upper_bound: float):
"""Clamps a value between lower and upper bounds."""
return max(min(value, maximum), minimum) Currently this complains with:
A workaround right now is to take advantage of the fact that pydoclint's parsing actually seems to work on the short line (which might be a separate bug now that I think about it), and write: def clamp(value: float, lower_bound: float, upper_bound: float):
"""Returns a value clamped between lower and upper bounds."""
return max(min(value, maximum), minimum) But that's overly verbose and not actually helpful for understanding the code. The full example: def clamp(value: float, minimum: float, maximum: float) -> float:
"""Clamp a value clamped between a minimum and maximum.
Args:
value: The value to clamp.
minimum: The minimum value.
maximum: The maximum value.
Returns:
The clamped value.
"""
return max(min(value, maximum), minimum) Is so verbose as to be actively unhelpful for readability. Since we support Google's docstrings style, we should not only allow short docstrings in pydoclint, but also enable it by default if the following setting is enabled: [tool.ruff.lint.pydocstyle]
convention = "google" |
As of
ruff==0.6.2
,pydoclint
rules (DOC) doesn't allow any settings. If prioritization is required, I would personally really value having the--skip-checking-short-docstrings
setting (see: https://jsh9.github.io/pydoclint/config_options.html)This is currently blocking me from using the rule altogether.
The text was updated successfully, but these errors were encountered: