-
Notifications
You must be signed in to change notification settings - Fork 187
Google Docstrings are (Mostly) Broken #514
Comments
Have you read the docs?
|
Sure have. This snippet from the docs talks a little bit about the issue.
|
I've also read and tested the code enough to recognize that the docs mean this quite literally:
Please correct me if I've missed something, but as far as I can tell, all that option does is disable some specific PEP-257 style checks. |
You can use this code to see what I mean: https://github.com/jroose/pydocstyle/tree/pydocstyle-514 It adds in several print statements to check whether _check_google_sections() or _check_numpy_sections() is being run. The file test_google_missing_arg.py is missing documentation for one of the parameters of its first function (function_with_types_in_docstring). That ought to trigger a D417, but it doesn't. However, if you change "Returns" to "Return" in the same docstring, it does trigger a D417 because it now detects the docstring as a "google-style" docstring and parses the arguments appropriately. This happens because the pydocstyle argument names don't include "Return" as a valid argument name for numpy-style docstrings.
|
I am tracking the larger work required for this to work with #482 (comment) and https://github.com/PyCQA/pydocstyle/milestone/6 |
As stated in #527, this can be circumvented by adding a Why do we keep fighting against linters? 🤔 |
The existing check for determining whether to use numpy or google docstrings looks like this:
Which appears to pass if any numpy-style section names are found. However, there's overlap between numpy section names and google section names: (e.g. Returns, Yields, Attributes, Methods, References, etc.). So if a Google docstring uses any section names that are shared with numpy, then pydocstyle will default to checking the function only for one or the other.
I suggest you enable a configuration option and/or command line option that selects between numpy and google style docstrings (possibly needing to be separate from convention to allow incompatible config items like ignore) instead of relying upon inaccurate heuristics. Such a configuration item would cause pydocstyle to override the default numpy docstring checking behavior in favor of Google docstrings.
The text was updated successfully, but these errors were encountered: