Skip to content

useless-type-doc issued for undocumented parameters that have PEP484 type annotations #4593

@finite-state-machine

Description

@finite-state-machine

This likely relates to (and solves) issue #4117.

Steps to reproduce

Call pylint with the docparams extension enabled on the following code:

'''demonstrate FP with useless-type-doc'''

def function(public_param: int, _some_private_param: bool = False) -> None:
    '''does things

    Args:
        public_param: an ordinary parameter
    '''
    for _ in range(public_param):
        ...
    if _some_private_param:
        ...
    else:
        ...

Current behavior

$ python3 -m pylint --load-plugins=pylint.extensions.docparams --rcfile=/dev/null bug.py
************* Module bug
bug.py:4:0: W9020: "_some_private_param" useless ignored parameter type documentation (useless-type-doc)

------------------------------------------------------------------
Your code has been rated at 8.33/10 (previous run: 5.00/10, +3.33)

Expected behavior

Pylint should issue no errors.

It would be reasonable for pylint to issue this error if the type information appeared in the docstring, however, pylint is actually responding to the type annotation (as in PEP484). The docparams module should only issue errors in response to docstrings (or lack thereof), and not PEP484 annotations.

pylint --version output

Result of pylint --version output:

pylint 2.8.1
astroid 2.5.6
Python 3.8.3 (default, Jul  6 2020, 09:12:34)
[Clang 10.0.1 (clang-1001.0.46.4)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement ✨Improvement to a componentFalse Positive 🦟A message is emitted but nothing is wrong with the code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions