-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
False negative differing-type-doc
for Google-style docstring
#10237
Comments
I think this is a feature request and not a bug. From what I can tell it appears the idea behind differing-type-doc is to highlight when the name X in the docstring is missing from the function parameters. An example being if you make a typo in the naming of the name in the docstring and it differs from what is listed in the parameters. |
I think there is a typo in the documentation of differing-type-doc, as there is differing-param-doc that catches differences in parameter name. Note that in the differing-type-doc documentation, there are two errors in the problematic code: |
My understanding is that both of these messages, for type and param, relate to name differences. |
the example problematic code on differing-param-doc doesn't raise an error. """Fake function."""
def add(x, y):
"""Add two numbers.
:param int x: x value.
:param int z: z value.
"""
return x + y
|
I don't follow what you mean by name differences. the type annotation in the function signature in the initial bug report is def test(x: Point) -> int:
"""Fake function.
Args:
x (Point): Value.
Returns:
int: Integer.
"""
return 5 |
The code explains it a bit more clearly than the docs I think: https://github.com/pylint-dev/pylint/blob/main/pylint/extensions/docparams.py#L510-L511 So, if you have a parameter X in the signature of the function but it is named XY in the docstring then it would raise the warning. And that happens for both So, I'm saying that type annotations are not factored into these checkers at all. It sounds like it could be a new check. |
does this comment convince you that the check is not happening? |
oh I see. I will argue that the documentation should be clarified, as this Sphinx-style docstring raises differing-type-doc: """Fake function."""
def add(x: int, y: int):
"""Add two numbers.
:param x: x value.
:type x: int
:param y: y value.
:type z: int
:return: Sum.
"""
return x + y I don't use Sphinx-style docstrings, always Google. In Google style there is no linebreak between the parameter definition and the type definition for the parameter, so it's basically impossible to raise differing-type-doc. |
For this one I do see some warnings (I wonder are our configs different in some way here): (venv312) markbyrne@Marks-Air-2 programming % cat x.py
"""Fake function."""
def add(x, y):
"""Add two numbers.
:param int x: x value.
:param int z: z value.
"""
return x + y
(venv312) markbyrne@Marks-Air-2 programming % pylint x.py --load-plugins=pylint.extensions.docparams
************* Module x
x.py:4:0: W9015: "y" missing in parameter documentation (missing-param-doc)
x.py:4:0: W9016: "y" missing in parameter type documentation (missing-type-doc)
x.py:4:0: W9017: "z" differing in parameter documentation (differing-param-doc)
x.py:4:0: W9018: "z" differing in parameter type documentation (differing-type-doc)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
(venv312) markbyrne@Marks-Air-2 programming % |
yup it's something in my |
Bug description
Command used
Pylint output
Expected behavior
Possible duplicate of #6478 . I expect the difference between
Point
in function signature andtuple[float, float]
in documentation to raisediffering-type-doc
.Pylint version
The text was updated successfully, but these errors were encountered: