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
|
Consider
pydoclintcorrectly detects the exception is re-reraised:Ruff does not