Skip to content

Commit 3ea77d2

Browse files
committed
Add test cases for ERA100 noqa conflict with RUF100
1 parent 0688883 commit 3ea77d2

File tree

5 files changed

+123
-0
lines changed

5 files changed

+123
-0
lines changed

crates/ruff/resources/test/fixtures/eradicate/ERA001.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ def foo(x, y, z):
1919
class A():
2020
pass
2121
# b = c
22+
23+
24+
dictionary = {
25+
# "key1": 123, # noqa: ERA001
26+
# "key2": 456,
27+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#import os # noqa: ERA001
2+
3+
dictionary = {
4+
# "key1": 123, # noqa: ERA001
5+
# "key2": 456,
6+
}
7+
8+
#import os # noqa: E501

crates/ruff/src/rules/eradicate/snapshots/ruff__rules__eradicate__tests__ERA001_ERA001.py.snap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,25 @@ ERA001.py:21:5: ERA001 [*] Found commented-out code
105105
19 19 | class A():
106106
20 20 | pass
107107
21 |- # b = c
108+
22 21 |
109+
23 22 |
110+
24 23 | dictionary = {
111+
112+
ERA001.py:26:5: ERA001 [*] Found commented-out code
113+
|
114+
24 | dictionary = {
115+
25 | # "key1": 123, # noqa: ERA001
116+
26 | # "key2": 456,
117+
| ^^^^^^^^^^^^^^ ERA001
118+
27 | }
119+
|
120+
= help: Remove commented-out code
121+
122+
Possible fix
123+
23 23 |
124+
24 24 | dictionary = {
125+
25 25 | # "key1": 123, # noqa: ERA001
126+
26 |- # "key2": 456,
127+
27 26 | }
108128

109129

crates/ruff/src/rules/ruff/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,21 @@ mod tests {
165165
Ok(())
166166
}
167167

168+
#[test]
169+
fn ruf100_5() -> Result<()> {
170+
let diagnostics = test_path(
171+
Path::new("ruff/RUF100_5.py"),
172+
&settings::Settings {
173+
..settings::Settings::for_rules(vec![
174+
Rule::UnusedNOQA,
175+
Rule::LineTooLong,
176+
Rule::CommentedOutCode,
177+
])
178+
},
179+
)?;
180+
assert_messages!(diagnostics);
181+
Ok(())
182+
}
168183
#[test]
169184
fn flake8_noqa() -> Result<()> {
170185
let diagnostics = test_path(
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
source: crates/ruff/src/rules/ruff/mod.rs
3+
---
4+
RUF100_5.py:4:21: RUF100 [*] Unused `noqa` directive (unused: `ERA001`)
5+
|
6+
3 | dictionary = {
7+
4 | # "key1": 123, # noqa: ERA001
8+
| ^^^^^^^^^^^^^^ RUF100
9+
5 | # "key2": 456,
10+
6 | }
11+
|
12+
= help: Remove unused `noqa` directive
13+
14+
Suggested fix
15+
1 1 | #import os # noqa: ERA001
16+
2 2 |
17+
3 3 | dictionary = {
18+
4 |- # "key1": 123, # noqa: ERA001
19+
4 |+ # "key1": 123,
20+
5 5 | # "key2": 456,
21+
6 6 | }
22+
7 7 |
23+
24+
RUF100_5.py:5:5: ERA001 [*] Found commented-out code
25+
|
26+
3 | dictionary = {
27+
4 | # "key1": 123, # noqa: ERA001
28+
5 | # "key2": 456,
29+
| ^^^^^^^^^^^^^^ ERA001
30+
6 | }
31+
|
32+
= help: Remove commented-out code
33+
34+
Possible fix
35+
2 2 |
36+
3 3 | dictionary = {
37+
4 4 | # "key1": 123, # noqa: ERA001
38+
5 |- # "key2": 456,
39+
6 5 | }
40+
7 6 |
41+
8 7 | #import os # noqa: E501
42+
43+
RUF100_5.py:8:1: ERA001 [*] Found commented-out code
44+
|
45+
6 | }
46+
7 |
47+
8 | #import os # noqa: E501
48+
| ^^^^^^^^^^^^^^^^^^^^^^^^ ERA001
49+
|
50+
= help: Remove commented-out code
51+
52+
Possible fix
53+
5 5 | # "key2": 456,
54+
6 6 | }
55+
7 7 |
56+
8 |-#import os # noqa: E501
57+
58+
RUF100_5.py:8:13: RUF100 [*] Unused `noqa` directive (unused: `E501`)
59+
|
60+
6 | }
61+
7 |
62+
8 | #import os # noqa: E501
63+
| ^^^^^^^^^^^^ RUF100
64+
|
65+
= help: Remove unused `noqa` directive
66+
67+
Suggested fix
68+
5 5 | # "key2": 456,
69+
6 6 | }
70+
7 7 |
71+
8 |-#import os # noqa: E501
72+
8 |+#import os
73+
74+

0 commit comments

Comments
 (0)