-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingpreviewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
docstring-extraneous-exception (DOC502) reports a false positive when an exception mentioned in the docstring is caught and explicitly reraised (i.e. raise e or raise e from None, assuming e is bound in the except clause and not rebound before it is raised). It correctly ignores implicit reraising (i.e. just raise) of a documented exception. The upstream implementation in pydoclint gets it right both ways. Example:
$ cat >doc502.py <<'# EOF'
def f():
"""Do nothing.
Raises
------
OSError
If the OS errors.
"""
try:
pass
except OSError as e:
raise e
# EOF
$ ruff --isolated check doc502.py --select DOC502 --preview --output-format concise -q
doc502.py:2:5: DOC502 Raised exception is not explicitly raised: `OSError`
$ pydoclint doc502.py
Skipping files that match this pattern: \.git|\.tox
doc502.py
🎉 No violations 🎉Version
ruff 0.14.1 (2bffef5 2025-10-16)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpreviewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule