Skip to content
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

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

Open
sbrugman opened this issue Nov 20, 2024 · 0 comments · May be fixed by #14496
Open

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

sbrugman opened this issue Nov 20, 2024 · 0 comments · May be fixed by #14496
Labels
docstring Related to docstring linting or formatting rule Implementing or modifying a lint rule

Comments

@sbrugman
Copy link
Contributor

sbrugman commented Nov 20, 2024

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)

@AlexWaygood AlexWaygood added rule Implementing or modifying a lint rule docstring Related to docstring linting or formatting labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docstring Related to docstring linting or formatting rule Implementing or modifying a lint rule
Projects
None yet
2 participants