Skip to content

Commit c9eb20f

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

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-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+
}

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(

0 commit comments

Comments
 (0)