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

[pydoclint] DOC502 should detect re-raised exceptions #12630

Closed
edgarrmondragon opened this issue Aug 2, 2024 · 0 comments · Fixed by #12639
Closed

[pydoclint] DOC502 should detect re-raised exceptions #12630

edgarrmondragon opened this issue Aug 2, 2024 · 0 comments · Fixed by #12639
Assignees
Labels
bug Something isn't working docstring Related to docstring linting or formatting

Comments

@edgarrmondragon
Copy link
Contributor

edgarrmondragon commented Aug 2, 2024

Consider

# repro_DOC.py

def my_func(arg: int) -> int:
    """Doer of things.

    Args:
        arg (int): The number to be doubled.

    Returns:
        int: The doubled number.

    Raises:
        TypeError: If arg cannot be multiplied by 2.
    """
    try:
        return arg * 2
    except TypeError:
        print("arg should be an integer")
        raise

pydoclint correctly detects the exception is re-reraised:

$ pydoclint --style=google repro_DOC.py
Loading config from user-specified .toml file: pyproject.toml
No config found in pyproject.toml.
Skipping files that match this pattern: \.git|\.tox
repro_DOC.py
🎉 No violations 🎉

Ruff does not

$ ruff check --select DOC repro_DOC.py
repro_DOC.py:12:1: DOC502 Raised exception is not explicitly raised: `TypeError`
   |
 7 |           arg (int): The number to be doubled.
 8 |   
 9 | /     Raises:
10 | |         TypeError: If arg cannot be multiplied by 2.
11 | |     """
   | |____^ DOC502
12 |       try:
13 |           return arg * 2
   |
@edgarrmondragon edgarrmondragon changed the title [pydoclint [pydoclint] DOC502 should detect re-raised exceptions Aug 2, 2024
@AlexWaygood AlexWaygood added bug Something isn't working docstring Related to docstring linting or formatting labels Aug 2, 2024
@AlexWaygood AlexWaygood self-assigned this Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docstring Related to docstring linting or formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants