Skip to content

docparams should support missing type documentation when type comments are used #6287

@AWhetter

Description

@AWhetter

Current problem

When running pylint (pylint --disable=all --enable=missing-type-doc --load-plugins=pylint.extensions.docparams code.py) with the following code, no errors are displayed:

def variant(node: str) -> list[str]:
    """Get the variants for the given `node`.

    Args:
        node: The node to get the variants for.

    Returns:
        The available variants.

    """
    return ["hi"]

However when type comments are used, a missing-type-doc warning is shown:

def variant(node):
    # type: (str) -> list[str]
    """Get the variants for the given `node`.

    Args:
        node: The node to get the variants for.

    Returns:
        The available variants.

    """
    return ["hi"]

Desired solution

Ideally docparams would allow type comments to count as type documentation, just like regular type annotations are allowed.
This will require changes on these lines: https://github.com/PyCQA/pylint/blob/a6cb836da56b051cdc0d584d726fb7579415cb54/pylint/extensions/docparams.py#L560-L563

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions