Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4cc0da3
pass hide_severity deep into annotate-snippets
ntBre Jul 22, 2025
d94ed81
add a test with hide_severity = true
ntBre Jul 30, 2025
2e814ee
revert hide_severity passing, using Level::None instead
ntBre Jul 30, 2025
b661e15
bring over syntax error changes and comment
ntBre Jul 30, 2025
9f13cbe
add syntax error severity test
ntBre Jul 30, 2025
d1054d5
extract hide_severity earlier
ntBre Jul 30, 2025
a6b2a73
replace `SyntaxError:` with `invalid-syntax:` for full and concise
ntBre Jul 31, 2025
b8aa43f
accept full and concise snapshots
ntBre Jul 31, 2025
0dc0616
accept junit, pylint, and rdjson snaps
ntBre Jul 31, 2025
6ee28ee
add Diagnostic::secondary_code_or_id
ntBre Jul 31, 2025
0b625a1
fall back on diagnostic id for azure
ntBre Jul 31, 2025
a1488fe
fall back on diagnostic id for github
ntBre Jul 31, 2025
7cec0e0
fall back on diagnostic id for grouped
ntBre Jul 31, 2025
199af70
fall back on diagnostic id for sarif
ntBre Jul 31, 2025
1cdb26c
fall back on diagnostic id for json and json-lines
ntBre Jul 31, 2025
9325158
fall back on diagnostic id for wasm
ntBre Jul 31, 2025
2617d56
update comment
ntBre Jul 31, 2025
0b0be5b
update ecosystem check regex
ntBre Jul 31, 2025
cbbc369
more permissive regex
ntBre Aug 1, 2025
df21120
make DisplayAnnotationType::is_none private
ntBre Aug 1, 2025
1ae8695
use `error` formatting for `hide_severity` identifiers
ntBre Aug 1, 2025
1e6e561
move fix indicator into annotate-snippets to preserve color
ntBre Aug 1, 2025
5f149fc
render fix indicator regardless of severity or id
ntBre Aug 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/ruff/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ fn stdin_parse_error() {
success: false
exit_code: 1
----- stdout -----
-:1:16: SyntaxError: Expected one or more symbol names after import
-:1:16: invalid-syntax: Expected one or more symbol names after import
|
1 | from foo import
| ^
Expand All @@ -818,14 +818,14 @@ fn stdin_multiple_parse_error() {
success: false
exit_code: 1
----- stdout -----
-:1:16: SyntaxError: Expected one or more symbol names after import
-:1:16: invalid-syntax: Expected one or more symbol names after import
|
1 | from foo import
| ^
2 | bar =
|

-:2:6: SyntaxError: Expected an expression
-:2:6: invalid-syntax: Expected an expression
|
1 | from foo import
2 | bar =
Expand All @@ -847,7 +847,7 @@ fn parse_error_not_included() {
success: false
exit_code: 1
----- stdout -----
-:1:6: SyntaxError: Expected an expression
-:1:6: invalid-syntax: Expected an expression
|
1 | foo =
| ^
Expand Down
20 changes: 10 additions & 10 deletions crates/ruff/tests/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5389,7 +5389,7 @@ fn walrus_before_py38() {
success: false
exit_code: 1
----- stdout -----
test.py:1:2: SyntaxError: Cannot use named assignment expression (`:=`) on Python 3.7 (syntax was added in Python 3.8)
test.py:1:2: invalid-syntax: Cannot use named assignment expression (`:=`) on Python 3.7 (syntax was added in Python 3.8)
Found 1 error.

----- stderr -----
Expand Down Expand Up @@ -5435,15 +5435,15 @@ match 2:
print("it's one")
"#
),
@r###"
@r"
success: false
exit_code: 1
----- stdout -----
test.py:2:1: SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
test.py:2:1: invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
Found 1 error.

----- stderr -----
"###
"
);

// syntax error on 3.9 with preview
Expand All @@ -5464,7 +5464,7 @@ match 2:
success: false
exit_code: 1
----- stdout -----
test.py:2:1: SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
test.py:2:1: invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
Found 1 error.

----- stderr -----
Expand Down Expand Up @@ -5492,7 +5492,7 @@ fn cache_syntax_errors() -> Result<()> {
success: false
exit_code: 1
----- stdout -----
main.py:1:1: SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
main.py:1:1: invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)

----- stderr -----
"
Expand All @@ -5505,7 +5505,7 @@ fn cache_syntax_errors() -> Result<()> {
success: false
exit_code: 1
----- stdout -----
main.py:1:1: SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
main.py:1:1: invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)

----- stderr -----
"
Expand Down Expand Up @@ -5618,7 +5618,7 @@ fn semantic_syntax_errors() -> Result<()> {
success: false
exit_code: 1
----- stdout -----
main.py:1:3: SyntaxError: assignment expression cannot rebind comprehension variable
main.py:1:3: invalid-syntax: assignment expression cannot rebind comprehension variable
main.py:1:20: F821 Undefined name `foo`

----- stderr -----
Expand All @@ -5632,7 +5632,7 @@ fn semantic_syntax_errors() -> Result<()> {
success: false
exit_code: 1
----- stdout -----
main.py:1:3: SyntaxError: assignment expression cannot rebind comprehension variable
main.py:1:3: invalid-syntax: assignment expression cannot rebind comprehension variable
main.py:1:20: F821 Undefined name `foo`

----- stderr -----
Expand All @@ -5651,7 +5651,7 @@ fn semantic_syntax_errors() -> Result<()> {
success: false
exit_code: 1
----- stdout -----
-:1:3: SyntaxError: assignment expression cannot rebind comprehension variable
-:1:3: invalid-syntax: assignment expression cannot rebind comprehension variable
Found 1 error.

----- stderr -----
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/tests/snapshots/lint__output_format_azure.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ exit_code: 1
----- stdout -----
##vso[task.logissue type=error;sourcepath=[TMP]/input.py;linenumber=1;columnnumber=8;code=F401;]`os` imported but unused
##vso[task.logissue type=error;sourcepath=[TMP]/input.py;linenumber=2;columnnumber=5;code=F821;]Undefined name `y`
##vso[task.logissue type=error;sourcepath=[TMP]/input.py;linenumber=3;columnnumber=1;]SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
##vso[task.logissue type=error;sourcepath=[TMP]/input.py;linenumber=3;columnnumber=1;code=invalid-syntax;]Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)

----- stderr -----
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exit_code: 1
----- stdout -----
input.py:1:8: F401 [*] `os` imported but unused
input.py:2:5: F821 Undefined name `y`
input.py:3:1: SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
input.py:3:1: invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
Found 3 errors.
[*] 1 fixable with the `--fix` option.

Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/tests/snapshots/lint__output_format_full.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ input.py:2:5: F821 Undefined name `y`
4 | case _: ...
|

input.py:3:1: SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
input.py:3:1: invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
|
1 | import os # F401
2 | x = y # F821
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ exit_code: 1
----- stdout -----
::error title=Ruff (F401),file=[TMP]/input.py,line=1,col=8,endLine=1,endColumn=10::input.py:1:8: F401 `os` imported but unused
::error title=Ruff (F821),file=[TMP]/input.py,line=2,col=5,endLine=2,endColumn=6::input.py:2:5: F821 Undefined name `y`
::error title=Ruff,file=[TMP]/input.py,line=3,col=1,endLine=3,endColumn=6::input.py:3:1: SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
::error title=Ruff (invalid-syntax),file=[TMP]/input.py,line=3,col=1,endLine=3,endColumn=6::input.py:3:1: invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this feels odd but it is consistent to how we handle the other rules. I'm fine leaving this as is (seems like a separate change)


----- stderr -----
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exit_code: 1
input.py:
1:8 F401 [*] `os` imported but unused
2:5 F821 Undefined name `y`
3:1 SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
3:1 invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)

Found 3 errors.
[*] 1 fixable with the `--fix` option.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ exit_code: 1
----- stdout -----
{"cell":null,"code":"F401","end_location":{"column":10,"row":1},"filename":"[TMP]/input.py","fix":{"applicability":"safe","edits":[{"content":"","end_location":{"column":1,"row":2},"location":{"column":1,"row":1}}],"message":"Remove unused import: `os`"},"location":{"column":8,"row":1},"message":"`os` imported but unused","noqa_row":1,"url":"https://docs.astral.sh/ruff/rules/unused-import"}
{"cell":null,"code":"F821","end_location":{"column":6,"row":2},"filename":"[TMP]/input.py","fix":null,"location":{"column":5,"row":2},"message":"Undefined name `y`","noqa_row":2,"url":"https://docs.astral.sh/ruff/rules/undefined-name"}
{"cell":null,"code":null,"end_location":{"column":6,"row":3},"filename":"[TMP]/input.py","fix":null,"location":{"column":1,"row":3},"message":"SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)","noqa_row":null,"url":null}
{"cell":null,"code":"invalid-syntax","end_location":{"column":6,"row":3},"filename":"[TMP]/input.py","fix":null,"location":{"column":1,"row":3},"message":"Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)","noqa_row":null,"url":null}

----- stderr -----
4 changes: 2 additions & 2 deletions crates/ruff/tests/snapshots/lint__output_format_json.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ exit_code: 1
},
{
"cell": null,
"code": null,
"code": "invalid-syntax",
"end_location": {
"column": 6,
"row": 3
Expand All @@ -80,7 +80,7 @@ exit_code: 1
"column": 1,
"row": 3
},
"message": "SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)",
"message": "Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)",
"noqa_row": null,
"url": null
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/tests/snapshots/lint__output_format_junit.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exit_code: 1
<failure message="Undefined name `y`">line 2, col 5, Undefined name `y`</failure>
</testcase>
<testcase name="org.ruff.invalid-syntax" classname="[TMP]/input" line="3" column="1">
<failure message="SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)">line 3, col 1, SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)</failure>
<failure message="Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)">line 3, col 1, Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)</failure>
</testcase>
</testsuite>
</testsuites>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ exit_code: 1
----- stdout -----
input.py:1: [F401] `os` imported but unused
input.py:2: [F821] Undefined name `y`
input.py:3: [invalid-syntax] SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
input.py:3: [invalid-syntax] Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)

----- stderr -----
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ exit_code: 1
}
}
},
"message": "SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)"
"message": "Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)"
}
],
"severity": "WARNING",
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff/tests/snapshots/lint__output_format_sarif.snap
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ exit_code: 1
}
],
"message": {
"text": "SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)"
"text": "Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)"
},
"ruleId": null
"ruleId": "invalid-syntax"
}
],
"tool": {
Expand Down
Loading
Loading