Skip to content

Commit 9b02f2f

Browse files
committed
Merge branch 'main' into dcreager/inferrable
* main: [ty] Add precise inference for indexing, slicing and unpacking `NamedTuple` instances (#19560) Add rule code to GitLab description (#19896) [ty] render docstrings in hover (#19882) [ty] simplify return type of place_from_declarations (#19884) [ty] Various minor cleanups to tuple internals (#19891) [ty] Improve `sys.version_info` special casing (#19894)
2 parents 87e1d28 + 9f6146a commit 9b02f2f

File tree

36 files changed

+1513
-585
lines changed

36 files changed

+1513
-585
lines changed

crates/ruff/tests/snapshots/lint__output_format_gitlab.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ exit_code: 1
1919
[
2020
{
2121
"check_name": "F401",
22-
"description": "`os` imported but unused",
22+
"description": "F401: `os` imported but unused",
2323
"fingerprint": "4dbad37161e65c72",
2424
"location": {
2525
"path": "input.py",
@@ -38,7 +38,7 @@ exit_code: 1
3838
},
3939
{
4040
"check_name": "F821",
41-
"description": "Undefined name `y`",
41+
"description": "F821: Undefined name `y`",
4242
"fingerprint": "7af59862a085230",
4343
"location": {
4444
"path": "input.py",
@@ -56,8 +56,8 @@ exit_code: 1
5656
"severity": "major"
5757
},
5858
{
59-
"check_name": "syntax-error",
60-
"description": "Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)",
59+
"check_name": "invalid-syntax",
60+
"description": "invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)",
6161
"fingerprint": "e558cec859bb66e8",
6262
"location": {
6363
"path": "input.py",

crates/ruff_linter/src/message/gitlab.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,14 @@ impl Serialize for SerializedMessages<'_> {
8888
}
8989
fingerprints.insert(message_fingerprint);
9090

91-
let (description, check_name) = if let Some(code) = diagnostic.secondary_code() {
92-
(diagnostic.body().to_string(), code.as_str())
93-
} else {
94-
let description = diagnostic.body();
95-
let description_without_prefix = description
96-
.strip_prefix("SyntaxError: ")
97-
.unwrap_or(description);
98-
99-
(description_without_prefix.to_string(), "syntax-error")
100-
};
91+
let description = diagnostic.body();
92+
let check_name = diagnostic.secondary_code_or_id();
10193

10294
let value = json!({
10395
"check_name": check_name,
104-
"description": description,
96+
// GitLab doesn't display the separate `check_name` field in a Code Quality report,
97+
// so prepend it to the description too.
98+
"description": format!("{check_name}: {description}"),
10599
"severity": "major",
106100
"fingerprint": format!("{:x}", message_fingerprint),
107101
"location": {

crates/ruff_linter/src/message/snapshots/ruff_linter__message__gitlab__tests__output.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ expression: redact_fingerprint(&content)
55
[
66
{
77
"check_name": "F401",
8-
"description": "`os` imported but unused",
8+
"description": "F401: `os` imported but unused",
99
"fingerprint": "<redacted>",
1010
"location": {
1111
"path": "fib.py",
@@ -24,7 +24,7 @@ expression: redact_fingerprint(&content)
2424
},
2525
{
2626
"check_name": "F841",
27-
"description": "Local variable `x` is assigned to but never used",
27+
"description": "F841: Local variable `x` is assigned to but never used",
2828
"fingerprint": "<redacted>",
2929
"location": {
3030
"path": "fib.py",
@@ -43,7 +43,7 @@ expression: redact_fingerprint(&content)
4343
},
4444
{
4545
"check_name": "F821",
46-
"description": "Undefined name `a`",
46+
"description": "F821: Undefined name `a`",
4747
"fingerprint": "<redacted>",
4848
"location": {
4949
"path": "undef.py",

crates/ruff_linter/src/message/snapshots/ruff_linter__message__gitlab__tests__syntax_errors.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ expression: redact_fingerprint(&content)
44
---
55
[
66
{
7-
"check_name": "syntax-error",
8-
"description": "Expected one or more symbol names after import",
7+
"check_name": "invalid-syntax",
8+
"description": "invalid-syntax: Expected one or more symbol names after import",
99
"fingerprint": "<redacted>",
1010
"location": {
1111
"path": "syntax_errors.py",
@@ -23,8 +23,8 @@ expression: redact_fingerprint(&content)
2323
"severity": "major"
2424
},
2525
{
26-
"check_name": "syntax-error",
27-
"description": "Expected ')', found newline",
26+
"check_name": "invalid-syntax",
27+
"description": "invalid-syntax: Expected ')', found newline",
2828
"fingerprint": "<redacted>",
2929
"location": {
3030
"path": "syntax_errors.py",

0 commit comments

Comments
 (0)