mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
Add DOC501 tests in package __init__.py
This commit is contained in:
parent
e1b10aae5c
commit
1c6c43b7b7
11 changed files with 958 additions and 383 deletions
|
@ -29,6 +29,26 @@ def calculate_speed(distance: float, time: float) -> float:
|
|||
raise FasterThanLightError from exc
|
||||
|
||||
|
||||
# OK - fully qualified path
|
||||
def calculate_speed(distance: float, time: float) -> float:
|
||||
"""Calculate speed as distance divided by time.
|
||||
|
||||
Args:
|
||||
distance: Distance traveled.
|
||||
time: Time spent traveling.
|
||||
|
||||
Returns:
|
||||
Speed as distance divided by time.
|
||||
|
||||
Raises:
|
||||
DOC501_google.FasterThanLightError: If speed is greater than the speed of light.
|
||||
"""
|
||||
try:
|
||||
return distance / time
|
||||
except ZeroDivisionError as exc:
|
||||
raise FasterThanLightError from exc
|
||||
|
||||
|
||||
# DOC501
|
||||
def calculate_speed(distance: float, time: float) -> float:
|
||||
"""Calculate speed as distance divided by time.
|
||||
|
|
|
@ -30,6 +30,34 @@ def calculate_speed(distance: float, time: float) -> float:
|
|||
raise FasterThanLightError from exc
|
||||
|
||||
|
||||
# OK - fully qualified path
|
||||
def calculate_speed(distance: float, time: float) -> float:
|
||||
"""
|
||||
Calculate speed as distance divided by time.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
distance : float
|
||||
Distance traveled.
|
||||
time : float
|
||||
Time spent traveling.
|
||||
|
||||
Returns
|
||||
-------
|
||||
float
|
||||
Speed as distance divided by time.
|
||||
|
||||
Raises
|
||||
------
|
||||
DOC501_numpy.FasterThanLightError
|
||||
If speed is greater than the speed of light.
|
||||
"""
|
||||
try:
|
||||
return distance / time
|
||||
except ZeroDivisionError as exc:
|
||||
raise FasterThanLightError from exc
|
||||
|
||||
|
||||
# DOC501
|
||||
def calculate_speed(distance: float, time: float) -> float:
|
||||
"""
|
||||
|
|
|
@ -12,7 +12,7 @@ mod tests {
|
|||
use crate::registry::Rule;
|
||||
use crate::rules::pydocstyle;
|
||||
use crate::rules::pydocstyle::settings::Convention;
|
||||
use crate::test::test_path;
|
||||
use crate::test::{test_path, test_path_as_package_init};
|
||||
use crate::{assert_diagnostics, settings};
|
||||
|
||||
use super::settings::Settings;
|
||||
|
@ -28,15 +28,29 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(Rule::DocstringMissingReturns, Path::new("DOC201_google.py"))]
|
||||
#[test_case(Rule::DocstringExtraneousReturns, Path::new("DOC202_google.py"))]
|
||||
#[test_case(Rule::DocstringMissingYields, Path::new("DOC402_google.py"))]
|
||||
#[test_case(Rule::DocstringExtraneousYields, Path::new("DOC403_google.py"))]
|
||||
#[test_case(Rule::DocstringMissingException, Path::new("DOC501_google.py"))]
|
||||
#[test_case(Rule::DocstringExtraneousException, Path::new("DOC502_google.py"))]
|
||||
fn rules_google_style(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.name(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
#[test_case(Rule::DocstringMissingReturns, Path::new("DOC201_google.py"), false)]
|
||||
#[test_case(Rule::DocstringExtraneousReturns, Path::new("DOC202_google.py"), false)]
|
||||
#[test_case(Rule::DocstringMissingYields, Path::new("DOC402_google.py"), false)]
|
||||
#[test_case(Rule::DocstringExtraneousYields, Path::new("DOC403_google.py"), false)]
|
||||
#[test_case(Rule::DocstringMissingException, Path::new("DOC501_google.py"), false)]
|
||||
#[test_case(Rule::DocstringMissingException, Path::new("DOC501_google.py"), true)]
|
||||
#[test_case(
|
||||
Rule::DocstringExtraneousException,
|
||||
Path::new("DOC502_google.py"),
|
||||
false
|
||||
)]
|
||||
fn rules_google_style(rule_code: Rule, path: &Path, in_package: bool) -> Result<()> {
|
||||
let test = match in_package {
|
||||
true => test_path_as_package_init,
|
||||
false => test_path,
|
||||
};
|
||||
let snapshot = format!(
|
||||
"{}_{}{}",
|
||||
rule_code.name(),
|
||||
path.to_string_lossy(),
|
||||
if in_package { "_package" } else { "" }
|
||||
);
|
||||
let diagnostics = test(
|
||||
Path::new("pydoclint").join(path).as_path(),
|
||||
&settings::LinterSettings {
|
||||
pydocstyle: pydocstyle::settings::Settings {
|
||||
|
@ -50,15 +64,29 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(Rule::DocstringMissingReturns, Path::new("DOC201_numpy.py"))]
|
||||
#[test_case(Rule::DocstringExtraneousReturns, Path::new("DOC202_numpy.py"))]
|
||||
#[test_case(Rule::DocstringMissingYields, Path::new("DOC402_numpy.py"))]
|
||||
#[test_case(Rule::DocstringExtraneousYields, Path::new("DOC403_numpy.py"))]
|
||||
#[test_case(Rule::DocstringMissingException, Path::new("DOC501_numpy.py"))]
|
||||
#[test_case(Rule::DocstringExtraneousException, Path::new("DOC502_numpy.py"))]
|
||||
fn rules_numpy_style(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.name(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
#[test_case(Rule::DocstringMissingReturns, Path::new("DOC201_numpy.py"), false)]
|
||||
#[test_case(Rule::DocstringExtraneousReturns, Path::new("DOC202_numpy.py"), false)]
|
||||
#[test_case(Rule::DocstringMissingYields, Path::new("DOC402_numpy.py"), false)]
|
||||
#[test_case(Rule::DocstringExtraneousYields, Path::new("DOC403_numpy.py"), false)]
|
||||
#[test_case(Rule::DocstringMissingException, Path::new("DOC501_numpy.py"), false)]
|
||||
#[test_case(Rule::DocstringMissingException, Path::new("DOC501_numpy.py"), true)]
|
||||
#[test_case(
|
||||
Rule::DocstringExtraneousException,
|
||||
Path::new("DOC502_numpy.py"),
|
||||
false
|
||||
)]
|
||||
fn rules_numpy_style(rule_code: Rule, path: &Path, in_package: bool) -> Result<()> {
|
||||
let test = match in_package {
|
||||
true => test_path_as_package_init,
|
||||
false => test_path,
|
||||
};
|
||||
let snapshot = format!(
|
||||
"{}_{}{}",
|
||||
rule_code.name(),
|
||||
path.to_string_lossy(),
|
||||
if in_package { "_package" } else { "" }
|
||||
);
|
||||
let diagnostics = test(
|
||||
Path::new("pydoclint").join(path).as_path(),
|
||||
&settings::LinterSettings {
|
||||
pydocstyle: pydocstyle::settings::Settings {
|
||||
|
@ -72,16 +100,26 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(Rule::DocstringMissingReturns, Path::new("DOC201_google.py"))]
|
||||
#[test_case(Rule::DocstringMissingYields, Path::new("DOC402_google.py"))]
|
||||
#[test_case(Rule::DocstringMissingException, Path::new("DOC501_google.py"))]
|
||||
fn rules_google_style_ignore_one_line(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
#[test_case(Rule::DocstringMissingReturns, Path::new("DOC201_google.py"), false)]
|
||||
#[test_case(Rule::DocstringMissingYields, Path::new("DOC402_google.py"), false)]
|
||||
#[test_case(Rule::DocstringMissingException, Path::new("DOC501_google.py"), false)]
|
||||
#[test_case(Rule::DocstringMissingException, Path::new("DOC501_google.py"), true)]
|
||||
fn rules_google_style_ignore_one_line(
|
||||
rule_code: Rule,
|
||||
path: &Path,
|
||||
in_package: bool,
|
||||
) -> Result<()> {
|
||||
let test = match in_package {
|
||||
true => test_path_as_package_init,
|
||||
false => test_path,
|
||||
};
|
||||
let snapshot = format!(
|
||||
"{}_{}_ignore_one_line",
|
||||
"{}_{}{}_ignore_one_line",
|
||||
rule_code.name(),
|
||||
path.to_string_lossy()
|
||||
path.to_string_lossy(),
|
||||
if in_package { "_package" } else { "" }
|
||||
);
|
||||
let diagnostics = test_path(
|
||||
let diagnostics = test(
|
||||
Path::new("pydoclint").join(path).as_path(),
|
||||
&settings::LinterSettings {
|
||||
pydoclint: Settings {
|
||||
|
|
|
@ -1,159 +1,159 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/pydoclint/mod.rs
|
||||
---
|
||||
DOC501_google.py:34:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
DOC501_google.py:54:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
32 | # DOC501
|
||||
33 | def calculate_speed(distance: float, time: float) -> float:
|
||||
34 | / """Calculate speed as distance divided by time.
|
||||
35 | |
|
||||
36 | | Args:
|
||||
37 | | distance: Distance traveled.
|
||||
38 | | time: Time spent traveling.
|
||||
39 | |
|
||||
40 | | Returns:
|
||||
41 | | Speed as distance divided by time.
|
||||
42 | | """
|
||||
52 | # DOC501
|
||||
53 | def calculate_speed(distance: float, time: float) -> float:
|
||||
54 | / """Calculate speed as distance divided by time.
|
||||
55 | |
|
||||
56 | | Args:
|
||||
57 | | distance: Distance traveled.
|
||||
58 | | time: Time spent traveling.
|
||||
59 | |
|
||||
60 | | Returns:
|
||||
61 | | Speed as distance divided by time.
|
||||
62 | | """
|
||||
| |_______^ DOC501
|
||||
43 | try:
|
||||
44 | return distance / time
|
||||
63 | try:
|
||||
64 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
DOC501_google.py:51:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
DOC501_google.py:71:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
49 | # DOC501
|
||||
50 | def calculate_speed(distance: float, time: float) -> float:
|
||||
51 | / """Calculate speed as distance divided by time.
|
||||
52 | |
|
||||
53 | | Args:
|
||||
54 | | distance: Distance traveled.
|
||||
55 | | time: Time spent traveling.
|
||||
56 | |
|
||||
57 | | Returns:
|
||||
58 | | Speed as distance divided by time.
|
||||
59 | | """
|
||||
69 | # DOC501
|
||||
70 | def calculate_speed(distance: float, time: float) -> float:
|
||||
71 | / """Calculate speed as distance divided by time.
|
||||
72 | |
|
||||
73 | | Args:
|
||||
74 | | distance: Distance traveled.
|
||||
75 | | time: Time spent traveling.
|
||||
76 | |
|
||||
77 | | Returns:
|
||||
78 | | Speed as distance divided by time.
|
||||
79 | | """
|
||||
| |_______^ DOC501
|
||||
60 | try:
|
||||
61 | return distance / time
|
||||
80 | try:
|
||||
81 | return distance / time
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
||||
DOC501_google.py:51:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
DOC501_google.py:71:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
49 | # DOC501
|
||||
50 | def calculate_speed(distance: float, time: float) -> float:
|
||||
51 | / """Calculate speed as distance divided by time.
|
||||
52 | |
|
||||
53 | | Args:
|
||||
54 | | distance: Distance traveled.
|
||||
55 | | time: Time spent traveling.
|
||||
56 | |
|
||||
57 | | Returns:
|
||||
58 | | Speed as distance divided by time.
|
||||
59 | | """
|
||||
69 | # DOC501
|
||||
70 | def calculate_speed(distance: float, time: float) -> float:
|
||||
71 | / """Calculate speed as distance divided by time.
|
||||
72 | |
|
||||
73 | | Args:
|
||||
74 | | distance: Distance traveled.
|
||||
75 | | time: Time spent traveling.
|
||||
76 | |
|
||||
77 | | Returns:
|
||||
78 | | Speed as distance divided by time.
|
||||
79 | | """
|
||||
| |_______^ DOC501
|
||||
60 | try:
|
||||
61 | return distance / time
|
||||
80 | try:
|
||||
81 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
DOC501_google.py:106:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
DOC501_google.py:126:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
|
|
||||
104 | # DOC501
|
||||
105 | def calculate_speed(distance: float, time: float) -> float:
|
||||
106 | / """Calculate speed as distance divided by time.
|
||||
107 | |
|
||||
108 | | Args:
|
||||
109 | | distance: Distance traveled.
|
||||
110 | | time: Time spent traveling.
|
||||
111 | |
|
||||
112 | | Returns:
|
||||
113 | | Speed as distance divided by time.
|
||||
114 | | """
|
||||
124 | # DOC501
|
||||
125 | def calculate_speed(distance: float, time: float) -> float:
|
||||
126 | / """Calculate speed as distance divided by time.
|
||||
127 | |
|
||||
128 | | Args:
|
||||
129 | | distance: Distance traveled.
|
||||
130 | | time: Time spent traveling.
|
||||
131 | |
|
||||
132 | | Returns:
|
||||
133 | | Speed as distance divided by time.
|
||||
134 | | """
|
||||
| |_______^ DOC501
|
||||
115 | raise AnotherError
|
||||
135 | raise AnotherError
|
||||
|
|
||||
= help: Add `AnotherError` to the docstring
|
||||
|
||||
DOC501_google.py:120:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
DOC501_google.py:140:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
|
|
||||
118 | # DOC501
|
||||
119 | def calculate_speed(distance: float, time: float) -> float:
|
||||
120 | / """Calculate speed as distance divided by time.
|
||||
121 | |
|
||||
122 | | Args:
|
||||
123 | | distance: Distance traveled.
|
||||
124 | | time: Time spent traveling.
|
||||
125 | |
|
||||
126 | | Returns:
|
||||
127 | | Speed as distance divided by time.
|
||||
128 | | """
|
||||
138 | # DOC501
|
||||
139 | def calculate_speed(distance: float, time: float) -> float:
|
||||
140 | / """Calculate speed as distance divided by time.
|
||||
141 | |
|
||||
142 | | Args:
|
||||
143 | | distance: Distance traveled.
|
||||
144 | | time: Time spent traveling.
|
||||
145 | |
|
||||
146 | | Returns:
|
||||
147 | | Speed as distance divided by time.
|
||||
148 | | """
|
||||
| |_______^ DOC501
|
||||
129 | raise AnotherError()
|
||||
149 | raise AnotherError()
|
||||
|
|
||||
= help: Add `AnotherError` to the docstring
|
||||
|
||||
DOC501_google.py:134:5: DOC501 Raised exception `SomeError` missing from docstring
|
||||
DOC501_google.py:154:5: DOC501 Raised exception `SomeError` missing from docstring
|
||||
|
|
||||
132 | # DOC501
|
||||
133 | def foo(bar: int):
|
||||
134 | / """Foo.
|
||||
135 | |
|
||||
136 | | Args:
|
||||
137 | | bar: Bar.
|
||||
138 | | """
|
||||
152 | # DOC501
|
||||
153 | def foo(bar: int):
|
||||
154 | / """Foo.
|
||||
155 | |
|
||||
156 | | Args:
|
||||
157 | | bar: Bar.
|
||||
158 | | """
|
||||
| |_______^ DOC501
|
||||
139 | raise something.SomeError
|
||||
159 | raise something.SomeError
|
||||
|
|
||||
= help: Add `SomeError` to the docstring
|
||||
|
||||
DOC501_google.py:197:5: DOC501 Raised exception `ZeroDivisionError` missing from docstring
|
||||
DOC501_google.py:217:5: DOC501 Raised exception `ZeroDivisionError` missing from docstring
|
||||
|
|
||||
195 | # DOC501
|
||||
196 | def calculate_speed(distance: float, time: float) -> float:
|
||||
197 | / """Calculate speed as distance divided by time.
|
||||
198 | |
|
||||
199 | | Args:
|
||||
200 | | distance: Distance traveled.
|
||||
201 | | time: Time spent traveling.
|
||||
202 | |
|
||||
203 | | Returns:
|
||||
204 | | Speed as distance divided by time.
|
||||
205 | |
|
||||
206 | | Raises:
|
||||
207 | | TypeError: if you didn't pass a number for both parameters
|
||||
208 | | """
|
||||
215 | # DOC501
|
||||
216 | def calculate_speed(distance: float, time: float) -> float:
|
||||
217 | / """Calculate speed as distance divided by time.
|
||||
218 | |
|
||||
219 | | Args:
|
||||
220 | | distance: Distance traveled.
|
||||
221 | | time: Time spent traveling.
|
||||
222 | |
|
||||
223 | | Returns:
|
||||
224 | | Speed as distance divided by time.
|
||||
225 | |
|
||||
226 | | Raises:
|
||||
227 | | TypeError: if you didn't pass a number for both parameters
|
||||
228 | | """
|
||||
| |_______^ DOC501
|
||||
209 | try:
|
||||
210 | return distance / time
|
||||
229 | try:
|
||||
230 | return distance / time
|
||||
|
|
||||
= help: Add `ZeroDivisionError` to the docstring
|
||||
|
||||
DOC501_google.py:238:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
DOC501_google.py:258:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
|
|
||||
237 | def foo():
|
||||
238 | / """Foo.
|
||||
239 | |
|
||||
240 | | Returns:
|
||||
241 | | 42: int.
|
||||
242 | | """
|
||||
257 | def foo():
|
||||
258 | / """Foo.
|
||||
259 | |
|
||||
260 | | Returns:
|
||||
261 | | 42: int.
|
||||
262 | | """
|
||||
| |_______^ DOC501
|
||||
243 | if True:
|
||||
244 | raise TypeError # DOC501
|
||||
263 | if True:
|
||||
264 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
DOC501_google.py:238:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
DOC501_google.py:258:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
237 | def foo():
|
||||
238 | / """Foo.
|
||||
239 | |
|
||||
240 | | Returns:
|
||||
241 | | 42: int.
|
||||
242 | | """
|
||||
257 | def foo():
|
||||
258 | / """Foo.
|
||||
259 | |
|
||||
260 | | Returns:
|
||||
261 | | 42: int.
|
||||
262 | | """
|
||||
| |_______^ DOC501
|
||||
243 | if True:
|
||||
244 | raise TypeError # DOC501
|
||||
263 | if True:
|
||||
264 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
|
|
@ -1,159 +1,159 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/pydoclint/mod.rs
|
||||
---
|
||||
DOC501_google.py:34:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
DOC501_google.py:54:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
32 | # DOC501
|
||||
33 | def calculate_speed(distance: float, time: float) -> float:
|
||||
34 | / """Calculate speed as distance divided by time.
|
||||
35 | |
|
||||
36 | | Args:
|
||||
37 | | distance: Distance traveled.
|
||||
38 | | time: Time spent traveling.
|
||||
39 | |
|
||||
40 | | Returns:
|
||||
41 | | Speed as distance divided by time.
|
||||
42 | | """
|
||||
52 | # DOC501
|
||||
53 | def calculate_speed(distance: float, time: float) -> float:
|
||||
54 | / """Calculate speed as distance divided by time.
|
||||
55 | |
|
||||
56 | | Args:
|
||||
57 | | distance: Distance traveled.
|
||||
58 | | time: Time spent traveling.
|
||||
59 | |
|
||||
60 | | Returns:
|
||||
61 | | Speed as distance divided by time.
|
||||
62 | | """
|
||||
| |_______^ DOC501
|
||||
43 | try:
|
||||
44 | return distance / time
|
||||
63 | try:
|
||||
64 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
DOC501_google.py:51:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
DOC501_google.py:71:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
49 | # DOC501
|
||||
50 | def calculate_speed(distance: float, time: float) -> float:
|
||||
51 | / """Calculate speed as distance divided by time.
|
||||
52 | |
|
||||
53 | | Args:
|
||||
54 | | distance: Distance traveled.
|
||||
55 | | time: Time spent traveling.
|
||||
56 | |
|
||||
57 | | Returns:
|
||||
58 | | Speed as distance divided by time.
|
||||
59 | | """
|
||||
69 | # DOC501
|
||||
70 | def calculate_speed(distance: float, time: float) -> float:
|
||||
71 | / """Calculate speed as distance divided by time.
|
||||
72 | |
|
||||
73 | | Args:
|
||||
74 | | distance: Distance traveled.
|
||||
75 | | time: Time spent traveling.
|
||||
76 | |
|
||||
77 | | Returns:
|
||||
78 | | Speed as distance divided by time.
|
||||
79 | | """
|
||||
| |_______^ DOC501
|
||||
60 | try:
|
||||
61 | return distance / time
|
||||
80 | try:
|
||||
81 | return distance / time
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
||||
DOC501_google.py:51:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
DOC501_google.py:71:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
49 | # DOC501
|
||||
50 | def calculate_speed(distance: float, time: float) -> float:
|
||||
51 | / """Calculate speed as distance divided by time.
|
||||
52 | |
|
||||
53 | | Args:
|
||||
54 | | distance: Distance traveled.
|
||||
55 | | time: Time spent traveling.
|
||||
56 | |
|
||||
57 | | Returns:
|
||||
58 | | Speed as distance divided by time.
|
||||
59 | | """
|
||||
69 | # DOC501
|
||||
70 | def calculate_speed(distance: float, time: float) -> float:
|
||||
71 | / """Calculate speed as distance divided by time.
|
||||
72 | |
|
||||
73 | | Args:
|
||||
74 | | distance: Distance traveled.
|
||||
75 | | time: Time spent traveling.
|
||||
76 | |
|
||||
77 | | Returns:
|
||||
78 | | Speed as distance divided by time.
|
||||
79 | | """
|
||||
| |_______^ DOC501
|
||||
60 | try:
|
||||
61 | return distance / time
|
||||
80 | try:
|
||||
81 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
DOC501_google.py:106:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
DOC501_google.py:126:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
|
|
||||
104 | # DOC501
|
||||
105 | def calculate_speed(distance: float, time: float) -> float:
|
||||
106 | / """Calculate speed as distance divided by time.
|
||||
107 | |
|
||||
108 | | Args:
|
||||
109 | | distance: Distance traveled.
|
||||
110 | | time: Time spent traveling.
|
||||
111 | |
|
||||
112 | | Returns:
|
||||
113 | | Speed as distance divided by time.
|
||||
114 | | """
|
||||
124 | # DOC501
|
||||
125 | def calculate_speed(distance: float, time: float) -> float:
|
||||
126 | / """Calculate speed as distance divided by time.
|
||||
127 | |
|
||||
128 | | Args:
|
||||
129 | | distance: Distance traveled.
|
||||
130 | | time: Time spent traveling.
|
||||
131 | |
|
||||
132 | | Returns:
|
||||
133 | | Speed as distance divided by time.
|
||||
134 | | """
|
||||
| |_______^ DOC501
|
||||
115 | raise AnotherError
|
||||
135 | raise AnotherError
|
||||
|
|
||||
= help: Add `AnotherError` to the docstring
|
||||
|
||||
DOC501_google.py:120:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
DOC501_google.py:140:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
|
|
||||
118 | # DOC501
|
||||
119 | def calculate_speed(distance: float, time: float) -> float:
|
||||
120 | / """Calculate speed as distance divided by time.
|
||||
121 | |
|
||||
122 | | Args:
|
||||
123 | | distance: Distance traveled.
|
||||
124 | | time: Time spent traveling.
|
||||
125 | |
|
||||
126 | | Returns:
|
||||
127 | | Speed as distance divided by time.
|
||||
128 | | """
|
||||
138 | # DOC501
|
||||
139 | def calculate_speed(distance: float, time: float) -> float:
|
||||
140 | / """Calculate speed as distance divided by time.
|
||||
141 | |
|
||||
142 | | Args:
|
||||
143 | | distance: Distance traveled.
|
||||
144 | | time: Time spent traveling.
|
||||
145 | |
|
||||
146 | | Returns:
|
||||
147 | | Speed as distance divided by time.
|
||||
148 | | """
|
||||
| |_______^ DOC501
|
||||
129 | raise AnotherError()
|
||||
149 | raise AnotherError()
|
||||
|
|
||||
= help: Add `AnotherError` to the docstring
|
||||
|
||||
DOC501_google.py:134:5: DOC501 Raised exception `SomeError` missing from docstring
|
||||
DOC501_google.py:154:5: DOC501 Raised exception `SomeError` missing from docstring
|
||||
|
|
||||
132 | # DOC501
|
||||
133 | def foo(bar: int):
|
||||
134 | / """Foo.
|
||||
135 | |
|
||||
136 | | Args:
|
||||
137 | | bar: Bar.
|
||||
138 | | """
|
||||
152 | # DOC501
|
||||
153 | def foo(bar: int):
|
||||
154 | / """Foo.
|
||||
155 | |
|
||||
156 | | Args:
|
||||
157 | | bar: Bar.
|
||||
158 | | """
|
||||
| |_______^ DOC501
|
||||
139 | raise something.SomeError
|
||||
159 | raise something.SomeError
|
||||
|
|
||||
= help: Add `SomeError` to the docstring
|
||||
|
||||
DOC501_google.py:197:5: DOC501 Raised exception `ZeroDivisionError` missing from docstring
|
||||
DOC501_google.py:217:5: DOC501 Raised exception `ZeroDivisionError` missing from docstring
|
||||
|
|
||||
195 | # DOC501
|
||||
196 | def calculate_speed(distance: float, time: float) -> float:
|
||||
197 | / """Calculate speed as distance divided by time.
|
||||
198 | |
|
||||
199 | | Args:
|
||||
200 | | distance: Distance traveled.
|
||||
201 | | time: Time spent traveling.
|
||||
202 | |
|
||||
203 | | Returns:
|
||||
204 | | Speed as distance divided by time.
|
||||
205 | |
|
||||
206 | | Raises:
|
||||
207 | | TypeError: if you didn't pass a number for both parameters
|
||||
208 | | """
|
||||
215 | # DOC501
|
||||
216 | def calculate_speed(distance: float, time: float) -> float:
|
||||
217 | / """Calculate speed as distance divided by time.
|
||||
218 | |
|
||||
219 | | Args:
|
||||
220 | | distance: Distance traveled.
|
||||
221 | | time: Time spent traveling.
|
||||
222 | |
|
||||
223 | | Returns:
|
||||
224 | | Speed as distance divided by time.
|
||||
225 | |
|
||||
226 | | Raises:
|
||||
227 | | TypeError: if you didn't pass a number for both parameters
|
||||
228 | | """
|
||||
| |_______^ DOC501
|
||||
209 | try:
|
||||
210 | return distance / time
|
||||
229 | try:
|
||||
230 | return distance / time
|
||||
|
|
||||
= help: Add `ZeroDivisionError` to the docstring
|
||||
|
||||
DOC501_google.py:238:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
DOC501_google.py:258:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
|
|
||||
237 | def foo():
|
||||
238 | / """Foo.
|
||||
239 | |
|
||||
240 | | Returns:
|
||||
241 | | 42: int.
|
||||
242 | | """
|
||||
257 | def foo():
|
||||
258 | / """Foo.
|
||||
259 | |
|
||||
260 | | Returns:
|
||||
261 | | 42: int.
|
||||
262 | | """
|
||||
| |_______^ DOC501
|
||||
243 | if True:
|
||||
244 | raise TypeError # DOC501
|
||||
263 | if True:
|
||||
264 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
DOC501_google.py:238:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
DOC501_google.py:258:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
237 | def foo():
|
||||
238 | / """Foo.
|
||||
239 | |
|
||||
240 | | Returns:
|
||||
241 | | 42: int.
|
||||
242 | | """
|
||||
257 | def foo():
|
||||
258 | / """Foo.
|
||||
259 | |
|
||||
260 | | Returns:
|
||||
261 | | 42: int.
|
||||
262 | | """
|
||||
| |_______^ DOC501
|
||||
243 | if True:
|
||||
244 | raise TypeError # DOC501
|
||||
263 | if True:
|
||||
264 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/pydoclint/mod.rs
|
||||
---
|
||||
__init__.py:54:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
52 | # DOC501
|
||||
53 | def calculate_speed(distance: float, time: float) -> float:
|
||||
54 | / """Calculate speed as distance divided by time.
|
||||
55 | |
|
||||
56 | | Args:
|
||||
57 | | distance: Distance traveled.
|
||||
58 | | time: Time spent traveling.
|
||||
59 | |
|
||||
60 | | Returns:
|
||||
61 | | Speed as distance divided by time.
|
||||
62 | | """
|
||||
| |_______^ DOC501
|
||||
63 | try:
|
||||
64 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
__init__.py:71:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
69 | # DOC501
|
||||
70 | def calculate_speed(distance: float, time: float) -> float:
|
||||
71 | / """Calculate speed as distance divided by time.
|
||||
72 | |
|
||||
73 | | Args:
|
||||
74 | | distance: Distance traveled.
|
||||
75 | | time: Time spent traveling.
|
||||
76 | |
|
||||
77 | | Returns:
|
||||
78 | | Speed as distance divided by time.
|
||||
79 | | """
|
||||
| |_______^ DOC501
|
||||
80 | try:
|
||||
81 | return distance / time
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
||||
__init__.py:71:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
69 | # DOC501
|
||||
70 | def calculate_speed(distance: float, time: float) -> float:
|
||||
71 | / """Calculate speed as distance divided by time.
|
||||
72 | |
|
||||
73 | | Args:
|
||||
74 | | distance: Distance traveled.
|
||||
75 | | time: Time spent traveling.
|
||||
76 | |
|
||||
77 | | Returns:
|
||||
78 | | Speed as distance divided by time.
|
||||
79 | | """
|
||||
| |_______^ DOC501
|
||||
80 | try:
|
||||
81 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
__init__.py:126:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
|
|
||||
124 | # DOC501
|
||||
125 | def calculate_speed(distance: float, time: float) -> float:
|
||||
126 | / """Calculate speed as distance divided by time.
|
||||
127 | |
|
||||
128 | | Args:
|
||||
129 | | distance: Distance traveled.
|
||||
130 | | time: Time spent traveling.
|
||||
131 | |
|
||||
132 | | Returns:
|
||||
133 | | Speed as distance divided by time.
|
||||
134 | | """
|
||||
| |_______^ DOC501
|
||||
135 | raise AnotherError
|
||||
|
|
||||
= help: Add `AnotherError` to the docstring
|
||||
|
||||
__init__.py:140:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
|
|
||||
138 | # DOC501
|
||||
139 | def calculate_speed(distance: float, time: float) -> float:
|
||||
140 | / """Calculate speed as distance divided by time.
|
||||
141 | |
|
||||
142 | | Args:
|
||||
143 | | distance: Distance traveled.
|
||||
144 | | time: Time spent traveling.
|
||||
145 | |
|
||||
146 | | Returns:
|
||||
147 | | Speed as distance divided by time.
|
||||
148 | | """
|
||||
| |_______^ DOC501
|
||||
149 | raise AnotherError()
|
||||
|
|
||||
= help: Add `AnotherError` to the docstring
|
||||
|
||||
__init__.py:154:5: DOC501 Raised exception `SomeError` missing from docstring
|
||||
|
|
||||
152 | # DOC501
|
||||
153 | def foo(bar: int):
|
||||
154 | / """Foo.
|
||||
155 | |
|
||||
156 | | Args:
|
||||
157 | | bar: Bar.
|
||||
158 | | """
|
||||
| |_______^ DOC501
|
||||
159 | raise something.SomeError
|
||||
|
|
||||
= help: Add `SomeError` to the docstring
|
||||
|
||||
__init__.py:217:5: DOC501 Raised exception `ZeroDivisionError` missing from docstring
|
||||
|
|
||||
215 | # DOC501
|
||||
216 | def calculate_speed(distance: float, time: float) -> float:
|
||||
217 | / """Calculate speed as distance divided by time.
|
||||
218 | |
|
||||
219 | | Args:
|
||||
220 | | distance: Distance traveled.
|
||||
221 | | time: Time spent traveling.
|
||||
222 | |
|
||||
223 | | Returns:
|
||||
224 | | Speed as distance divided by time.
|
||||
225 | |
|
||||
226 | | Raises:
|
||||
227 | | TypeError: if you didn't pass a number for both parameters
|
||||
228 | | """
|
||||
| |_______^ DOC501
|
||||
229 | try:
|
||||
230 | return distance / time
|
||||
|
|
||||
= help: Add `ZeroDivisionError` to the docstring
|
||||
|
||||
__init__.py:258:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
|
|
||||
257 | def foo():
|
||||
258 | / """Foo.
|
||||
259 | |
|
||||
260 | | Returns:
|
||||
261 | | 42: int.
|
||||
262 | | """
|
||||
| |_______^ DOC501
|
||||
263 | if True:
|
||||
264 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
__init__.py:258:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
257 | def foo():
|
||||
258 | / """Foo.
|
||||
259 | |
|
||||
260 | | Returns:
|
||||
261 | | 42: int.
|
||||
262 | | """
|
||||
| |_______^ DOC501
|
||||
263 | if True:
|
||||
264 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
|
@ -0,0 +1,159 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/pydoclint/mod.rs
|
||||
---
|
||||
__init__.py:54:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
52 | # DOC501
|
||||
53 | def calculate_speed(distance: float, time: float) -> float:
|
||||
54 | / """Calculate speed as distance divided by time.
|
||||
55 | |
|
||||
56 | | Args:
|
||||
57 | | distance: Distance traveled.
|
||||
58 | | time: Time spent traveling.
|
||||
59 | |
|
||||
60 | | Returns:
|
||||
61 | | Speed as distance divided by time.
|
||||
62 | | """
|
||||
| |_______^ DOC501
|
||||
63 | try:
|
||||
64 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
__init__.py:71:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
69 | # DOC501
|
||||
70 | def calculate_speed(distance: float, time: float) -> float:
|
||||
71 | / """Calculate speed as distance divided by time.
|
||||
72 | |
|
||||
73 | | Args:
|
||||
74 | | distance: Distance traveled.
|
||||
75 | | time: Time spent traveling.
|
||||
76 | |
|
||||
77 | | Returns:
|
||||
78 | | Speed as distance divided by time.
|
||||
79 | | """
|
||||
| |_______^ DOC501
|
||||
80 | try:
|
||||
81 | return distance / time
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
||||
__init__.py:71:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
69 | # DOC501
|
||||
70 | def calculate_speed(distance: float, time: float) -> float:
|
||||
71 | / """Calculate speed as distance divided by time.
|
||||
72 | |
|
||||
73 | | Args:
|
||||
74 | | distance: Distance traveled.
|
||||
75 | | time: Time spent traveling.
|
||||
76 | |
|
||||
77 | | Returns:
|
||||
78 | | Speed as distance divided by time.
|
||||
79 | | """
|
||||
| |_______^ DOC501
|
||||
80 | try:
|
||||
81 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
__init__.py:126:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
|
|
||||
124 | # DOC501
|
||||
125 | def calculate_speed(distance: float, time: float) -> float:
|
||||
126 | / """Calculate speed as distance divided by time.
|
||||
127 | |
|
||||
128 | | Args:
|
||||
129 | | distance: Distance traveled.
|
||||
130 | | time: Time spent traveling.
|
||||
131 | |
|
||||
132 | | Returns:
|
||||
133 | | Speed as distance divided by time.
|
||||
134 | | """
|
||||
| |_______^ DOC501
|
||||
135 | raise AnotherError
|
||||
|
|
||||
= help: Add `AnotherError` to the docstring
|
||||
|
||||
__init__.py:140:5: DOC501 Raised exception `AnotherError` missing from docstring
|
||||
|
|
||||
138 | # DOC501
|
||||
139 | def calculate_speed(distance: float, time: float) -> float:
|
||||
140 | / """Calculate speed as distance divided by time.
|
||||
141 | |
|
||||
142 | | Args:
|
||||
143 | | distance: Distance traveled.
|
||||
144 | | time: Time spent traveling.
|
||||
145 | |
|
||||
146 | | Returns:
|
||||
147 | | Speed as distance divided by time.
|
||||
148 | | """
|
||||
| |_______^ DOC501
|
||||
149 | raise AnotherError()
|
||||
|
|
||||
= help: Add `AnotherError` to the docstring
|
||||
|
||||
__init__.py:154:5: DOC501 Raised exception `SomeError` missing from docstring
|
||||
|
|
||||
152 | # DOC501
|
||||
153 | def foo(bar: int):
|
||||
154 | / """Foo.
|
||||
155 | |
|
||||
156 | | Args:
|
||||
157 | | bar: Bar.
|
||||
158 | | """
|
||||
| |_______^ DOC501
|
||||
159 | raise something.SomeError
|
||||
|
|
||||
= help: Add `SomeError` to the docstring
|
||||
|
||||
__init__.py:217:5: DOC501 Raised exception `ZeroDivisionError` missing from docstring
|
||||
|
|
||||
215 | # DOC501
|
||||
216 | def calculate_speed(distance: float, time: float) -> float:
|
||||
217 | / """Calculate speed as distance divided by time.
|
||||
218 | |
|
||||
219 | | Args:
|
||||
220 | | distance: Distance traveled.
|
||||
221 | | time: Time spent traveling.
|
||||
222 | |
|
||||
223 | | Returns:
|
||||
224 | | Speed as distance divided by time.
|
||||
225 | |
|
||||
226 | | Raises:
|
||||
227 | | TypeError: if you didn't pass a number for both parameters
|
||||
228 | | """
|
||||
| |_______^ DOC501
|
||||
229 | try:
|
||||
230 | return distance / time
|
||||
|
|
||||
= help: Add `ZeroDivisionError` to the docstring
|
||||
|
||||
__init__.py:258:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
|
|
||||
257 | def foo():
|
||||
258 | / """Foo.
|
||||
259 | |
|
||||
260 | | Returns:
|
||||
261 | | 42: int.
|
||||
262 | | """
|
||||
| |_______^ DOC501
|
||||
263 | if True:
|
||||
264 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
__init__.py:258:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
257 | def foo():
|
||||
258 | / """Foo.
|
||||
259 | |
|
||||
260 | | Returns:
|
||||
261 | | 42: int.
|
||||
262 | | """
|
||||
| |_______^ DOC501
|
||||
263 | if True:
|
||||
264 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
|
@ -1,140 +1,140 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/pydoclint/mod.rs
|
||||
---
|
||||
DOC501_numpy.py:35:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
DOC501_numpy.py:63:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
33 | # DOC501
|
||||
34 | def calculate_speed(distance: float, time: float) -> float:
|
||||
35 | / """
|
||||
36 | | Calculate speed as distance divided by time.
|
||||
37 | |
|
||||
38 | | Parameters
|
||||
39 | | ----------
|
||||
40 | | distance : float
|
||||
41 | | Distance traveled.
|
||||
42 | | time : float
|
||||
43 | | Time spent traveling.
|
||||
44 | |
|
||||
45 | | Returns
|
||||
46 | | -------
|
||||
47 | | float
|
||||
48 | | Speed as distance divided by time.
|
||||
49 | | """
|
||||
61 | # DOC501
|
||||
62 | def calculate_speed(distance: float, time: float) -> float:
|
||||
63 | / """
|
||||
64 | | Calculate speed as distance divided by time.
|
||||
65 | |
|
||||
66 | | Parameters
|
||||
67 | | ----------
|
||||
68 | | distance : float
|
||||
69 | | Distance traveled.
|
||||
70 | | time : float
|
||||
71 | | Time spent traveling.
|
||||
72 | |
|
||||
73 | | Returns
|
||||
74 | | -------
|
||||
75 | | float
|
||||
76 | | Speed as distance divided by time.
|
||||
77 | | """
|
||||
| |_______^ DOC501
|
||||
50 | try:
|
||||
51 | return distance / time
|
||||
78 | try:
|
||||
79 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
DOC501_numpy.py:58:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
56 | # DOC501
|
||||
57 | def calculate_speed(distance: float, time: float) -> float:
|
||||
58 | / """
|
||||
59 | | Calculate speed as distance divided by time.
|
||||
60 | |
|
||||
61 | | Parameters
|
||||
62 | | ----------
|
||||
63 | | distance : float
|
||||
64 | | Distance traveled.
|
||||
65 | | time : float
|
||||
66 | | Time spent traveling.
|
||||
67 | |
|
||||
68 | | Returns
|
||||
69 | | -------
|
||||
70 | | float
|
||||
71 | | Speed as distance divided by time.
|
||||
72 | | """
|
||||
| |_______^ DOC501
|
||||
73 | try:
|
||||
74 | return distance / time
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
||||
DOC501_numpy.py:58:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
56 | # DOC501
|
||||
57 | def calculate_speed(distance: float, time: float) -> float:
|
||||
58 | / """
|
||||
59 | | Calculate speed as distance divided by time.
|
||||
60 | |
|
||||
61 | | Parameters
|
||||
62 | | ----------
|
||||
63 | | distance : float
|
||||
64 | | Distance traveled.
|
||||
65 | | time : float
|
||||
66 | | Time spent traveling.
|
||||
67 | |
|
||||
68 | | Returns
|
||||
69 | | -------
|
||||
70 | | float
|
||||
71 | | Speed as distance divided by time.
|
||||
72 | | """
|
||||
| |_______^ DOC501
|
||||
73 | try:
|
||||
74 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
DOC501_numpy.py:83:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
DOC501_numpy.py:86:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
81 | # DOC501
|
||||
82 | def calculate_speed(distance: float, time: float) -> float:
|
||||
83 | / """Calculate speed as distance divided by time.
|
||||
84 | |
|
||||
85 | | ACalculate speed as distance divided by time.
|
||||
86 | |
|
||||
87 | | Parameters
|
||||
88 | | ----------
|
||||
89 | | distance : float
|
||||
90 | | Distance traveled.
|
||||
91 | | time : float
|
||||
92 | | Time spent traveling.
|
||||
93 | |
|
||||
94 | | Returns
|
||||
95 | | -------
|
||||
96 | | float
|
||||
97 | | Speed as distance divided by time.
|
||||
98 | |
|
||||
99 | | Raises
|
||||
100 | | ------
|
||||
101 | | ZeroDivisionError
|
||||
102 | | If attempting to divide by zero.
|
||||
103 | | """
|
||||
84 | # DOC501
|
||||
85 | def calculate_speed(distance: float, time: float) -> float:
|
||||
86 | / """
|
||||
87 | | Calculate speed as distance divided by time.
|
||||
88 | |
|
||||
89 | | Parameters
|
||||
90 | | ----------
|
||||
91 | | distance : float
|
||||
92 | | Distance traveled.
|
||||
93 | | time : float
|
||||
94 | | Time spent traveling.
|
||||
95 | |
|
||||
96 | | Returns
|
||||
97 | | -------
|
||||
98 | | float
|
||||
99 | | Speed as distance divided by time.
|
||||
100 | | """
|
||||
| |_______^ DOC501
|
||||
104 | try:
|
||||
105 | return distance / time
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
DOC501_numpy.py:139:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
|
|
||||
138 | def foo():
|
||||
139 | / """Foo.
|
||||
140 | |
|
||||
141 | | Returns
|
||||
142 | | -------
|
||||
143 | | int
|
||||
144 | | 42
|
||||
145 | | """
|
||||
| |_______^ DOC501
|
||||
146 | if True:
|
||||
147 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
DOC501_numpy.py:139:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
138 | def foo():
|
||||
139 | / """Foo.
|
||||
140 | |
|
||||
141 | | Returns
|
||||
142 | | -------
|
||||
143 | | int
|
||||
144 | | 42
|
||||
145 | | """
|
||||
| |_______^ DOC501
|
||||
146 | if True:
|
||||
147 | raise TypeError # DOC501
|
||||
101 | try:
|
||||
102 | return distance / time
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
||||
DOC501_numpy.py:86:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
84 | # DOC501
|
||||
85 | def calculate_speed(distance: float, time: float) -> float:
|
||||
86 | / """
|
||||
87 | | Calculate speed as distance divided by time.
|
||||
88 | |
|
||||
89 | | Parameters
|
||||
90 | | ----------
|
||||
91 | | distance : float
|
||||
92 | | Distance traveled.
|
||||
93 | | time : float
|
||||
94 | | Time spent traveling.
|
||||
95 | |
|
||||
96 | | Returns
|
||||
97 | | -------
|
||||
98 | | float
|
||||
99 | | Speed as distance divided by time.
|
||||
100 | | """
|
||||
| |_______^ DOC501
|
||||
101 | try:
|
||||
102 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
DOC501_numpy.py:111:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
|
|
||||
109 | # DOC501
|
||||
110 | def calculate_speed(distance: float, time: float) -> float:
|
||||
111 | / """Calculate speed as distance divided by time.
|
||||
112 | |
|
||||
113 | | ACalculate speed as distance divided by time.
|
||||
114 | |
|
||||
115 | | Parameters
|
||||
116 | | ----------
|
||||
117 | | distance : float
|
||||
118 | | Distance traveled.
|
||||
119 | | time : float
|
||||
120 | | Time spent traveling.
|
||||
121 | |
|
||||
122 | | Returns
|
||||
123 | | -------
|
||||
124 | | float
|
||||
125 | | Speed as distance divided by time.
|
||||
126 | |
|
||||
127 | | Raises
|
||||
128 | | ------
|
||||
129 | | ZeroDivisionError
|
||||
130 | | If attempting to divide by zero.
|
||||
131 | | """
|
||||
| |_______^ DOC501
|
||||
132 | try:
|
||||
133 | return distance / time
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
DOC501_numpy.py:167:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
|
|
||||
166 | def foo():
|
||||
167 | / """Foo.
|
||||
168 | |
|
||||
169 | | Returns
|
||||
170 | | -------
|
||||
171 | | int
|
||||
172 | | 42
|
||||
173 | | """
|
||||
| |_______^ DOC501
|
||||
174 | if True:
|
||||
175 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
DOC501_numpy.py:167:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
166 | def foo():
|
||||
167 | / """Foo.
|
||||
168 | |
|
||||
169 | | Returns
|
||||
170 | | -------
|
||||
171 | | int
|
||||
172 | | 42
|
||||
173 | | """
|
||||
| |_______^ DOC501
|
||||
174 | if True:
|
||||
175 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/pydoclint/mod.rs
|
||||
---
|
||||
__init__.py:63:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
61 | # DOC501
|
||||
62 | def calculate_speed(distance: float, time: float) -> float:
|
||||
63 | / """
|
||||
64 | | Calculate speed as distance divided by time.
|
||||
65 | |
|
||||
66 | | Parameters
|
||||
67 | | ----------
|
||||
68 | | distance : float
|
||||
69 | | Distance traveled.
|
||||
70 | | time : float
|
||||
71 | | Time spent traveling.
|
||||
72 | |
|
||||
73 | | Returns
|
||||
74 | | -------
|
||||
75 | | float
|
||||
76 | | Speed as distance divided by time.
|
||||
77 | | """
|
||||
| |_______^ DOC501
|
||||
78 | try:
|
||||
79 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
__init__.py:86:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
84 | # DOC501
|
||||
85 | def calculate_speed(distance: float, time: float) -> float:
|
||||
86 | / """
|
||||
87 | | Calculate speed as distance divided by time.
|
||||
88 | |
|
||||
89 | | Parameters
|
||||
90 | | ----------
|
||||
91 | | distance : float
|
||||
92 | | Distance traveled.
|
||||
93 | | time : float
|
||||
94 | | Time spent traveling.
|
||||
95 | |
|
||||
96 | | Returns
|
||||
97 | | -------
|
||||
98 | | float
|
||||
99 | | Speed as distance divided by time.
|
||||
100 | | """
|
||||
| |_______^ DOC501
|
||||
101 | try:
|
||||
102 | return distance / time
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
||||
|
||||
__init__.py:86:5: DOC501 Raised exception `FasterThanLightError` missing from docstring
|
||||
|
|
||||
84 | # DOC501
|
||||
85 | def calculate_speed(distance: float, time: float) -> float:
|
||||
86 | / """
|
||||
87 | | Calculate speed as distance divided by time.
|
||||
88 | |
|
||||
89 | | Parameters
|
||||
90 | | ----------
|
||||
91 | | distance : float
|
||||
92 | | Distance traveled.
|
||||
93 | | time : float
|
||||
94 | | Time spent traveling.
|
||||
95 | |
|
||||
96 | | Returns
|
||||
97 | | -------
|
||||
98 | | float
|
||||
99 | | Speed as distance divided by time.
|
||||
100 | | """
|
||||
| |_______^ DOC501
|
||||
101 | try:
|
||||
102 | return distance / time
|
||||
|
|
||||
= help: Add `FasterThanLightError` to the docstring
|
||||
|
||||
__init__.py:111:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
|
|
||||
109 | # DOC501
|
||||
110 | def calculate_speed(distance: float, time: float) -> float:
|
||||
111 | / """Calculate speed as distance divided by time.
|
||||
112 | |
|
||||
113 | | ACalculate speed as distance divided by time.
|
||||
114 | |
|
||||
115 | | Parameters
|
||||
116 | | ----------
|
||||
117 | | distance : float
|
||||
118 | | Distance traveled.
|
||||
119 | | time : float
|
||||
120 | | Time spent traveling.
|
||||
121 | |
|
||||
122 | | Returns
|
||||
123 | | -------
|
||||
124 | | float
|
||||
125 | | Speed as distance divided by time.
|
||||
126 | |
|
||||
127 | | Raises
|
||||
128 | | ------
|
||||
129 | | ZeroDivisionError
|
||||
130 | | If attempting to divide by zero.
|
||||
131 | | """
|
||||
| |_______^ DOC501
|
||||
132 | try:
|
||||
133 | return distance / time
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
__init__.py:167:5: DOC501 Raised exception `TypeError` missing from docstring
|
||||
|
|
||||
166 | def foo():
|
||||
167 | / """Foo.
|
||||
168 | |
|
||||
169 | | Returns
|
||||
170 | | -------
|
||||
171 | | int
|
||||
172 | | 42
|
||||
173 | | """
|
||||
| |_______^ DOC501
|
||||
174 | if True:
|
||||
175 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `TypeError` to the docstring
|
||||
|
||||
__init__.py:167:5: DOC501 Raised exception `ValueError` missing from docstring
|
||||
|
|
||||
166 | def foo():
|
||||
167 | / """Foo.
|
||||
168 | |
|
||||
169 | | Returns
|
||||
170 | | -------
|
||||
171 | | int
|
||||
172 | | 42
|
||||
173 | | """
|
||||
| |_______^ DOC501
|
||||
174 | if True:
|
||||
175 | raise TypeError # DOC501
|
||||
|
|
||||
= help: Add `ValueError` to the docstring
|
|
@ -129,7 +129,7 @@ mod tests {
|
|||
..settings::LinterSettings::for_rule(rule_code)
|
||||
},
|
||||
)?;
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
assert_diagnostics!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
#![cfg(any(test, fuzzing))]
|
||||
//! Helper functions for the tests of rule implementations.
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::path::Path;
|
||||
|
||||
#[cfg(not(fuzzing))]
|
||||
use anyhow::Result;
|
||||
use anyhow::{Context, Result};
|
||||
use itertools::Itertools;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
|
@ -19,6 +16,11 @@ use ruff_python_index::Indexer;
|
|||
use ruff_python_parser::{ParseError, ParseOptions};
|
||||
use ruff_python_trivia::textwrap::dedent;
|
||||
use ruff_source_file::SourceFileBuilder;
|
||||
use std::borrow::Cow;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use tempfile::tempdir;
|
||||
|
||||
use crate::codes::Rule;
|
||||
use crate::fix::{FixResult, fix_file};
|
||||
|
@ -49,6 +51,35 @@ pub(crate) fn test_path(
|
|||
Ok(test_contents(&source_kind, &path, settings).0)
|
||||
}
|
||||
|
||||
/// Like [`test_path`], but first copies the Python file to be the `__init__.py` of a package.
|
||||
#[cfg(not(fuzzing))]
|
||||
pub(crate) fn test_path_as_package_init(
|
||||
path: impl AsRef<Path>,
|
||||
settings: &LinterSettings,
|
||||
) -> Result<Vec<OldDiagnostic>> {
|
||||
let package_name = path
|
||||
.as_ref()
|
||||
.file_stem()
|
||||
.map(OsStr::to_string_lossy)
|
||||
.unwrap_or("my_package".into());
|
||||
let path = test_resource_path("fixtures").join(&path);
|
||||
|
||||
let temp_dir = tempdir().context("creating temp dir")?;
|
||||
let package_dir = temp_dir.path().join(&*package_name);
|
||||
println!("{}", package_dir.to_str().unwrap());
|
||||
println!("{} {}", package_dir.exists(), package_dir.is_dir());
|
||||
let package_init_path = package_dir.join("__init__.py");
|
||||
fs::create_dir_all(&package_dir).context("creating my_package in tmp")?;
|
||||
println!("{} {}", package_dir.exists(), package_dir.is_dir());
|
||||
println!("{} {}", path.exists(), path.is_file());
|
||||
fs::copy(&path, &package_init_path).context("copying into __init__.py in tmp")?;
|
||||
|
||||
let source_type = PySourceType::from(&package_init_path);
|
||||
let source_kind =
|
||||
SourceKind::from_path(package_init_path.as_ref(), source_type)?.expect("valid source");
|
||||
Ok(test_contents(&source_kind, &package_init_path, settings).0)
|
||||
}
|
||||
|
||||
#[cfg(not(fuzzing))]
|
||||
pub(crate) struct TestedNotebook {
|
||||
pub(crate) diagnostics: Vec<Diagnostic>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue