Skip to content

Extend docstring-missing-exception to empty exception description (DOC501) #14494

@sbrugman

Description

@sbrugman

The rule that checks missing documentation for parameters considers empty descriptions as undocumented (undocumented-param, DOC501).
We have a similar rule for exceptions, which considers empty descriptions as documented (docstring-missing-exception, D417).

This example only errors for DOC501:

def func1(arg1: str, arg2: int) -> int:
    """

    Args:
        arg1:
        arg2:

    Raises:
        ValueError:
    """
    try:
        return int(arg1) + arg2
    except:
        raise ValueError("msg")
 ruff check --select D417,DOC501 --preview example.py

Proposal: modify D417 to report an error for empty exception descriptions.

Alternative solution: split undocumented and empty/missing into two separate rules.

This behaviour is especially useful when docstring stubs are auto-generated (#14492)

Metadata

Metadata

Assignees

No one assigned

    Labels

    docstringRelated to docstring linting or formattingruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions