File tree Expand file tree Collapse file tree 4 files changed +100
-54
lines changed Expand file tree Collapse file tree 4 files changed +100
-54
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,17 @@ exit_code: 1
22
22
" description" : " `os` imported but unused" ,
23
23
" fingerprint" : " 4dbad37161e65c72" ,
24
24
" location" : {
25
- " lines" : {
26
- " begin" : 1 ,
27
- " end" : 1
28
- },
29
- " path" : " input.py"
25
+ " path" : " input.py" ,
26
+ " positions" : {
27
+ " begin" : {
28
+ " column" : 8 ,
29
+ " line" : 1
30
+ },
31
+ " end" : {
32
+ " column" : 10 ,
33
+ " line" : 1
34
+ }
35
+ }
30
36
},
31
37
" severity" : " major"
32
38
},
@@ -35,11 +41,17 @@ exit_code: 1
35
41
" description" : " Undefined name `y`" ,
36
42
" fingerprint" : " 7af59862a085230" ,
37
43
" location" : {
38
- " lines" : {
39
- " begin" : 2 ,
40
- " end" : 2
41
- },
42
- " path" : " input.py"
44
+ " path" : " input.py" ,
45
+ " positions" : {
46
+ " begin" : {
47
+ " column" : 5 ,
48
+ " line" : 2
49
+ },
50
+ " end" : {
51
+ " column" : 6 ,
52
+ " line" : 2
53
+ }
54
+ }
43
55
},
44
56
" severity" : " major"
45
57
},
@@ -48,11 +60,17 @@ exit_code: 1
48
60
" description" : " Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)" ,
49
61
" fingerprint" : " e558cec859bb66e8" ,
50
62
" location" : {
51
- " lines" : {
52
- " begin" : 3 ,
53
- " end" : 3
54
- },
55
- " path" : " input.py"
63
+ " path" : " input.py" ,
64
+ " positions" : {
65
+ " begin" : {
66
+ " column" : 1 ,
67
+ " line" : 3
68
+ },
69
+ " end" : {
70
+ " column" : 6 ,
71
+ " line" : 3
72
+ }
73
+ }
56
74
},
57
75
" severity" : " major"
58
76
}
Original file line number Diff line number Diff line change @@ -61,22 +61,17 @@ impl Serialize for SerializedMessages<'_> {
61
61
let mut fingerprints = HashSet :: < u64 > :: with_capacity ( self . diagnostics . len ( ) ) ;
62
62
63
63
for diagnostic in self . diagnostics {
64
- let start_location = diagnostic. expect_ruff_start_location ( ) ;
65
- let end_location = diagnostic. expect_ruff_end_location ( ) ;
66
-
67
64
let filename = diagnostic. expect_ruff_filename ( ) ;
68
- let lines = if self . context . is_notebook ( & filename) {
65
+
66
+ let ( start_location, end_location) = if self . context . is_notebook ( & filename) {
69
67
// We can't give a reasonable location for the structured formats,
70
68
// so we show one that's clearly a fallback
71
- json ! ( {
72
- "begin" : 1 ,
73
- "end" : 1
74
- } )
69
+ Default :: default ( )
75
70
} else {
76
- json ! ( {
77
- "begin" : start_location . line ,
78
- "end" : end_location . line
79
- } )
71
+ (
72
+ diagnostic . expect_ruff_start_location ( ) ,
73
+ diagnostic . expect_ruff_end_location ( ) ,
74
+ )
80
75
} ;
81
76
82
77
let path = self . project_dir . as_ref ( ) . map_or_else (
@@ -111,8 +106,11 @@ impl Serialize for SerializedMessages<'_> {
111
106
"fingerprint" : format!( "{:x}" , message_fingerprint) ,
112
107
"location" : {
113
108
"path" : path,
114
- "lines" : lines
115
- }
109
+ "positions" : {
110
+ "begin" : start_location,
111
+ "end" : end_location,
112
+ } ,
113
+ } ,
116
114
} ) ;
117
115
118
116
s. serialize_element ( & value) ?;
Original file line number Diff line number Diff line change @@ -8,11 +8,17 @@ expression: redact_fingerprint(&content)
8
8
" description" : " `os` imported but unused" ,
9
9
" fingerprint" : " <redacted>" ,
10
10
" location" : {
11
- " lines" : {
12
- " begin" : 1 ,
13
- " end" : 1
14
- },
15
- " path" : " fib.py"
11
+ " path" : " fib.py" ,
12
+ " positions" : {
13
+ " begin" : {
14
+ " column" : 8 ,
15
+ " line" : 1
16
+ },
17
+ " end" : {
18
+ " column" : 10 ,
19
+ " line" : 1
20
+ }
21
+ }
16
22
},
17
23
" severity" : " major"
18
24
},
@@ -21,11 +27,17 @@ expression: redact_fingerprint(&content)
21
27
" description" : " Local variable `x` is assigned to but never used" ,
22
28
" fingerprint" : " <redacted>" ,
23
29
" location" : {
24
- " lines" : {
25
- " begin" : 6 ,
26
- " end" : 6
27
- },
28
- " path" : " fib.py"
30
+ " path" : " fib.py" ,
31
+ " positions" : {
32
+ " begin" : {
33
+ " column" : 5 ,
34
+ " line" : 6
35
+ },
36
+ " end" : {
37
+ " column" : 6 ,
38
+ " line" : 6
39
+ }
40
+ }
29
41
},
30
42
" severity" : " major"
31
43
},
@@ -34,11 +46,17 @@ expression: redact_fingerprint(&content)
34
46
" description" : " Undefined name `a`" ,
35
47
" fingerprint" : " <redacted>" ,
36
48
" location" : {
37
- " lines" : {
38
- " begin" : 1 ,
39
- " end" : 1
40
- },
41
- " path" : " undef.py"
49
+ " path" : " undef.py" ,
50
+ " positions" : {
51
+ " begin" : {
52
+ " column" : 4 ,
53
+ " line" : 1
54
+ },
55
+ " end" : {
56
+ " column" : 5 ,
57
+ " line" : 1
58
+ }
59
+ }
42
60
},
43
61
" severity" : " major"
44
62
}
Original file line number Diff line number Diff line change @@ -8,11 +8,17 @@ expression: redact_fingerprint(&content)
8
8
" description" : " Expected one or more symbol names after import" ,
9
9
" fingerprint" : " <redacted>" ,
10
10
" location" : {
11
- " lines" : {
12
- " begin" : 1 ,
13
- " end" : 2
14
- },
15
- " path" : " syntax_errors.py"
11
+ " path" : " syntax_errors.py" ,
12
+ " positions" : {
13
+ " begin" : {
14
+ " column" : 15 ,
15
+ " line" : 1
16
+ },
17
+ " end" : {
18
+ " column" : 1 ,
19
+ " line" : 2
20
+ }
21
+ }
16
22
},
17
23
" severity" : " major"
18
24
},
@@ -21,11 +27,17 @@ expression: redact_fingerprint(&content)
21
27
" description" : " Expected ')', found newline" ,
22
28
" fingerprint" : " <redacted>" ,
23
29
" location" : {
24
- " lines" : {
25
- " begin" : 3 ,
26
- " end" : 4
27
- },
28
- " path" : " syntax_errors.py"
30
+ " path" : " syntax_errors.py" ,
31
+ " positions" : {
32
+ " begin" : {
33
+ " column" : 12 ,
34
+ " line" : 3
35
+ },
36
+ " end" : {
37
+ " column" : 1 ,
38
+ " line" : 4
39
+ }
40
+ }
29
41
},
30
42
" severity" : " major"
31
43
}
You can’t perform that action at this time.
0 commit comments