Skip to content

Commit 9432587

Browse files
committed
test: another line terminator bug fix
I believe this case is different from the last in that it happens when the end of a *multi-line* annotation occurs after a line terminator. Previously, the diagnostic would render on the next line, which is definitely a bit weird. This new update renders it at the end of the line the annotation ends on. In some cases, the annotation was previously rendered to point at source lines below where the error occurred, which is probably pretty confusing.
1 parent bfcd48e commit 9432587

17 files changed

+148
-162
lines changed

crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
22
source: crates/ruff_linter/src/rules/isort/mod.rs
3-
snapshot_kind: text
43
---
54
insert_empty_lines.py:1:1: I001 [*] Import block is un-sorted or un-formatted
65
|
76
1 | / import a
87
2 | | import b
9-
3 | | x = 1
10-
| |_^ I001
8+
| |_________^ I001
9+
3 | x = 1
1110
4 | import os
1211
5 | import sys
1312
|
@@ -27,8 +26,8 @@ insert_empty_lines.py:4:1: I001 [*] Import block is un-sorted or un-formatted
2726
3 | x = 1
2827
4 | / import os
2928
5 | | import sys
30-
6 | | def f():
31-
| |_^ I001
29+
| |___________^ I001
30+
6 | def f():
3231
7 | pass
3332
8 | if True:
3433
|
@@ -50,9 +49,9 @@ insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted
5049
13 | y = 1
5150
14 | / import os
5251
15 | | import sys
53-
16 | | """Docstring"""
54-
| |_^ I001
55-
17 |
52+
| |___________^ I001
53+
16 | """Docstring"""
54+
17 |
5655
18 | if True:
5756
|
5857
= help: Organize imports
@@ -69,9 +68,9 @@ insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted
6968
insert_empty_lines.py:52:1: I001 [*] Import block is un-sorted or un-formatted
7069
|
7170
52 | / import os
72-
53 | |
73-
54 | | # Comment goes here.
74-
| |_^ I001
71+
53 | |
72+
| |__^ I001
73+
54 | # Comment goes here.
7574
55 | def f():
7675
56 | pass
7776
|

crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
22
source: crates/ruff_linter/src/rules/isort/mod.rs
3-
snapshot_kind: text
43
---
54
insert_empty_lines.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted
65
|
76
1 | / import a
87
2 | | import b
9-
3 | | x = 1
10-
| |_^ I001
8+
| |_________^ I001
9+
3 | x = 1
1110
4 | import os
1211
5 | import sys
1312
|
@@ -27,8 +26,8 @@ insert_empty_lines.pyi:4:1: I001 [*] Import block is un-sorted or un-formatted
2726
3 | x = 1
2827
4 | / import os
2928
5 | | import sys
30-
6 | | def f():
31-
| |_^ I001
29+
| |___________^ I001
30+
6 | def f():
3231
7 | pass
3332
8 | if True:
3433
|
@@ -49,9 +48,9 @@ insert_empty_lines.pyi:14:1: I001 [*] Import block is un-sorted or un-formatted
4948
13 | y = 1
5049
14 | / import os
5150
15 | | import sys
52-
16 | | """Docstring"""
53-
| |_^ I001
54-
17 |
51+
| |___________^ I001
52+
16 | """Docstring"""
53+
17 |
5554
18 | if True:
5655
|
5756
= help: Organize imports

crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
---
22
source: crates/ruff_linter/src/rules/isort/mod.rs
3-
snapshot_kind: text
43
---
54
lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted
65
|
76
1 | / from __future__ import annotations
8-
2 | |
7+
2 | |
98
3 | | from typing import Any
10-
4 | |
9+
4 | |
1110
5 | | from requests import Session
12-
6 | |
11+
6 | |
1312
7 | | from my_first_party import my_first_party_object
14-
8 | |
13+
8 | |
1514
9 | | from . import my_local_folder_object
16-
10 | | class Thing(object):
17-
| |_^ I001
15+
| |_____________________________________^ I001
16+
10 | class Thing(object):
1817
11 | name: str
1918
12 | def __init__(self, name: str):
2019
|

crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
---
22
source: crates/ruff_linter/src/rules/isort/mod.rs
3-
snapshot_kind: text
43
---
54
lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted
65
|
76
1 | / from __future__ import annotations
8-
2 | |
7+
2 | |
98
3 | | from typing import Any
10-
4 | |
9+
4 | |
1110
5 | | from requests import Session
12-
6 | |
11+
6 | |
1312
7 | | from my_first_party import my_first_party_object
14-
8 | |
13+
8 | |
1514
9 | | from . import my_local_folder_object
16-
10 | | class Thing(object):
17-
| |_^ I001
15+
| |_____________________________________^ I001
16+
10 | class Thing(object):
1817
11 | name: str
1918
12 | def __init__(self, name: str):
2019
|

crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
---
22
source: crates/ruff_linter/src/rules/isort/mod.rs
3-
snapshot_kind: text
43
---
54
match_case.py:3:1: I001 [*] Import block is un-sorted or un-formatted
65
|
76
1 | match 1:
87
2 | case 1:
98
3 | / import sys
109
4 | | import os
11-
5 | | case 2:
12-
| |_^ I001
10+
| |__________________^ I001
11+
5 | case 2:
1312
6 | import collections
1413
7 | import abc
1514
|
@@ -31,6 +30,7 @@ match_case.py:6:1: I001 [*] Import block is un-sorted or un-formatted
3130
5 | case 2:
3231
6 | / import collections
3332
7 | | import abc
33+
| |___________________^ I001
3434
|
3535
= help: Organize imports
3636

crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
source: crates/ruff_linter/src/rules/isort/mod.rs
3-
snapshot_kind: text
43
---
54
preserve_indentation.py:2:1: I001 [*] Import block is un-sorted or un-formatted
65
|
76
1 | if True:
87
2 | / import sys
98
3 | | import os
10-
4 | | else:
11-
| |_^ I001
9+
| |______________^ I001
10+
4 | else:
1211
5 | import sys
1312
6 | import os
1413
|
@@ -29,6 +28,7 @@ preserve_indentation.py:5:1: I001 [*] Import block is un-sorted or un-formatted
2928
4 | else:
3029
5 | / import sys
3130
6 | | import os
31+
| |______________^ I001
3232
|
3333
= help: Organize imports
3434

crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: crates/ruff_linter/src/rules/isort/mod.rs
3-
snapshot_kind: text
43
---
54
two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted
65
|
@@ -12,9 +11,9 @@ two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted
1211
6 | | nan,
1312
7 | | pi,
1413
8 | | )
15-
9 | |
16-
10 | | del sin, cos, tan, pi, nan
17-
| |_^ I001
14+
9 | |
15+
| |__^ I001
16+
10 | del sin, cos, tan, pi, nan
1817
|
1918
= help: Organize imports
2019

crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
22
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
3-
snapshot_kind: text
43
---
54
E11.py:9:1: E112 Expected an indented block
65
|
76
7 | #: E112
87
8 | if False:
8+
| ^ E112
99
9 | print()
10-
| E112
1110
10 | #: E113
1211
11 | print()
1312
|
@@ -46,8 +45,8 @@ E11.py:45:1: E112 Expected an indented block
4645
|
4746
43 | #: E112
4847
44 | if False: #
48+
| ^ E112
4949
45 | print()
50-
| E112
5150
46 | #:
5251
47 | if False:
5352
|

crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
3-
snapshot_kind: text
43
---
54
E11.py:9:1: SyntaxError: Expected an indented block after `if` statement
65
|
@@ -36,8 +35,8 @@ E11.py:30:1: E115 Expected an indented block (comment)
3635
|
3736
28 | def start(self):
3837
29 | if True:
38+
| ^ E115
3939
30 | # try:
40-
| E115
4140
31 | # self.master.start()
4241
32 | # except MasterExit:
4342
|
@@ -46,8 +45,8 @@ E11.py:31:1: E115 Expected an indented block (comment)
4645
|
4746
29 | if True:
4847
30 | # try:
48+
| ^ E115
4949
31 | # self.master.start()
50-
| E115
5150
32 | # except MasterExit:
5251
33 | # self.shutdown()
5352
|
@@ -56,8 +55,8 @@ E11.py:32:1: E115 Expected an indented block (comment)
5655
|
5756
30 | # try:
5857
31 | # self.master.start()
58+
| ^ E115
5959
32 | # except MasterExit:
60-
| E115
6160
33 | # self.shutdown()
6261
34 | # finally:
6362
|
@@ -66,8 +65,8 @@ E11.py:33:1: E115 Expected an indented block (comment)
6665
|
6766
31 | # self.master.start()
6867
32 | # except MasterExit:
68+
| ^ E115
6969
33 | # self.shutdown()
70-
| E115
7170
34 | # finally:
7271
35 | # sys.exit()
7372
|
@@ -76,8 +75,8 @@ E11.py:34:1: E115 Expected an indented block (comment)
7675
|
7776
32 | # except MasterExit:
7877
33 | # self.shutdown()
78+
| ^ E115
7979
34 | # finally:
80-
| E115
8180
35 | # sys.exit()
8281
36 | self.master.start()
8382
|
@@ -86,8 +85,8 @@ E11.py:35:1: E115 Expected an indented block (comment)
8685
|
8786
33 | # self.shutdown()
8887
34 | # finally:
88+
| ^ E115
8989
35 | # sys.exit()
90-
| E115
9190
36 | self.master.start()
9291
37 | #: E117
9392
|

crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs
3-
snapshot_kind: text
43
---
54
D.py:232:1: D207 [*] Docstring is under-indented
65
|
76
230 | """Summary.
8-
231 |
7+
231 |
8+
| ^ D207
99
232 | Description.
10-
| D207
11-
233 |
10+
233 |
1211
234 | """
1312
|
1413
= help: Increase indentation
@@ -26,9 +25,9 @@ D.py:232:1: D207 [*] Docstring is under-indented
2625
D.py:244:1: D207 [*] Docstring is under-indented
2726
|
2827
242 | Description.
29-
243 |
28+
243 |
29+
| ^ D207
3030
244 | """
31-
| D207
3231
|
3332
= help: Increase indentation
3433

@@ -45,9 +44,9 @@ D.py:244:1: D207 [*] Docstring is under-indented
4544
D.py:440:1: D207 [*] Docstring is under-indented
4645
|
4746
438 | def docstring_start_in_same_line(): """First Line.
48-
439 |
47+
439 |
48+
| ^ D207
4949
440 | Second Line
50-
| D207
5150
441 | """
5251
|
5352
= help: Increase indentation
@@ -65,8 +64,8 @@ D.py:440:1: D207 [*] Docstring is under-indented
6564
D.py:441:1: D207 [*] Docstring is under-indented
6665
|
6766
440 | Second Line
67+
| ^ D207
6868
441 | """
69-
| D207
7069
|
7170
= help: Increase indentation
7271

0 commit comments

Comments
 (0)