From 17f01a4355f8ce2419d4ab53446f62e8b9f842c9 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 14 Jan 2025 14:05:45 -0500 Subject: [PATCH] test: add more missing carets This update includes some missing `^` in the diagnostic annotations. This update also includes some shifting of "syntax error" annotations to the end of the preceding line. I believe this is technically a regression, but fixing them has proven quite difficult. I *think* the best way to do that might be to tweak the spans generated by the Python parser errors, but I didn't want to dig into that. (Another approach would be to change the `annotate-snippets` rendering, but when I tried that and managed to fix these regressions, I ended up causing a bunch of other regressions.) Ref https://github.com/astral-sh/ruff/pull/15359/commits/77d454525e26270964183fa08d3f310ef2119d43#r1915458616 --- ...x@re_lexing__fstring_format_spec_1.py.snap | 27 +++++++++---------- ...syntax@statements__if_extra_indent.py.snap | 7 +++-- ..._syntax@try_stmt_misspelled_except.py.snap | 7 +++-- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__fstring_format_spec_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__fstring_format_spec_1.py.snap index 8cb0b79749..dbc237b1d3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__fstring_format_spec_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__fstring_format_spec_1.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/re_lexing/fstring_format_spec_1.py -snapshot_kind: text --- ## AST @@ -301,7 +300,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^ Syntax Error: f-string: expecting '}' -7 | +7 | 8 | f'middle {'string':\\ | @@ -310,7 +309,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^^^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons -7 | +7 | 8 | f'middle {'string':\\ | @@ -319,7 +318,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons -7 | +7 | 8 | f'middle {'string':\\ | @@ -328,7 +327,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^^ Syntax Error: missing closing quote in string literal -7 | +7 | 8 | f'middle {'string':\\ | @@ -337,7 +336,7 @@ Module( 5 | f'middle {'string':\ 6 | 'format spec'} | ^ Syntax Error: Expected a statement -7 | +7 | 8 | f'middle {'string':\\ 9 | 'format spec'} | @@ -345,9 +344,9 @@ Module( | 6 | 'format spec'} -7 | +7 | 8 | f'middle {'string':\\ - | Syntax Error: f-string: unterminated string + | ^ Syntax Error: f-string: unterminated string 9 | 'format spec'} | @@ -356,7 +355,7 @@ Module( 8 | f'middle {'string':\\ 9 | 'format spec'} | ^^^^^^^^ Syntax Error: Unexpected indentation -10 | +10 | 11 | f'middle {'string':\\\ | @@ -365,7 +364,7 @@ Module( 8 | f'middle {'string':\\ 9 | 'format spec'} | ^ Syntax Error: Expected a statement -10 | +10 | 11 | f'middle {'string':\\\ | @@ -374,7 +373,7 @@ Module( 8 | f'middle {'string':\\ 9 | 'format spec'} | ^ Syntax Error: Expected a statement -10 | +10 | 11 | f'middle {'string':\\\ 12 | 'format spec'} | @@ -382,9 +381,9 @@ Module( | 9 | 'format spec'} -10 | +10 | + | ^ Syntax Error: Expected a statement 11 | f'middle {'string':\\\ - | Syntax Error: Expected a statement 12 | 'format spec'} | @@ -420,5 +419,5 @@ Module( | 11 | f'middle {'string':\\\ 12 | 'format spec'} - | Syntax Error: Expected a statement + | ^ Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_indent.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_indent.py.snap index 4c589dda56..76a3ff101f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_indent.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_indent.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/invalid/statements/if_extra_indent.py -snapshot_kind: text --- ## AST @@ -92,14 +91,14 @@ Module( 3 | pass 4 | a + b | ^^^^^^^^ Syntax Error: Unexpected indentation -5 | +5 | 6 | pass | | 6 | pass -7 | +7 | + | ^ Syntax Error: Expected a statement 8 | a = 10 - | Syntax Error: Expected a statement | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_misspelled_except.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_misspelled_except.py.snap index 4180af0311..93dc9f223d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_misspelled_except.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_misspelled_except.py.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs input_file: crates/ruff_python_parser/resources/inline/err/try_stmt_misspelled_except.py -snapshot_kind: text --- ## AST @@ -198,8 +197,8 @@ Module( | 3 | exept: # spellchecker:disable-line 4 | pass + | ^ Syntax Error: Expected a statement 5 | finally: - | Syntax Error: Expected a statement 6 | pass 7 | a = 1 | @@ -239,8 +238,8 @@ Module( | 5 | finally: 6 | pass + | ^ Syntax Error: Expected a statement 7 | a = 1 - | Syntax Error: Expected a statement 8 | try: 9 | pass | @@ -268,6 +267,6 @@ Module( | 12 | exept: # spellchecker:disable-line 13 | pass + | ^ Syntax Error: Expected a statement 14 | b = 1 - | Syntax Error: Expected a statement |