From 7b42997056c62c5b23af69253f1e60ffcc43bca7 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Fri, 28 Jun 2024 11:36:02 +0530 Subject: [PATCH] Update snapshots with syntax errors --- .../flake8_commas/rules/trailing_commas.rs | 2 +- ...at__tests__ISC001_ISC_syntax_error.py.snap | 133 ++++++++++++++++++ ...at__tests__ISC002_ISC_syntax_error.py.snap | 131 +++++++++++++++++ ...tyle__tests__E301_E30_syntax_error.py.snap | 41 +++++- ...tyle__tests__E302_E30_syntax_error.py.snap | 41 +++++- ...tyle__tests__E303_E30_syntax_error.py.snap | 39 +++++ ...tyle__tests__E305_E30_syntax_error.py.snap | 41 +++++- ...tyle__tests__E306_E30_syntax_error.py.snap | 39 +++++ ...10_invalid_characters_syntax_error.py.snap | 58 ++++++++ 9 files changed, 521 insertions(+), 4 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs b/crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs index f7b2d83d68318..71993c038c25f 100644 --- a/crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs +++ b/crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs @@ -253,7 +253,7 @@ pub(crate) fn trailing_commas( None } } - kind => { + _ => { if fstrings == 0 { Some(SimpleToken::from(token.as_tuple())) } else { diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap index 9673691d162d1..eb711539e5930 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap @@ -1,6 +1,25 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs --- +ISC_syntax_error.py:2:5: SyntaxError: missing closing quote in string literal + | +1 | # The lexer doesn't emit a string token if it's unterminated +2 | "a" "b + | ^ +3 | "a" "b" "c +4 | "a" """b + | + +ISC_syntax_error.py:2:7: SyntaxError: Expected a statement + | +1 | # The lexer doesn't emit a string token if it's unterminated +2 | "a" "b + | ^ +3 | "a" "b" "c +4 | "a" """b +5 | c""" "d + | + ISC_syntax_error.py:3:1: ISC001 [*] Implicitly concatenated string literals on one line | 1 | # The lexer doesn't emit a string token if it's unterminated @@ -21,6 +40,26 @@ ISC_syntax_error.py:3:1: ISC001 [*] Implicitly concatenated string literals on o 5 5 | c""" "d 6 6 | +ISC_syntax_error.py:3:9: SyntaxError: missing closing quote in string literal + | +1 | # The lexer doesn't emit a string token if it's unterminated +2 | "a" "b +3 | "a" "b" "c + | ^ +4 | "a" """b +5 | c""" "d + | + +ISC_syntax_error.py:3:11: SyntaxError: Expected a statement + | +1 | # The lexer doesn't emit a string token if it's unterminated +2 | "a" "b +3 | "a" "b" "c + | ^ +4 | "a" """b +5 | c""" "d + | + ISC_syntax_error.py:4:1: ISC001 Implicitly concatenated string literals on one line | 2 | "a" "b @@ -33,6 +72,48 @@ ISC_syntax_error.py:4:1: ISC001 Implicitly concatenated string literals on one l | = help: Combine string literals +ISC_syntax_error.py:5:6: SyntaxError: missing closing quote in string literal + | +3 | "a" "b" "c +4 | "a" """b +5 | c""" "d + | ^ +6 | +7 | # For f-strings, the `FStringRanges` won't contain the range for + | + +ISC_syntax_error.py:5:8: SyntaxError: Expected a statement + | +3 | "a" "b" "c +4 | "a" """b +5 | c""" "d + | ^ +6 | +7 | # For f-strings, the `FStringRanges` won't contain the range for +8 | # unterminated f-strings. + | + +ISC_syntax_error.py:9:8: SyntaxError: f-string: unterminated string + | + 7 | # For f-strings, the `FStringRanges` won't contain the range for + 8 | # unterminated f-strings. + 9 | f"a" f"b + | ^ +10 | f"a" f"b" f"c +11 | f"a" f"""b + | + +ISC_syntax_error.py:9:9: SyntaxError: Expected FStringEnd, found newline + | + 7 | # For f-strings, the `FStringRanges` won't contain the range for + 8 | # unterminated f-strings. + 9 | f"a" f"b + | ^ +10 | f"a" f"b" f"c +11 | f"a" f"""b +12 | c""" f"d {e + | + ISC_syntax_error.py:10:1: ISC001 [*] Implicitly concatenated string literals on one line | 8 | # unterminated f-strings. @@ -54,6 +135,26 @@ ISC_syntax_error.py:10:1: ISC001 [*] Implicitly concatenated string literals on 12 12 | c""" f"d {e 13 13 | +ISC_syntax_error.py:10:13: SyntaxError: f-string: unterminated string + | + 8 | # unterminated f-strings. + 9 | f"a" f"b +10 | f"a" f"b" f"c + | ^ +11 | f"a" f"""b +12 | c""" f"d {e + | + +ISC_syntax_error.py:10:14: SyntaxError: Expected FStringEnd, found newline + | + 8 | # unterminated f-strings. + 9 | f"a" f"b +10 | f"a" f"b" f"c + | ^ +11 | f"a" f"""b +12 | c""" f"d {e + | + ISC_syntax_error.py:11:1: ISC001 Implicitly concatenated string literals on one line | 9 | f"a" f"b @@ -65,3 +166,35 @@ ISC_syntax_error.py:11:1: ISC001 Implicitly concatenated string literals on one 14 | ( | = help: Combine string literals + +ISC_syntax_error.py:16:5: SyntaxError: missing closing quote in string literal + | +14 | ( +15 | "a" +16 | "b + | ^ +17 | "c" +18 | "d" + | + +ISC_syntax_error.py:26:9: SyntaxError: f-string: unterminated triple-quoted string + | +24 | ( +25 | """abc""" +26 | f"""def + | ^ +27 | "g" "h" +28 | "i" "j" + | + +ISC_syntax_error.py:30:1: SyntaxError: unexpected EOF while parsing + | +28 | "i" "j" +29 | ) + | + +ISC_syntax_error.py:30:1: SyntaxError: f-string: unterminated string + | +28 | "i" "j" +29 | ) + | diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap index 1858d1d7e1447..c09ec34c0f08e 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap @@ -1,4 +1,135 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs --- +ISC_syntax_error.py:2:5: SyntaxError: missing closing quote in string literal + | +1 | # The lexer doesn't emit a string token if it's unterminated +2 | "a" "b + | ^ +3 | "a" "b" "c +4 | "a" """b + | +ISC_syntax_error.py:2:7: SyntaxError: Expected a statement + | +1 | # The lexer doesn't emit a string token if it's unterminated +2 | "a" "b + | ^ +3 | "a" "b" "c +4 | "a" """b +5 | c""" "d + | + +ISC_syntax_error.py:3:9: SyntaxError: missing closing quote in string literal + | +1 | # The lexer doesn't emit a string token if it's unterminated +2 | "a" "b +3 | "a" "b" "c + | ^ +4 | "a" """b +5 | c""" "d + | + +ISC_syntax_error.py:3:11: SyntaxError: Expected a statement + | +1 | # The lexer doesn't emit a string token if it's unterminated +2 | "a" "b +3 | "a" "b" "c + | ^ +4 | "a" """b +5 | c""" "d + | + +ISC_syntax_error.py:5:6: SyntaxError: missing closing quote in string literal + | +3 | "a" "b" "c +4 | "a" """b +5 | c""" "d + | ^ +6 | +7 | # For f-strings, the `FStringRanges` won't contain the range for + | + +ISC_syntax_error.py:5:8: SyntaxError: Expected a statement + | +3 | "a" "b" "c +4 | "a" """b +5 | c""" "d + | ^ +6 | +7 | # For f-strings, the `FStringRanges` won't contain the range for +8 | # unterminated f-strings. + | + +ISC_syntax_error.py:9:8: SyntaxError: f-string: unterminated string + | + 7 | # For f-strings, the `FStringRanges` won't contain the range for + 8 | # unterminated f-strings. + 9 | f"a" f"b + | ^ +10 | f"a" f"b" f"c +11 | f"a" f"""b + | + +ISC_syntax_error.py:9:9: SyntaxError: Expected FStringEnd, found newline + | + 7 | # For f-strings, the `FStringRanges` won't contain the range for + 8 | # unterminated f-strings. + 9 | f"a" f"b + | ^ +10 | f"a" f"b" f"c +11 | f"a" f"""b +12 | c""" f"d {e + | + +ISC_syntax_error.py:10:13: SyntaxError: f-string: unterminated string + | + 8 | # unterminated f-strings. + 9 | f"a" f"b +10 | f"a" f"b" f"c + | ^ +11 | f"a" f"""b +12 | c""" f"d {e + | + +ISC_syntax_error.py:10:14: SyntaxError: Expected FStringEnd, found newline + | + 8 | # unterminated f-strings. + 9 | f"a" f"b +10 | f"a" f"b" f"c + | ^ +11 | f"a" f"""b +12 | c""" f"d {e + | + +ISC_syntax_error.py:16:5: SyntaxError: missing closing quote in string literal + | +14 | ( +15 | "a" +16 | "b + | ^ +17 | "c" +18 | "d" + | + +ISC_syntax_error.py:26:9: SyntaxError: f-string: unterminated triple-quoted string + | +24 | ( +25 | """abc""" +26 | f"""def + | ^ +27 | "g" "h" +28 | "i" "j" + | + +ISC_syntax_error.py:30:1: SyntaxError: unexpected EOF while parsing + | +28 | "i" "j" +29 | ) + | + +ISC_syntax_error.py:30:1: SyntaxError: f-string: unterminated string + | +28 | "i" "j" +29 | ) + | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap index 77f286a07efe2..b5ac87140db0c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap @@ -1,6 +1,25 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- +E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' + | +2 | # parenthesis. +3 | +4 | def foo[T1, T2(): + | ^ +5 | pass + | + +E30_syntax_error.py:13:18: SyntaxError: Expected ')', found newline + | +12 | class Foo: +13 | def __init__( + | ^ +14 | pass +15 | def method(): +16 | pass + | + E30_syntax_error.py:15:5: E301 [*] Expected 1 blank line, found 0 | 13 | def __init__( @@ -18,4 +37,24 @@ E30_syntax_error.py:15:5: E301 [*] Expected 1 blank line, found 0 15 |+ 15 16 | def method(): 16 17 | pass -17 18 | +17 18 | + +E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline + | +16 | pass +17 | +18 | foo = Foo( + | ^ +19 | +20 | +21 | def top( + | + +E30_syntax_error.py:21:9: SyntaxError: Expected ')', found newline + | +21 | def top( + | ^ +22 | def nested1(): +23 | pass +24 | def nested2(): + | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap index 5f1a18fc2a871..80dc54e8aed86 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap @@ -1,6 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- +E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' + | +2 | # parenthesis. +3 | +4 | def foo[T1, T2(): + | ^ +5 | pass + | + E30_syntax_error.py:7:1: E302 [*] Expected 2 blank lines, found 1 | 5 | pass @@ -18,4 +27,34 @@ E30_syntax_error.py:7:1: E302 [*] Expected 2 blank lines, found 1 7 |+ 7 8 | def bar(): 8 9 | pass -9 10 | +9 10 | + +E30_syntax_error.py:13:18: SyntaxError: Expected ')', found newline + | +12 | class Foo: +13 | def __init__( + | ^ +14 | pass +15 | def method(): +16 | pass + | + +E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline + | +16 | pass +17 | +18 | foo = Foo( + | ^ +19 | +20 | +21 | def top( + | + +E30_syntax_error.py:21:9: SyntaxError: Expected ')', found newline + | +21 | def top( + | ^ +22 | def nested1(): +23 | pass +24 | def nested2(): + | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap index ca3ff1ffc57ac..5d173263ca59d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap @@ -1,6 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- +E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' + | +2 | # parenthesis. +3 | +4 | def foo[T1, T2(): + | ^ +5 | pass + | + E30_syntax_error.py:12:1: E303 [*] Too many blank lines (3) | 12 | class Foo: @@ -18,3 +27,33 @@ E30_syntax_error.py:12:1: E303 [*] Too many blank lines (3) 12 11 | class Foo: 13 12 | def __init__( 14 13 | pass + +E30_syntax_error.py:13:18: SyntaxError: Expected ')', found newline + | +12 | class Foo: +13 | def __init__( + | ^ +14 | pass +15 | def method(): +16 | pass + | + +E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline + | +16 | pass +17 | +18 | foo = Foo( + | ^ +19 | +20 | +21 | def top( + | + +E30_syntax_error.py:21:9: SyntaxError: Expected ')', found newline + | +21 | def top( + | ^ +22 | def nested1(): +23 | pass +24 | def nested2(): + | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap index 0c81c7cb30ed7..7b3890df98035 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap @@ -1,6 +1,25 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- +E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' + | +2 | # parenthesis. +3 | +4 | def foo[T1, T2(): + | ^ +5 | pass + | + +E30_syntax_error.py:13:18: SyntaxError: Expected ')', found newline + | +12 | class Foo: +13 | def __init__( + | ^ +14 | pass +15 | def method(): +16 | pass + | + E30_syntax_error.py:18:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) | 16 | pass @@ -17,4 +36,24 @@ E30_syntax_error.py:18:1: E305 [*] Expected 2 blank lines after class or functio 18 |+ 18 19 | foo = Foo( 19 20 | -20 21 | +20 21 | + +E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline + | +16 | pass +17 | +18 | foo = Foo( + | ^ +19 | +20 | +21 | def top( + | + +E30_syntax_error.py:21:9: SyntaxError: Expected ')', found newline + | +21 | def top( + | ^ +22 | def nested1(): +23 | pass +24 | def nested2(): + | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap index 4e7c04f94db4c..97821e0f8e23b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap @@ -1,6 +1,45 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- +E30_syntax_error.py:4:15: SyntaxError: Expected ']', found '(' + | +2 | # parenthesis. +3 | +4 | def foo[T1, T2(): + | ^ +5 | pass + | + +E30_syntax_error.py:13:18: SyntaxError: Expected ')', found newline + | +12 | class Foo: +13 | def __init__( + | ^ +14 | pass +15 | def method(): +16 | pass + | + +E30_syntax_error.py:18:11: SyntaxError: Expected ')', found newline + | +16 | pass +17 | +18 | foo = Foo( + | ^ +19 | +20 | +21 | def top( + | + +E30_syntax_error.py:21:9: SyntaxError: Expected ')', found newline + | +21 | def top( + | ^ +22 | def nested1(): +23 | pass +24 | def nested2(): + | + E30_syntax_error.py:24:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | 22 | def nested1(): diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters_syntax_error.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters_syntax_error.py.snap index 4d27ee862d439..3ebcb6b640330 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters_syntax_error.py.snap @@ -21,6 +21,27 @@ invalid_characters_syntax_error.py:5:6: PLE2510 [*] Invalid unescaped character 7 7 | b = '␈ 8 8 | b = '␈' +invalid_characters_syntax_error.py:7:5: SyntaxError: missing closing quote in string literal + | +5 | b = '␈' +6 | # Unterminated string +7 | b = '␈ + | ^ +8 | b = '␈' +9 | # Unterminated f-string + | + +invalid_characters_syntax_error.py:7:7: SyntaxError: Expected a statement + | + 5 | b = '␈' + 6 | # Unterminated string + 7 | b = '␈ + | ^ + 8 | b = '␈' + 9 | # Unterminated f-string +10 | b = f'␈ + | + invalid_characters_syntax_error.py:8:6: PLE2510 [*] Invalid unescaped character backspace, use "\b" instead | 6 | # Unterminated string @@ -42,6 +63,27 @@ invalid_characters_syntax_error.py:8:6: PLE2510 [*] Invalid unescaped character 10 10 | b = f'␈ 11 11 | b = f'␈' +invalid_characters_syntax_error.py:10:7: SyntaxError: f-string: unterminated string + | + 8 | b = '␈' + 9 | # Unterminated f-string +10 | b = f'␈ + | ^ +11 | b = f'␈' +12 | # Implicitly concatenated + | + +invalid_characters_syntax_error.py:10:8: SyntaxError: Expected FStringEnd, found newline + | + 8 | b = '␈' + 9 | # Unterminated f-string +10 | b = f'␈ + | ^ +11 | b = f'␈' +12 | # Implicitly concatenated +13 | b = '␈' f'␈' '␈ + | + invalid_characters_syntax_error.py:11:7: PLE2510 [*] Invalid unescaped character backspace, use "\b" instead | 9 | # Unterminated f-string @@ -93,3 +135,19 @@ invalid_characters_syntax_error.py:13:11: PLE2510 [*] Invalid unescaped characte 12 12 | # Implicitly concatenated 13 |-b = '␈' f'␈' '␈ 13 |+b = '␈' f'\b' '␈ + +invalid_characters_syntax_error.py:13:14: SyntaxError: missing closing quote in string literal + | +11 | b = f'␈' +12 | # Implicitly concatenated +13 | b = '␈' f'␈' '␈ + | ^ + | + +invalid_characters_syntax_error.py:13:16: SyntaxError: Expected a statement + | +11 | b = f'␈' +12 | # Implicitly concatenated +13 | b = '␈' f'␈' '␈ + | ^ + |