Describe the bug
DOC501 rule violation when the docstring includes the exception.
ruff==0.5.5
python==3.12.4
Command: ruff check --preview --select DOC
No pyproject.toml or other configuration than what's shown here.
Steps to reproduce
Sample file to test against.
class Foo:
def __init__(self, bar, zap):
self.bar = bar
self.zap = zap
def get_bar(self) -> str:
"""Print and return bar.
Raises:
ValueError: bar is not bar.
Returns:
str: bar value.
"""
print(self.bar)
if self.bar != "bar":
raise ValueError(self.bar)
return self.bar
Expected behavior
No violations.
Running pydoclint --style=google test.py gives the expected no violation result.
Debug logs
test.py:17:19: DOC501 Raised exception `ValueError` missing from docstring
|
15 | print(self.bar)
16 | if self.bar != "bar":
17 | raise ValueError(self.bar)
| ^^^^^^^^^^^^^^^^^^^^ DOC501
18 | return self.bar
|
Notes
Adding an argument to Foo.get_bar and adding that to the docstring then makes the DOC501 violation go away. Example below:
def get_bar(self, x: str) -> str:
"""Print and return bar.
Args:
x (str): A dummy value.
Raises:
ValueError: bar is not bar.
Returns:
str: bar value
"""
print(self.bar)
if self.bar != "bar":
raise ValueError(self.bar)
return self.bar
Describe the bug
DOC501 rule violation when the docstring includes the exception.
ruff==0.5.5
python==3.12.4
Command:
ruff check --preview --select DOCNo pyproject.toml or other configuration than what's shown here.
Steps to reproduce
Sample file to test against.
Expected behavior
No violations.
Running
pydoclint --style=google test.pygives the expected no violation result.Debug logs
Notes
Adding an argument to Foo.get_bar and adding that to the docstring then makes the DOC501 violation go away. Example below: