From 5caef89af32f2631a6cbc63fd5efd2b0fc4382b9 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 7 Jan 2025 14:46:50 -0500 Subject: [PATCH] test: update snapshots with improper end-of-line placement This looks like a bug fix that occurs when the annotation is a zero-width span immediately following a line terminator. Previously, the caret seems to be rendered on the next line, but it should be rendered at the end of the line the span corresponds to. I admit that this one is kinda weird. I would somewhat expect that our spans here are actually incorrect, and that to obtain this sort of rendering, we should identify a span just immediately _before_ the line terminator and not after it. But I don't want to dive into that rabbit hole for now (and given how `annotate-snippets` now renders these spans, perhaps there is more to it than I see), and this does seem like a clear improvement given the spans we feed to `annotate-snippets`. --- ...rules__isort__tests__line_ending_crlf.py.snap | 7 +++---- ...__rules__isort__tests__line_ending_lf.py.snap | 7 +++---- ...er__rules__isort__tests__no_wrap_star.py.snap | 4 ++-- ...ff_linter__rules__isort__tests__split.py.snap | 16 ++++++++-------- ...nvalid_syntax@if_stmt_misspelled_elif.py.snap | 4 ++-- ...syntax@match_stmt_expected_case_block.py.snap | 4 ++-- ...ntax@re_lex_logical_token_windows_eol.py.snap | 10 ++++------ ...lexing__line_continuation_windows_eol.py.snap | 12 +++++------- 8 files changed, 29 insertions(+), 35 deletions(-) diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap index fd6eeec94b..7a82945f64 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- line_ending_crlf.py:1:1: I001 [*] Import block is un-sorted or un-formatted | -1 | / from long_module_name import member_one, member_two, member_three, member_four, member_five -2 | | - | |_^ I001 +1 | from long_module_name import member_one, member_two, member_three, member_four, member_five + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 +2 | | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap index cdf02f650d..88cb9c8fab 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- line_ending_lf.py:1:1: I001 [*] Import block is un-sorted or un-formatted | -1 | / from long_module_name import member_one, member_two, member_three, member_four, member_five -2 | | - | |_^ I001 +1 | from long_module_name import member_one, member_two, member_three, member_four, member_five + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 +2 | | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap index e4116bc077..cdaf1e3466 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- no_wrap_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted | -1 | / from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore +1 | from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 | = help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap index aa18086932..40de22a232 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap @@ -1,14 +1,13 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- split.py:15:1: I001 [*] Import block is un-sorted or un-formatted | 14 | if True: 15 | / import C 16 | | import A -17 | | - | |_^ I001 + | |_____________^ I001 +17 | 18 | # isort: split | = help: Organize imports @@ -27,12 +26,12 @@ split.py:15:1: I001 [*] Import block is un-sorted or un-formatted split.py:20:1: I001 [*] Import block is un-sorted or un-formatted | 18 | # isort: split -19 | +19 | 20 | / import D 21 | | import B -22 | | - | |_^ I001 -23 | + | |_____________^ I001 +22 | +23 | 24 | import e | = help: Organize imports @@ -51,9 +50,10 @@ split.py:20:1: I001 [*] Import block is un-sorted or un-formatted split.py:30:1: I001 [*] Import block is un-sorted or un-formatted | 28 | # isort: split -29 | +29 | 30 | / import d 31 | | import c + | |_________^ I001 | = help: Organize imports diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_misspelled_elif.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_misspelled_elif.py.snap index 8be2a8ac49..b8d421961c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_misspelled_elif.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_misspelled_elif.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/if_stmt_misspelled_elif.py -snapshot_kind: text --- ## AST @@ -90,8 +89,8 @@ Module( | 3 | elf: 4 | pass + | ^ Syntax Error: Expected a statement 5 | else: - | Syntax Error: Expected a statement 6 | pass | @@ -125,4 +124,5 @@ Module( | 5 | else: 6 | pass + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expected_case_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expected_case_block.py.snap index ec0d060459..2844e904f7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expected_case_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expected_case_block.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/match_stmt_expected_case_block.py -snapshot_kind: text --- ## AST @@ -113,8 +112,8 @@ Module( | 1 | match x: 2 | x = 1 + | ^ Syntax Error: Expected a statement 3 | match x: - | Syntax Error: Expected a statement 4 | match y: 5 | case _: ... | @@ -132,4 +131,5 @@ Module( | 4 | match y: 5 | case _: ... + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_windows_eol.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_windows_eol.py.snap index 912c68cf07..31bb3a87f2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_windows_eol.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_windows_eol.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lex_logical_token_windows_eol.py -snapshot_kind: text --- ## AST @@ -100,9 +99,8 @@ Module( ## Errors | -1 | if call(foo, [a, b - | ___________________^ -2 | | def bar(): - | |_^ Syntax Error: Expected ']', found NonLogicalNewline -3 | pass +1 | if call(foo, [a, b + | ^ Syntax Error: Expected ']', found NonLogicalNewline +2 | def bar(): +3 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_windows_eol.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_windows_eol.py.snap index b7679b43b9..935f436e82 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_windows_eol.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_windows_eol.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lexing/line_continuation_windows_eol.py -snapshot_kind: text --- ## AST @@ -82,10 +81,9 @@ Module( ## Errors | -1 | call(a, b, # comment \ - | _______________________^ -2 | | - | |_^ Syntax Error: Expected ')', found newline -3 | def bar(): -4 | pass +1 | call(a, b, # comment \ + | ^ Syntax Error: Expected ')', found newline +2 | +3 | def bar(): +4 | pass |