Skip to content

Commit 44dd30f

Browse files
committed
Fix
1 parent d9718c2 commit 44dd30f

7 files changed

+45
-27
lines changed

crates/ruff_linter/src/noqa.rs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,19 +1253,25 @@ mod tests {
12531253
#[test]
12541254
fn noqa_no_code() {
12551255
let source = "# noqa:";
1256-
assert_debug_snapshot!(Directive::try_extract(source, TextSize::default()));
1256+
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
1257+
assert_debug_snapshot!(directive);
1258+
assert_lexed_ranges_match_slices(directive, source);
12571259
}
12581260

12591261
#[test]
12601262
fn noqa_no_code_invalid_suffix() {
12611263
let source = "# noqa: foo";
1262-
assert_debug_snapshot!(Directive::try_extract(source, TextSize::default()));
1264+
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
1265+
assert_debug_snapshot!(directive);
1266+
assert_lexed_ranges_match_slices(directive, source);
12631267
}
12641268

12651269
#[test]
12661270
fn noqa_no_code_trailing_content() {
12671271
let source = "# noqa: # Foo";
1268-
assert_debug_snapshot!(Directive::try_extract(source, TextSize::default()));
1272+
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
1273+
assert_debug_snapshot!(directive);
1274+
assert_lexed_ranges_match_slices(directive, source);
12691275
}
12701276

12711277
#[test]
@@ -1503,19 +1509,25 @@ mod tests {
15031509
#[test]
15041510
fn flake8_noqa_no_code() {
15051511
let source = "# flake8: # noqa:";
1506-
assert_debug_snapshot!(Directive::try_extract(source, TextSize::default()));
1512+
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
1513+
assert_debug_snapshot!(exemption);
1514+
assert_lexed_ranges_match_slices(exemption, source);
15071515
}
15081516

15091517
#[test]
15101518
fn flake8_noqa_no_code_invalid_suffix() {
15111519
let source = "# flake8: # noqa: foo";
1512-
assert_debug_snapshot!(Directive::try_extract(source, TextSize::default()));
1520+
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
1521+
assert_debug_snapshot!(exemption);
1522+
assert_lexed_ranges_match_slices(exemption, source);
15131523
}
15141524

15151525
#[test]
15161526
fn flake8_noqa_no_code_trailing_content() {
15171527
let source = "# flake8: # noqa: # Foo";
1518-
assert_debug_snapshot!(Directive::try_extract(source, TextSize::default()));
1528+
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
1529+
assert_debug_snapshot!(exemption);
1530+
assert_lexed_ranges_match_slices(exemption, source);
15191531
}
15201532

15211533
#[test]
@@ -1529,19 +1541,25 @@ mod tests {
15291541
#[test]
15301542
fn ruff_noqa_no_code() {
15311543
let source = "# ruff: # noqa:";
1532-
assert_debug_snapshot!(Directive::try_extract(source, TextSize::default()));
1544+
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
1545+
assert_debug_snapshot!(exemption);
1546+
assert_lexed_ranges_match_slices(exemption, source);
15331547
}
15341548

15351549
#[test]
15361550
fn ruff_noqa_no_code_invalid_suffix() {
15371551
let source = "# ruff: # noqa: foo";
1538-
assert_debug_snapshot!(Directive::try_extract(source, TextSize::default()));
1552+
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
1553+
assert_debug_snapshot!(exemption);
1554+
assert_lexed_ranges_match_slices(exemption, source);
15391555
}
15401556

15411557
#[test]
15421558
fn ruff_noqa_no_code_trailing_content() {
15431559
let source = "# ruff: # noqa: # Foo";
1544-
assert_debug_snapshot!(Directive::try_extract(source, TextSize::default()));
1560+
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
1561+
assert_debug_snapshot!(exemption);
1562+
assert_lexed_ranges_match_slices(exemption, source);
15451563
}
15461564

15471565
#[test]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: crates/ruff_linter/src/noqa.rs
3-
expression: "Directive::try_extract(source, TextSize::default())"
3+
expression: exemption
44
---
5-
Err(
6-
MissingCodes,
5+
Ok(
6+
None,
77
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: crates/ruff_linter/src/noqa.rs
3-
expression: "Directive::try_extract(source, TextSize::default())"
3+
expression: exemption
44
---
5-
Err(
6-
MissingCodes,
5+
Ok(
6+
None,
77
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: crates/ruff_linter/src/noqa.rs
3-
expression: "Directive::try_extract(source, TextSize::default())"
3+
expression: exemption
44
---
5-
Err(
6-
MissingCodes,
5+
Ok(
6+
None,
77
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: crates/ruff_linter/src/noqa.rs
3-
expression: "Directive::try_extract(source, TextSize::default())"
3+
expression: exemption
44
---
5-
Err(
6-
MissingCodes,
5+
Ok(
6+
None,
77
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: crates/ruff_linter/src/noqa.rs
3-
expression: "Directive::try_extract(source, TextSize::default())"
3+
expression: exemption
44
---
5-
Err(
6-
MissingCodes,
5+
Ok(
6+
None,
77
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: crates/ruff_linter/src/noqa.rs
3-
expression: "Directive::try_extract(source, TextSize::default())"
3+
expression: exemption
44
---
5-
Err(
6-
MissingCodes,
5+
Ok(
6+
None,
77
)

0 commit comments

Comments
 (0)