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.
This commit is contained in:
Andrew Gallant 2025-01-07 15:09:42 -05:00 committed by Andrew Gallant
parent 5caef89af3
commit 79e71cbbcd
9 changed files with 70 additions and 76 deletions

View file

@ -1,13 +1,12 @@
---
source: crates/ruff_linter/src/rules/isort/mod.rs
snapshot_kind: text
---
insert_empty_lines.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / import a
2 | | import b
3 | | x = 1
| |_^ I001
| |_________^ I001
3 | x = 1
4 | import os
5 | import sys
|
@ -27,8 +26,8 @@ insert_empty_lines.py:4:1: I001 [*] Import block is un-sorted or un-formatted
3 | x = 1
4 | / import os
5 | | import sys
6 | | def f():
| |_^ I001
| |___________^ I001
6 | def f():
7 | pass
8 | if True:
|
@ -50,9 +49,9 @@ insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted
13 | y = 1
14 | / import os
15 | | import sys
16 | | """Docstring"""
| |_^ I001
17 |
| |___________^ I001
16 | """Docstring"""
17 |
18 | if True:
|
= help: Organize imports
@ -69,9 +68,9 @@ insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted
insert_empty_lines.py:52:1: I001 [*] Import block is un-sorted or un-formatted
|
52 | / import os
53 | |
54 | | # Comment goes here.
| |_^ I001
53 | |
| |__^ I001
54 | # Comment goes here.
55 | def f():
56 | pass
|

View file

@ -1,13 +1,12 @@
---
source: crates/ruff_linter/src/rules/isort/mod.rs
snapshot_kind: text
---
insert_empty_lines.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / import a
2 | | import b
3 | | x = 1
| |_^ I001
| |_________^ I001
3 | x = 1
4 | import os
5 | import sys
|
@ -27,8 +26,8 @@ insert_empty_lines.pyi:4:1: I001 [*] Import block is un-sorted or un-formatted
3 | x = 1
4 | / import os
5 | | import sys
6 | | def f():
| |_^ I001
| |___________^ I001
6 | def f():
7 | pass
8 | if True:
|
@ -49,9 +48,9 @@ insert_empty_lines.pyi:14:1: I001 [*] Import block is un-sorted or un-formatted
13 | y = 1
14 | / import os
15 | | import sys
16 | | """Docstring"""
| |_^ I001
17 |
| |___________^ I001
16 | """Docstring"""
17 |
18 | if True:
|
= help: Organize imports

View file

@ -1,20 +1,19 @@
---
source: crates/ruff_linter/src/rules/isort/mod.rs
snapshot_kind: text
---
lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / from __future__ import annotations
2 | |
2 | |
3 | | from typing import Any
4 | |
4 | |
5 | | from requests import Session
6 | |
6 | |
7 | | from my_first_party import my_first_party_object
8 | |
8 | |
9 | | from . import my_local_folder_object
10 | | class Thing(object):
| |_^ I001
| |_____________________________________^ I001
10 | class Thing(object):
11 | name: str
12 | def __init__(self, name: str):
|

View file

@ -1,20 +1,19 @@
---
source: crates/ruff_linter/src/rules/isort/mod.rs
snapshot_kind: text
---
lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / from __future__ import annotations
2 | |
2 | |
3 | | from typing import Any
4 | |
4 | |
5 | | from requests import Session
6 | |
6 | |
7 | | from my_first_party import my_first_party_object
8 | |
8 | |
9 | | from . import my_local_folder_object
10 | | class Thing(object):
| |_^ I001
| |_____________________________________^ I001
10 | class Thing(object):
11 | name: str
12 | def __init__(self, name: str):
|

View file

@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/rules/isort/mod.rs
snapshot_kind: text
---
match_case.py:3:1: I001 [*] Import block is un-sorted or un-formatted
|
@ -8,8 +7,8 @@ match_case.py:3:1: I001 [*] Import block is un-sorted or un-formatted
2 | case 1:
3 | / import sys
4 | | import os
5 | | case 2:
| |_^ I001
| |__________________^ I001
5 | case 2:
6 | import collections
7 | import abc
|
@ -31,6 +30,7 @@ match_case.py:6:1: I001 [*] Import block is un-sorted or un-formatted
5 | case 2:
6 | / import collections
7 | | import abc
| |___________________^ I001
|
= help: Organize imports

