Skip to content

Commit 3f19d13

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 9228a2b commit 3f19d13

9 files changed

+70
-76
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

Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
11
---
22
source: crates/ruff_linter/src/rules/pylint/mod.rs
3-
snapshot_kind: text
43
---
54
bidirectional_unicode.py:2:1: PLE2502 Contains control characters that can permit obfuscated code
65
|
7-
1 | # E2502
8-
2 | / print("שלום")
9-
3 | |
10-
| |_^ PLE2502
11-
4 | # E2502
12-
5 | example = "x‏" * 100 # "‏x" is assigned
6+
1 | # E2502
7+
2 | print("שלום")
8+
| ^^^^^^^^^^^^^ PLE2502
9+
3 |
10+
4 | # E2502
11+
5 | example = "x‏" * 100 # "‏x" is assigned
1312
|
1413

1514
bidirectional_unicode.py:5:1: PLE2502 Contains control characters that can permit obfuscated code
1615
|
17-
4 | # E2502
18-
5 | / example = "x‏" * 100 # "‏x" is assigned
19-
6 | |
20-
| |_^ PLE2502
21-
7 | # E2502
22-
8 | if access_level != "none‮⁦": # Check if admin ⁩⁦' and access_level != 'user
16+
4 | # E2502
17+
5 | example = "x‏" * 100 # "‏x" is assigned
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502
19+
6 |
20+
7 | # E2502
21+
8 | if access_level != "none": # Check if admin ' and access_level != 'user
2322
|
2423

2524
bidirectional_unicode.py:8:1: PLE2502 Contains control characters that can permit obfuscated code
2625
|
27-
7 | # E2502
28-
8 | / if access_level != "none‮⁦": # Check if admin ⁩⁦' and access_level != 'user
29-
9 | | print("You are an admin.")
30-
| |_^ PLE2502
26+
7 | # E2502
27+
8 | if access_level != "none": # Check if admin ' and access_level != 'user
28+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502
29+
9 | print("You are an admin.")
3130
|
3231

3332
bidirectional_unicode.py:14:1: PLE2502 Contains control characters that can permit obfuscated code
3433
|
35-
12 | # E2502
36-
13 | def subtract_funds(account: str, amount: int):
37-
14 | / """Subtract funds from bank account then """
38-
15 | | return
39-
| |_^ PLE2502
40-
16 | bank[account] -= amount
41-
17 | return
34+
12 | # E2502
35+
13 | def subtract_funds(account: str, amount: int):
36+
14 | """Subtract funds from bank account then """
37+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502
38+
15 | return
39+
16 | bank[account] -= amount
40+
17 | return
4241
|

crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
source: crates/ruff_linter/src/linter.rs
3-
snapshot_kind: text
43
---
54
isort.ipynb:cell 1:1:1: I001 [*] Import block is un-sorted or un-formatted
65
|
76
1 | / from pathlib import Path
87
2 | | import random
98
3 | | import math
10-
4 | | from typing import Any
11-
| |_^ I001
9+
| |____________^ I001
10+
4 | from typing import Any
1211
5 | import collections
1312
6 | # Newline should be added here
1413
|
@@ -28,8 +27,8 @@ isort.ipynb:cell 2:1:1: I001 [*] Import block is un-sorted or un-formatted
2827
|
2928
1 | / from typing import Any
3029
2 | | import collections
31-
3 | | # Newline should be added here
32-
| |_^ I001
30+
| |___________________^ I001
31+
3 | # Newline should be added here
3332
4 | def foo():
3433
5 | pass
3534
|
@@ -52,9 +51,9 @@ isort.ipynb:cell 3:1:1: I001 [*] Import block is un-sorted or un-formatted
5251
|
5352
1 | / from pathlib import Path
5453
2 | | import sys
55-
3 | |
56-
4 | | %matplotlib \
57-
| |_^ I001
54+
3 | |
55+
| |__^ I001
56+
4 | %matplotlib \
5857
5 | --inline
5958
|
6059
= help: Organize imports
@@ -73,9 +72,10 @@ isort.ipynb:cell 3:1:1: I001 [*] Import block is un-sorted or un-formatted
7372
isort.ipynb:cell 3:7:1: I001 [*] Import block is un-sorted or un-formatted
7473
|
7574
5 | --inline
76-
6 |
75+
6 |
7776
7 | / import math
7877
8 | | import abc
78+
| |___________^ I001
7979
|
8080
= help: Organize imports
8181

0 commit comments

Comments
 (0)