From d3898f33c6d426c7a3d3ccab2054b4e215686e55 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Wed, 14 May 2025 04:52:19 -0300 Subject: [PATCH] Remove trailing whitespace from python.gram (#133858) Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com> (cherry picked from commit 6df39765e652ba06267f8e7abae431c37194a23e) --- .pre-commit-config.yaml | 2 ++ Grammar/python.gram | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 66b8aa14b9283a..d952a53cf3c83e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,6 +39,8 @@ repos: exclude: Lib/test/tokenizedata/coding20731.py - id: trailing-whitespace types_or: [c, inc, python, rst] + - id: trailing-whitespace + files: '\.(gram)$' - repo: https://github.com/woodruffw/zizmor-pre-commit rev: v1.6.0 diff --git a/Grammar/python.gram b/Grammar/python.gram index 243d9cdd82bf0f..cc2b58b0fcf49f 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -79,7 +79,7 @@ _PyPegen_parse(Parser *p) # ~ # Commit to the current alternative, even if it fails to parse. # &&e -# Eager parse e. The parser will not backtrack and will immediately +# Eager parse e. The parser will not backtrack and will immediately # fail with SyntaxError if e cannot be parsed. # @@ -640,7 +640,7 @@ type_alias[stmt_ty]: # Type parameter declaration # -------------------------- -type_params[asdl_type_param_seq*]: +type_params[asdl_type_param_seq*]: | invalid_type_params | '[' t=type_param_seq ']' { CHECK_VERSION(asdl_type_param_seq *, 12, "Type parameter lists are", t) } @@ -1307,13 +1307,13 @@ invalid_group: invalid_import: | a='import' ','.dotted_name+ 'from' dotted_name { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "Did you mean to use 'from ... import ...' instead?") } - | 'import' token=NEWLINE { + | 'import' token=NEWLINE { RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") } invalid_import_from_targets: | import_from_as_names ',' NEWLINE { RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") } - | token=NEWLINE { + | token=NEWLINE { RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") } invalid_with_stmt: @@ -1437,5 +1437,5 @@ invalid_factor: invalid_type_params: | '[' token=']' { RAISE_SYNTAX_ERROR_STARTING_FROM( - token, + token, "Type parameter list cannot be empty")}