View file

@ -1,14 +1,13 @@
---
source: crates/ruff_linter/src/rules/isort/mod.rs
snapshot_kind: text
---
preserve_indentation.py:2:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | if True:
2 | / import sys
3 | | import os
4 | | else:
| |_^ I001
| |______________^ I001
4 | else:
5 | import sys
6 | import os
|
@ -29,6 +28,7 @@ preserve_indentation.py:5:1: I001 [*] Import block is un-sorted or un-formatted
4 | else:
5 | / import sys
6 | | import os
| |______________^ I001
|
= help: Organize imports

View file

@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/rules/isort/mod.rs
snapshot_kind: text
---
two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted
|
@ -12,9 +11,9 @@ two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted
6 | | nan,
7 | | pi,
8 | | )
9 | |
10 | | del sin, cos, tan, pi, nan
| |_^ I001
9 | |
| |__^ I001
10 | del sin, cos, tan, pi, nan
|
= help: Organize imports

View file

@ -1,42 +1,41 @@
---
source: crates/ruff_linter/src/rules/pylint/mod.rs
snapshot_kind: text
---
bidirectional_unicode.py:2:1: PLE2502 Contains control characters that can permit obfuscated code
|
1 | # E2502
2 | / print("שלום")
3 | |
| |_^ PLE2502
4 | # E2502
5 | example = "x" * 100 # "x" is assigned
1 | # E2502
2 | print("שלום")
| ^^^^^^^^^^^^^ PLE2502
3 |
4 | # E2502
5 | example = "x" * 100 # "x" is assigned
|
bidirectional_unicode.py:5:1: PLE2502 Contains control characters that can permit obfuscated code
|
4 | # E2502
5 | / example = "x" * 100 # "x" is assigned
6 | |
| |_^ PLE2502
7 | # E2502
8 | if access_level != "none": # Check if admin ' and access_level != 'user
4 | # E2502
5 | example = "x" * 100 # "x" is assigned
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502
6 |
7 | # E2502
8 | if access_level != "none": # Check if admin ' and access_level != 'user
|
bidirectional_unicode.py:8:1: PLE2502 Contains control characters that can permit obfuscated code
|
7 | # E2502
8 | / if access_level != "none": # Check if admin ' and access_level != 'user
9 | | print("You are an admin.")
| |_^ PLE2502
7 | # E2502
8 | if access_level != "none": # Check if admin ' and access_level != 'user
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502
9 | print("You are an admin.")
|
bidirectional_unicode.py:14:1: PLE2502 Contains control characters that can permit obfuscated code
|
12 | # E2502
13 | def subtract_funds(account: str, amount: int):
14 | / """Subtract funds from bank account then """
15 | | return
| |_^ PLE2502
16 | bank[account] -= amount
17 | return
12 | # E2502
13 | def subtract_funds(account: str, amount: int):
14 | """Subtract funds from bank account then """
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502
15 | return
16 | bank[account] -= amount
17 | return
|

View file

@ -1,14 +1,13 @@
---
source: crates/ruff_linter/src/linter.rs
snapshot_kind: text
---
isort.ipynb:cell 1:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / from pathlib import Path
2 | | import random
3 | | import math
4 | | from typing import Any
| |_^ I001
| |____________^ I001
4 | from typing import Any
5 | import collections
6 | # Newline should be added here
|
@ -28,8 +27,8 @@ isort.ipynb:cell 2:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / from typing import Any
2 | | import collections
3 | | # Newline should be added here
| |_^ I001
| |___________________^ I001
3 | # Newline should be added here
4 | def foo():
5 | pass
|
@ -52,9 +51,9 @@ isort.ipynb:cell 3:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / from pathlib import Path
2 | | import sys
3 | |
4 | | %matplotlib \
| |_^ I001
3 | |
| |__^ I001
4 | %matplotlib \
5 | --inline
|
= help: Organize imports
@ -73,9 +72,10 @@ isort.ipynb:cell 3:1:1: I001 [*] Import block is un-sorted or un-formatted
isort.ipynb:cell 3:7:1: I001 [*] Import block is un-sorted or un-formatted
|
5 | --inline
6 |
6 |
7 | / import math
8 | | import abc
| |___________^ I001
|
= help: Organize imports