Skip to content

Commit 17f01a4

Browse files
committed
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 77d4545#r1915458616
1 parent 5021f32 commit 17f01a4

3 files changed

+19
-22
lines changed

crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__fstring_format_spec_1.py.snap

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: crates/ruff_python_parser/tests/fixtures.rs
33
input_file: crates/ruff_python_parser/resources/invalid/re_lexing/fstring_format_spec_1.py
4-
snapshot_kind: text
54
---
65
## AST
76

@@ -301,7 +300,7 @@ Module(
301300
5 | f'middle {'string':\
302301
6 | 'format spec'}
303302
| ^ Syntax Error: f-string: expecting '}'
304-
7 |
303+
7 |
305304
8 | f'middle {'string':\\
306305
|
307306

@@ -310,7 +309,7 @@ Module(
310309
5 | f'middle {'string':\
311310
6 | 'format spec'}
312311
| ^^^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons
313-
7 |
312+
7 |
314313
8 | f'middle {'string':\\
315314
|
316315

@@ -319,7 +318,7 @@ Module(
319318
5 | f'middle {'string':\
320319
6 | 'format spec'}
321320
| ^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons
322-
7 |
321+
7 |
323322
8 | f'middle {'string':\\
324323
|
325324

@@ -328,7 +327,7 @@ Module(
328327
5 | f'middle {'string':\
329328
6 | 'format spec'}
330329
| ^^ Syntax Error: missing closing quote in string literal
331-
7 |
330+
7 |
332331
8 | f'middle {'string':\\
333332
|
334333

@@ -337,17 +336,17 @@ Module(
337336
5 | f'middle {'string':\
338337
6 | 'format spec'}
339338
| ^ Syntax Error: Expected a statement
340-
7 |
339+
7 |
341340
8 | f'middle {'string':\\
342341
9 | 'format spec'}
343342
|
344343

345344

346345
|
347346
6 | 'format spec'}
348-
7 |
347+
7 |
349348
8 | f'middle {'string':\\
350-
| Syntax Error: f-string: unterminated string
349+
| ^ Syntax Error: f-string: unterminated string
351350
9 | 'format spec'}
352351
|
353352

@@ -356,7 +355,7 @@ Module(
356355
8 | f'middle {'string':\\
357356
9 | 'format spec'}
358357
| ^^^^^^^^ Syntax Error: Unexpected indentation
359-
10 |
358+
10 |
360359
11 | f'middle {'string':\\\
361360
|
362361

@@ -365,7 +364,7 @@ Module(
365364
8 | f'middle {'string':\\
366365
9 | 'format spec'}
367366
| ^ Syntax Error: Expected a statement
368-
10 |
367+
10 |
369368
11 | f'middle {'string':\\\
370369
|
371370

@@ -374,17 +373,17 @@ Module(
374373
8 | f'middle {'string':\\
375374
9 | 'format spec'}
376375
| ^ Syntax Error: Expected a statement
377-
10 |
376+
10 |
378377
11 | f'middle {'string':\\\
379378
12 | 'format spec'}
380379
|
381380

382381

383382
|
384383
9 | 'format spec'}
385-
10 |
384+
10 |
385+
| ^ Syntax Error: Expected a statement
386386
11 | f'middle {'string':\\\
387-
| Syntax Error: Expected a statement
388387
12 | 'format spec'}
389388
|
390389

@@ -420,5 +419,5 @@ Module(
420419
|
421420
11 | f'middle {'string':\\\
422421
12 | 'format spec'}
423-
| Syntax Error: Expected a statement
422+
| ^ Syntax Error: Expected a statement
424423
|

crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_indent.py.snap

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: crates/ruff_python_parser/tests/fixtures.rs
33
input_file: crates/ruff_python_parser/resources/invalid/statements/if_extra_indent.py
4-
snapshot_kind: text
54
---
65
## AST
76

@@ -92,14 +91,14 @@ Module(
9291
3 | pass
9392
4 | a + b
9493
| ^^^^^^^^ Syntax Error: Unexpected indentation
95-
5 |
94+
5 |
9695
6 | pass
9796
|
9897

9998

10099
|
101100
6 | pass
102-
7 |
101+
7 |
102+
| ^ Syntax Error: Expected a statement
103103
8 | a = 10
104-
| Syntax Error: Expected a statement
105104
|

crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_misspelled_except.py.snap

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: crates/ruff_python_parser/tests/fixtures.rs
33
input_file: crates/ruff_python_parser/resources/inline/err/try_stmt_misspelled_except.py
4-
snapshot_kind: text
54
---
65
## AST
76

@@ -198,8 +197,8 @@ Module(
198197
|
199198
3 | exept: # spellchecker:disable-line
200199
4 | pass
200+
| ^ Syntax Error: Expected a statement
201201
5 | finally:
202-
| Syntax Error: Expected a statement
203202
6 | pass
204203
7 | a = 1
205204
|
@@ -239,8 +238,8 @@ Module(
239238
|
240239
5 | finally:
241240
6 | pass
241+
| ^ Syntax Error: Expected a statement
242242
7 | a = 1
243-
| Syntax Error: Expected a statement
244243
8 | try:
245244
9 | pass
246245
|
@@ -268,6 +267,6 @@ Module(
268267
|
269268
12 | exept: # spellchecker:disable-line
270269
13 | pass
270+
| ^ Syntax Error: Expected a statement
271271
14 | b = 1
272-
| Syntax Error: Expected a statement
273272
|

0 commit comments

Comments
 (0)