From 1d8e54da7ffc280f4e8af1c1c8646439f401bba6 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 31 Aug 2026 16:10:03 +0900 Subject: [PATCH 01/20] Patch Ruff for RustPython Expose RustPython AST metadata fields, apply the RustPython package patch, and make CI usable on fork runners. Assisted-by: Codex:GPT-5 Assisted-by: Grok:grok-4.6 Assisted-by: Claude Code:claude-opus-5-5 --- .github/workflows/ci.yaml | 8 +- .github/workflows/release.yml | 2 +- .github/workflows/ty-ecosystem-analyzer.yaml | 2 +- Cargo.lock | 424 ++++++++--------- Cargo.toml | 16 +- crates/ruff_graph/src/collector.rs | 2 + .../checkers/ast/analyze/except_handler.rs | 1 + .../src/checkers/ast/analyze/expression.rs | 4 + .../src/checkers/ast/analyze/statement.rs | 12 + crates/ruff_linter/src/checkers/ast/mod.rs | 15 + crates/ruff_linter/src/importer/mod.rs | 1 + .../rules/runtime_value_in_dag_or_task.rs | 1 + .../flake8_annotations/rules/definition.rs | 4 + .../rules/hardcoded_sql_expression.rs | 1 + .../flake8_bugbear/rules/assert_false.rs | 2 + .../rules/delattr_with_constant.rs | 1 + .../rules/duplicate_exceptions.rs | 1 + .../rules/loop_iterator_mutation.rs | 5 + .../rules/reuse_of_groupby_generator.rs | 1 + .../rules/setattr_with_constant.rs | 3 + ...cessary_dict_comprehension_for_iterable.rs | 2 + .../rules/unnecessary_list_call.rs | 2 + .../rules/multiple_starts_ends_with.rs | 9 + .../rules/duplicate_literal_member.rs | 1 + .../flake8_pyi/rules/exit_annotations.rs | 1 + .../src/rules/flake8_pyi/rules/mod.rs | 1 + .../rules/redundant_none_literal.rs | 1 + .../rules/flake8_pyi/rules/simple_defaults.rs | 1 + .../rules/unnecessary_literal_union.rs | 2 + .../rules/unnecessary_type_union.rs | 2 + .../flake8_pytest_style/rules/assertion.rs | 1 + .../flake8_pytest_style/rules/parametrize.rs | 4 + .../rules/unittest_assert.rs | 5 + .../flake8_simplify/rules/ast_bool_op.rs | 10 + .../rules/flake8_simplify/rules/ast_ifexp.rs | 2 + .../flake8_simplify/rules/ast_unary_op.rs | 4 + .../if_else_block_instead_of_dict_get.rs | 7 + .../rules/if_else_block_instead_of_if_exp.rs | 12 + .../flake8_simplify/rules/needless_bool.rs | 7 + .../rules/reimplemented_builtin.rs | 6 + .../rules/split_static_string.rs | 1 + .../rules/relative_imports.rs | 1 + crates/ruff_linter/src/rules/flynt/helpers.rs | 5 + .../ruff_linter/src/rules/isort/annotate.rs | 1 + .../rules/isort/rules/add_required_imports.rs | 1 + .../rules/manual_dict_comprehension.rs | 3 + .../rules/manual_list_comprehension.rs | 2 + .../rules/perflint/rules/manual_list_copy.rs | 2 + .../perflint/rules/unnecessary_list_cast.rs | 2 + .../pycodestyle/rules/lambda_assignment.rs | 8 + .../pylint/rules/bad_string_format_type.rs | 1 + .../src/rules/pylint/rules/if_stmt_min_max.rs | 1 + .../rules/pylint/rules/manual_import_from.rs | 1 + .../src/rules/pylint/rules/nested_min_max.rs | 4 + .../rules/pylint/rules/redefined_loop_name.rs | 2 + .../rules/repeated_equality_comparison.rs | 4 + ...convert_named_tuple_functional_to_class.rs | 5 + .../convert_typed_dict_functional_to_class.rs | 6 + .../rules/deprecated_c_element_tree.rs | 1 + .../rules/lru_cache_with_maxsize_none.rs | 2 + .../rules/pyupgrade/rules/native_literals.rs | 2 + .../rules/pyupgrade/rules/os_error_alias.rs | 1 + .../src/rules/pyupgrade/rules/pep695/mod.rs | 2 + .../rules/printf_string_formatting.rs | 1 + .../pyupgrade/rules/timeout_error_alias.rs | 1 + .../rules/unnecessary_default_type_args.rs | 2 + .../pyupgrade/rules/use_pep604_annotation.rs | 1 + .../pyupgrade/rules/yield_in_for_loop.rs | 4 + .../ruff_linter/src/rules/refurb/helpers.rs | 3 + .../src/rules/refurb/rules/bit_count.rs | 1 + .../refurb/rules/check_and_remove_from_set.rs | 2 + .../src/rules/refurb/rules/read_whole_file.rs | 2 + .../refurb/rules/reimplemented_starmap.rs | 4 + .../src/rules/refurb/rules/repeated_append.rs | 3 + .../rules/slice_to_remove_prefix_or_suffix.rs | 4 + .../refurb/rules/unnecessary_enumerate.rs | 4 + .../ruff/rules/assert_with_print_message.rs | 5 + .../rules/collection_literal_concatenation.rs | 2 + .../invalid_formatter_suppression_comment.rs | 1 + .../ruff/rules/legacy_form_pytest_raises.rs | 10 + .../ruff/rules/map_int_version_parsing.rs | 2 + .../ruff/rules/mutable_fromkeys_value.rs | 2 + .../src/rules/ruff/rules/never_union.rs | 1 + .../ruff/rules/none_not_at_end_of_union.rs | 1 + .../src/rules/ruff/rules/sort_dunder_slots.rs | 1 + .../ruff/rules/unnecessary_nested_literal.rs | 1 + .../rules/unnecessary_regular_expression.rs | 3 + crates/ruff_python_ast/Cargo.toml | 7 +- crates/ruff_python_ast/ast.toml | 89 +++- crates/ruff_python_ast/generate.py | 5 +- crates/ruff_python_ast/src/comparable.rs | 438 +++++++---------- crates/ruff_python_ast/src/generated.rs | 202 ++++++++ crates/ruff_python_ast/src/helpers.rs | 80 ++-- crates/ruff_python_ast/src/node.rs | 47 +- crates/ruff_python_ast/src/nodes.rs | 73 ++- .../src/operator_precedence.rs | 1 + crates/ruff_python_ast/src/relocate.rs | 3 + crates/ruff_python_ast/src/visitor.rs | 208 ++------ .../src/visitor/source_order.rs | 1 + .../src/visitor/transformer.rs | 215 ++------- .../tests/visitor.rs | 1 + crates/ruff_python_codegen/src/generator.rs | 22 + crates/ruff_python_formatter/generate.py | 2 +- .../src/expression/expr_constant.rs | 13 + .../src/expression/expr_dict.rs | 1 + .../src/expression/expr_list.rs | 1 + .../src/expression/expr_set.rs | 1 + .../src/expression/expr_tuple.rs | 1 + .../src/expression/mod.rs | 10 + crates/ruff_python_formatter/src/generated.rs | 36 ++ .../src/module/mod_module.rs | 1 + .../src/other/arguments.rs | 2 + .../src/other/comprehension.rs | 2 + .../other/except_handler_except_handler.rs | 1 + .../src/other/match_case.rs | 1 + .../src/other/parameter.rs | 2 + .../src/other/parameters.rs | 1 + .../src/pattern/pattern_match_class.rs | 3 + .../src/pattern/pattern_match_mapping.rs | 4 + .../src/pattern/pattern_match_or.rs | 1 + .../src/pattern/pattern_match_sequence.rs | 1 + crates/ruff_python_formatter/src/range.rs | 5 + .../src/statement/clause.rs | 20 + .../src/statement/stmt_ann_assign.rs | 1 + .../src/statement/stmt_assign.rs | 3 + .../src/statement/stmt_class_def.rs | 2 + .../src/statement/stmt_delete.rs | 1 + .../src/statement/stmt_for.rs | 4 + .../src/statement/stmt_function_def.rs | 4 + .../src/statement/stmt_if.rs | 3 + .../src/statement/stmt_import_from.rs | 1 + .../src/statement/stmt_try.rs | 4 + .../src/statement/stmt_while.rs | 2 + crates/ruff_python_parser/Cargo.toml | 7 +- crates/ruff_python_parser/src/lib.rs | 1 + .../src/parser/expression.rs | 24 + .../ruff_python_parser/src/parser/helpers.rs | 1 + crates/ruff_python_parser/src/parser/mod.rs | 1 + .../ruff_python_parser/src/parser/pattern.rs | 8 + .../ruff_python_parser/src/parser/recovery.rs | 7 + ...arser__tests__ipython_escape_commands.snap | 29 ++ ...arser__parser__tests__unicode_aliases.snap | 3 + .../src/parser/statement.rs | 37 ++ ...ests__dont_panic_on_8_in_octal_escape.snap | 3 + ...string__tests__fstring_constant_range.snap | 8 + ...ing__tests__fstring_escaped_character.snap | 5 + ...tring__tests__fstring_escaped_newline.snap | 5 + ...ing__tests__fstring_line_continuation.snap | 5 + ...__fstring_parse_self_documenting_base.snap | 5 + ...ring_parse_self_documenting_base_more.snap | 8 + ...fstring_parse_self_documenting_format.snap | 5 + ...ing__tests__fstring_unescaped_newline.snap | 5 + ...r__string__tests__parse_empty_fstring.snap | 2 + ...r__string__tests__parse_empty_tstring.snap | 2 + ...tring__tests__parse_f_string_concat_1.snap | 2 + ...tring__tests__parse_f_string_concat_2.snap | 2 + ...tring__tests__parse_f_string_concat_3.snap | 5 + ...tring__tests__parse_f_string_concat_4.snap | 5 + ..._parser__string__tests__parse_fstring.snap | 8 + ...__string__tests__parse_fstring_equals.snap | 6 + ...ring_nested_concatenation_string_spec.snap | 8 + ...ing__tests__parse_fstring_nested_spec.snap | 8 + ...sts__parse_fstring_nested_string_spec.snap | 8 + ...ring__tests__parse_fstring_not_equals.snap | 6 + ..._tests__parse_fstring_not_nested_spec.snap | 5 + ...ts__parse_fstring_self_doc_prec_space.snap | 5 + ...parse_fstring_self_doc_trailing_space.snap | 5 + ...ring__tests__parse_fstring_yield_expr.snap | 5 + ..._parser__string__tests__parse_tstring.snap | 8 + ...__string__tests__parse_tstring_equals.snap | 6 + ...ring_nested_concatenation_string_spec.snap | 8 + ...ing__tests__parse_tstring_nested_spec.snap | 8 + ...sts__parse_tstring_nested_string_spec.snap | 8 + ...ring__tests__parse_tstring_not_equals.snap | 6 + ..._tests__parse_tstring_not_nested_spec.snap | 5 + ...ts__parse_tstring_self_doc_prec_space.snap | 5 + ...parse_tstring_self_doc_trailing_space.snap | 5 + ...ring__tests__parse_tstring_yield_expr.snap | 5 + ...ing__tests__parse_u_f_string_concat_1.snap | 2 + ...ing__tests__parse_u_f_string_concat_2.snap | 2 + ...on_parser__string__tests__raw_fstring.snap | 5 + ...on_parser__string__tests__raw_tstring.snap | 5 + ...ing__tests__triple_quoted_raw_fstring.snap | 5 + ...ing__tests__triple_quoted_raw_tstring.snap | 5 + ...string__tests__tstring_constant_range.snap | 8 + ...ing__tests__tstring_escaped_character.snap | 5 + ...tring__tests__tstring_escaped_newline.snap | 5 + ...ing__tests__tstring_line_continuation.snap | 5 + ...__tstring_parse_self_documenting_base.snap | 5 + ...ring_parse_self_documenting_base_more.snap | 8 + ...tstring_parse_self_documenting_format.snap | 5 + ...ing__tests__tstring_unescaped_newline.snap | 5 + ...ann_assign_stmt_invalid_annotation.py.snap | 8 + ...tax@ann_assign_stmt_invalid_target.py.snap | 20 + ...ntax@ann_assign_stmt_invalid_value.py.snap | 7 + ...syntax@ann_assign_stmt_missing_rhs.py.snap | 2 + ..._assign_stmt_type_alias_annotation.py.snap | 8 + ...tax@args_unparenthesized_generator.py.snap | 19 + .../invalid_syntax@assert_empty_msg.py.snap | 1 + .../invalid_syntax@assert_empty_test.py.snap | 1 + ...lid_syntax@assert_invalid_msg_expr.py.snap | 1 + ...id_syntax@assert_invalid_test_expr.py.snap | 1 + ..._syntax@assign_stmt_invalid_target.py.snap | 15 + ...tax@assign_stmt_invalid_value_expr.py.snap | 24 + ..._syntax@assign_stmt_keyword_target.py.snap | 7 + ...lid_syntax@assign_stmt_missing_rhs.py.snap | 10 + ...tax@assign_stmt_starred_expr_value.py.snap | 17 + ...alid_syntax@async_unexpected_token.py.snap | 14 + ...tax@aug_assign_stmt_invalid_target.py.snap | 1 + ...ntax@aug_assign_stmt_invalid_value.py.snap | 5 + ...syntax@aug_assign_stmt_missing_rhs.py.snap | 1 + ...ash_continuation_indentation_error.py.snap | 2 + ..._syntax@case_expect_indented_block.py.snap | 3 + ...nvalid_syntax@class_def_empty_body.py.snap | 10 + ...alid_syntax@class_def_missing_name.py.snap | 11 + ...class_def_unclosed_type_param_list.py.snap | 9 + ...unparenthesized_generator_argument.py.snap | 7 + ...lid_syntax@class_type_params_py311.py.snap | 8 + ...yntax@clause_expect_indented_block.py.snap | 3 + ...tax@clause_expect_single_statement.py.snap | 3 + ...ntax@comma_separated_missing_comma.py.snap | 3 + ...ted_missing_comma_between_elements.py.snap | 2 + ...ted_missing_element_between_commas.py.snap | 2 + ...ma_separated_missing_first_element.py.snap | 3 + ...prehension_missing_for_after_async.py.snap | 3 + .../invalid_syntax@debug_shadow_class.py.snap | 6 + ...valid_syntax@debug_shadow_function.py.snap | 22 + ...invalid_syntax@debug_shadow_import.py.snap | 3 + .../invalid_syntax@debug_shadow_match.py.snap | 2 + .../invalid_syntax@debug_shadow_try.py.snap | 6 + ...lid_syntax@debug_shadow_type_alias.py.snap | 2 + .../invalid_syntax@debug_shadow_with.py.snap | 6 + ...ax@decorator_await_expression_py38.py.snap | 11 + ...syntax@decorator_dict_literal_py38.py.snap | 7 + ...d_syntax@decorator_expression_py38.py.snap | 6 + ...yntax@decorator_float_literal_py38.py.snap | 6 + ...yntax@decorator_invalid_expression.py.snap | 6 + ...yntax@decorator_missing_expression.py.snap | 18 + ...d_syntax@decorator_missing_newline.py.snap | 13 + ...ax@decorator_named_expression_py37.py.snap | 11 + ..._non_toplevel_call_expression_py38.py.snap | 10 + ..._syntax@decorator_unexpected_token.py.snap | 17 + .../invalid_syntax@del_debug_py39.py.snap | 2 + ...valid_syntax@del_incomplete_target.py.snap | 3 + .../invalid_syntax@del_stmt_empty.py.snap | 2 + ...x@different_match_pattern_bindings.py.snap | 73 +++ ...d_syntax@dotted_name_multiple_dots.py.snap | 1 + ...alid_syntax@duplicate_keyword_args.py.snap | 23 + ..._syntax@duplicate_match_class_attr.py.snap | 34 ++ ...invalid_syntax@duplicate_match_key.py.snap | 69 +++ ...tax@duplicate_type_parameter_names.py.snap | 33 ++ .../invalid_syntax@except_star_py310.py.snap | 8 + ...tax@except_stmt_invalid_expression.py.snap | 11 + ...syntax@except_stmt_missing_as_name.py.snap | 7 + ...ntax@except_stmt_missing_exception.py.snap | 13 + ...stmt_missing_exception_and_as_name.py.snap | 6 + ...cept_stmt_unparenthesized_tuple_as.py.snap | 13 + ..._unparenthesized_tuple_no_as_py313.py.snap | 13 + ...essions__arguments__double_starred.py.snap | 9 + ...ments__duplicate_keyword_arguments.py.snap | 3 + ...ons__arguments__invalid_expression.py.snap | 9 + ...uments__invalid_keyword_expression.py.snap | 9 + ...ressions__arguments__invalid_order.py.snap | 11 + ...sions__arguments__missing_argument.py.snap | 3 + ...ressions__arguments__missing_comma.py.snap | 3 + ...ons__arguments__missing_expression.py.snap | 7 + ...ax@expressions__arguments__starred.py.snap | 9 + ...expressions__arguments__unclosed_0.py.snap | 8 + ...expressions__arguments__unclosed_1.py.snap | 8 + ...expressions__arguments__unclosed_2.py.snap | 8 + ...essions__attribute__invalid_member.py.snap | 1 + ...ressions__attribute__multiple_dots.py.snap | 1 + ...@expressions__attribute__no_member.py.snap | 1 + ...xpressions__await__no_expression_0.py.snap | 1 + ...xpressions__await__no_expression_1.py.snap | 6 + ...syntax@expressions__await__recover.py.snap | 4 + ...ns__bin_op__invalid_rhs_expression.py.snap | 4 + ...x@expressions__bin_op__missing_lhs.py.snap | 1 + ...expressions__bin_op__missing_rhs_0.py.snap | 1 + ...expressions__bin_op__missing_rhs_1.py.snap | 1 + ...@expressions__bin_op__multiple_ops.py.snap | 1 + ...ressions__bin_op__named_expression.py.snap | 2 + ...ssions__bin_op__starred_expression.py.snap | 1 + ...s__bool_op__invalid_rhs_expression.py.snap | 6 + ...@expressions__bool_op__missing_lhs.py.snap | 1 + ...@expressions__bool_op__missing_rhs.py.snap | 2 + ...essions__bool_op__named_expression.py.snap | 3 + ...sions__bool_op__starred_expression.py.snap | 3 + ...xpressions__compare__invalid_order.py.snap | 6 + ...s__compare__invalid_rhs_expression.py.snap | 6 + ...@expressions__compare__missing_lhs.py.snap | 1 + ...xpressions__compare__missing_rhs_0.py.snap | 2 + ...xpressions__compare__missing_rhs_1.py.snap | 1 + ...xpressions__compare__missing_rhs_2.py.snap | 2 + ...ressions__compare__multiple_equals.py.snap | 9 + ...essions__compare__named_expression.py.snap | 4 + ...sions__compare__starred_expression.py.snap | 5 + ...x@expressions__dict__comprehension.py.snap | 34 ++ ...tax@expressions__dict__double_star.py.snap | 18 + ...s__dict__double_star_comprehension.py.snap | 4 + ...ons__dict__missing_closing_brace_0.py.snap | 4 + ...ons__dict__missing_closing_brace_1.py.snap | 2 + ...ons__dict__missing_closing_brace_2.py.snap | 7 + ...ressions__dict__named_expression_0.py.snap | 2 + ...ressions__dict__named_expression_1.py.snap | 2 + ..._syntax@expressions__dict__recover.py.snap | 10 + ...tax@expressions__emoji_identifiers.py.snap | 7 + ...yntax@expressions__emoji_statement.py.snap | 1 + ...essions__if__missing_orelse_expr_0.py.snap | 6 + ...essions__if__missing_orelse_expr_1.py.snap | 1 + ...pressions__if__missing_test_expr_0.py.snap | 6 + ...pressions__if__missing_test_expr_1.py.snap | 1 + ...id_syntax@expressions__if__recover.py.snap | 4 + ...essions__lambda_default_parameters.py.snap | 8 + ...sions__lambda_duplicate_parameters.py.snap | 26 + ...x@expressions__list__comprehension.py.snap | 52 ++ ...s__list__missing_closing_bracket_0.py.snap | 2 + ...s__list__missing_closing_bracket_1.py.snap | 2 + ...s__list__missing_closing_bracket_2.py.snap | 2 + ...s__list__missing_closing_bracket_3.py.snap | 7 + ..._syntax@expressions__list__recover.py.snap | 9 + ...__list__star_expression_precedence.py.snap | 15 + ...expressions__named__invalid_target.py.snap | 3 + ...sions__named__missing_expression_0.py.snap | 1 + ...sions__named__missing_expression_1.py.snap | 1 + ...sions__named__missing_expression_2.py.snap | 4 + ...sions__named__missing_expression_3.py.snap | 1 + ...sions__named__missing_expression_4.py.snap | 1 + ...ressions__parenthesized__generator.py.snap | 6 + ...nthesized__missing_closing_paren_0.py.snap | 1 + ...nthesized__missing_closing_paren_1.py.snap | 1 + ...nthesized__missing_closing_paren_2.py.snap | 2 + ...nthesized__missing_closing_paren_3.py.snap | 7 + ...ions__parenthesized__parenthesized.py.snap | 1 + ...@expressions__parenthesized__tuple.py.snap | 7 + ..._parenthesized__tuple_starred_expr.py.snap | 39 ++ ...ax@expressions__set__comprehension.py.snap | 34 ++ ...set__missing_closing_curly_brace_0.py.snap | 2 + ...set__missing_closing_curly_brace_1.py.snap | 2 + ...set__missing_closing_curly_brace_2.py.snap | 2 + ...set__missing_closing_curly_brace_3.py.snap | 7 + ...d_syntax@expressions__set__recover.py.snap | 9 + ...s__set__star_expression_precedence.py.snap | 15 + ...__subscript__invalid_slice_element.py.snap | 1 + ...sions__subscript__unclosed_slice_0.py.snap | 1 + ...sions__subscript__unclosed_slice_1.py.snap | 4 + .../invalid_syntax@expressions__unary.py.snap | 1 + ...pressions__unary__named_expression.py.snap | 1 + ...xpressions__unary__no_expression_0.py.snap | 1 + ...xpressions__unary__no_expression_1.py.snap | 1 + ...pressions__yield__named_expression.py.snap | 2 + ...xpressions__yield__star_expression.py.snap | 3 + ...ns__yield_from__starred_expression.py.snap | 2 + ...sions__yield_from__unparenthesized.py.snap | 4 + ...ing_conversion_follows_exclamation.py.snap | 16 + ...d_syntax@f_string_empty_expression.py.snap | 11 + ...g_invalid_conversion_flag_name_tok.py.snap | 6 + ..._invalid_conversion_flag_other_tok.py.snap | 11 + ...ntax@f_string_invalid_starred_expr.py.snap | 17 + ..._string_lambda_without_parentheses.py.snap | 9 + ...id_syntax@f_string_unclosed_lbrace.py.snap | 26 + ...ing_unclosed_lbrace_in_format_spec.py.snap | 11 + ...nvalid_syntax@for_iter_unpack_py38.py.snap | 16 + ..._syntax@for_stmt_invalid_iter_expr.py.snap | 15 + ...lid_syntax@for_stmt_invalid_target.py.snap | 33 ++ ...or_stmt_invalid_target_binary_expr.py.snap | 28 ++ ...for_stmt_invalid_target_in_keyword.py.snap | 38 ++ ...syntax@for_stmt_missing_in_keyword.py.snap | 9 + ...valid_syntax@for_stmt_missing_iter.py.snap | 8 + ...lid_syntax@for_stmt_missing_target.py.snap | 5 + ...id_syntax@from_import_dotted_names.py.snap | 4 + ...lid_syntax@from_import_empty_names.py.snap | 4 + ..._syntax@from_import_missing_module.py.snap | 3 + ...id_syntax@from_import_missing_rpar.py.snap | 3 + ...tax@from_import_parenthesized_star.py.snap | 2 + ...@from_import_star_with_other_names.py.snap | 5 + ...ort_unparenthesized_trailing_comma.py.snap | 4 + ...lid_syntax@function_def_empty_body.py.snap | 14 + ...x@function_def_invalid_return_expr.py.snap | 16 + ...ax@function_def_missing_identifier.py.snap | 11 + ...x@function_def_missing_return_type.py.snap | 6 + ...nction_def_unclosed_parameter_list.py.snap | 26 + ...ction_def_unclosed_type_param_list.py.snap | 14 + ...n_def_unparenthesized_return_types.py.snap | 13 + ..._syntax@function_type_params_py311.py.snap | 13 + .../invalid_syntax@global_stmt_empty.py.snap | 1 + ...alid_syntax@global_stmt_expression.py.snap | 1 + ..._syntax@global_stmt_trailing_comma.py.snap | 1 + ..._syntax@if_stmt_elif_missing_colon.py.snap | 6 + .../invalid_syntax@if_stmt_empty_body.py.snap | 2 + ...tax@if_stmt_invalid_elif_test_expr.py.snap | 6 + ...d_syntax@if_stmt_invalid_test_expr.py.snap | 4 + ...valid_syntax@if_stmt_missing_colon.py.snap | 6 + ...nvalid_syntax@if_stmt_missing_test.py.snap | 2 + ...lid_syntax@if_stmt_misspelled_elif.py.snap | 3 + ...y_concatenated_unterminated_string.py.snap | 6 + ...ated_unterminated_string_multiline.py.snap | 8 + ...syntax@import_alias_missing_asname.py.snap | 1 + .../invalid_syntax@import_from_star.py.snap | 22 + .../invalid_syntax@import_stmt_empty.py.snap | 1 + ...ax@import_stmt_parenthesized_names.py.snap | 2 + ...lid_syntax@import_stmt_star_import.py.snap | 2 + ..._syntax@import_stmt_trailing_comma.py.snap | 1 + ..._attribute_before_for_in_delimiter.py.snap | 15 + ...id_syntax@invalid_annotation_class.py.snap | 30 ++ ...syntax@invalid_annotation_function.py.snap | 129 +++++ ...@invalid_annotation_function_py314.py.snap | 59 +++ ...id_syntax@invalid_annotation_py314.py.snap | 15 + ...ntax@invalid_annotation_type_alias.py.snap | 6 + ...nvalid_syntax@invalid_byte_literal.py.snap | 1 + .../invalid_syntax@invalid_del_target.py.snap | 7 + ...ax@invalid_fstring_literal_element.py.snap | 5 + ...alid_syntax@invalid_future_feature.py.snap | 4 + ...yntax@invalid_match_pattern_target.py.snap | 8 + ...alid_syntax@invalid_string_literal.py.snap | 1 + ...lp_escape_command_error_recovery_1.py.snap | 4 + ...lp_escape_command_error_recovery_2.py.snap | 5 + ...lp_escape_command_error_recovery_3.py.snap | 7 + ...id_syntax@irrefutable_case_pattern.py.snap | 10 + ...lid_syntax@iter_unpack_return_py37.py.snap | 11 + ...alid_syntax@iter_unpack_yield_py37.py.snap | 18 + ...ntax@lambda_body_with_starred_expr.py.snap | 16 + ...syntax@lambda_body_with_yield_expr.py.snap | 7 + ...@lazy_import_invalid_context_py315.py.snap | 31 ++ ...tax@lazy_import_invalid_from_py315.py.snap | 9 + ...alid_syntax@lazy_import_stmt_py314.py.snap | 2 + .../invalid_syntax@match_before_py310.py.snap | 2 + ...d_syntax@match_classify_as_keyword.py.snap | 2 + ..._classify_as_keyword_or_identifier.py.snap | 2 + ...nvalid_syntax@match_expected_colon.py.snap | 3 + ...x@match_stmt_expect_indented_block.py.snap | 2 + ...tax@match_stmt_expected_case_block.py.snap | 5 + ...ntax@match_stmt_invalid_guard_expr.py.snap | 4 + ...ax@match_stmt_invalid_subject_expr.py.snap | 6 + ...ntax@match_stmt_missing_guard_expr.py.snap | 2 + ..._syntax@match_stmt_missing_pattern.py.snap | 2 + ...@match_stmt_no_newline_before_case.py.snap | 2 + ...@match_stmt_single_starred_subject.py.snap | 2 + ...mixed_bytes_and_non_bytes_literals.py.snap | 5 + ...x@mixed_tstring_and_bytes_literals.py.snap | 15 + ...ultiple_assignment_in_case_pattern.py.snap | 30 ++ ...ntax@multiple_clauses_on_same_line.py.snap | 29 ++ ...multiple_starred_assignment_target.py.snap | 27 ++ ..._starred_names_in_sequence_pattern.py.snap | 3 + .../invalid_syntax@named_expr_slice.py.snap | 1 + ...yntax@named_expr_slice_parse_error.py.snap | 1 + ...x@nested_async_comprehension_py310.py.snap | 76 +++ ...@nested_quote_in_format_spec_py312.py.snap | 6 + ...nvalid_syntax@node_range_with_gaps.py.snap | 16 + ...nlocal_declaration_at_module_level.py.snap | 1 + ...invalid_syntax@nonlocal_stmt_empty.py.snap | 6 + ...id_syntax@nonlocal_stmt_expression.py.snap | 6 + ...yntax@nonlocal_stmt_trailing_comma.py.snap | 6 + ...id_syntax@param_missing_annotation.py.snap | 15 + ...valid_syntax@param_missing_default.py.snap | 15 + ...ntax@param_with_invalid_annotation.py.snap | 24 + ..._syntax@param_with_invalid_default.py.snap | 22 + ...param_with_invalid_star_annotation.py.snap | 30 ++ ...x@param_with_star_annotation_py310.py.snap | 8 + ...alid_syntax@params_duplicate_names.py.snap | 18 + ...rams_expected_after_star_separator.py.snap | 32 ++ ...x@params_follows_var_keyword_param.py.snap | 14 + ...@params_kwarg_after_star_separator.py.snap | 8 + ...alid_syntax@params_multiple_kwargs.py.snap | 10 + ...ax@params_multiple_slash_separator.py.snap | 21 + ...tax@params_multiple_star_separator.py.snap | 21 + ...lid_syntax@params_multiple_varargs.py.snap | 36 ++ ..._syntax@params_no_arg_before_slash.py.snap | 13 + ...x@params_non_default_after_default.py.snap | 12 + ...lid_syntax@params_star_after_slash.py.snap | 41 ++ ...ms_star_separator_after_star_param.py.snap | 25 + ...ax@params_var_keyword_with_default.py.snap | 11 + ...params_var_positional_with_default.py.snap | 11 + ...parenthesized_context_manager_py38.py.snap | 10 + ...id_syntax@parenthesized_kwarg_py38.py.snap | 7 + ...valid_syntax@pep701_f_string_py311.py.snap | 86 ++++ ...@pep701_nested_interpolation_py311.py.snap | 17 + ...ict_unpacking_comprehensions_py315.py.snap | 13 + ...798_unpacking_comprehensions_py314.py.snap | 13 + .../invalid_syntax@pos_only_py37.py.snap | 35 ++ ...syntax@raise_stmt_from_without_exc.py.snap | 1 + ...id_syntax@raise_stmt_invalid_cause.py.snap | 1 + ...alid_syntax@raise_stmt_invalid_exc.py.snap | 1 + ...e_stmt_unparenthesized_tuple_cause.py.snap | 3 + ...ise_stmt_unparenthesized_tuple_exc.py.snap | 4 + ...nvalid_syntax@re_lex_logical_token.py.snap | 83 ++++ ...yntax@re_lex_logical_token_mac_eol.py.snap | 10 + ...x@re_lex_logical_token_windows_eol.py.snap | 10 + ...x@re_lexing__fstring_format_spec_1.py.snap | 16 + ...tax@re_lexing__line_continuation_1.py.snap | 8 + ...ing__line_continuation_windows_eol.py.snap | 8 + ...re_lexing__triple_quoted_fstring_1.py.snap | 6 + ...re_lexing__triple_quoted_fstring_2.py.snap | 6 + ...re_lexing__triple_quoted_fstring_3.py.snap | 9 + .../invalid_syntax@re_lexing__ty_1828.py.snap | 10 + ...tax@rebound_comprehension_variable.py.snap | 51 ++ ...id_syntax@return_stmt_invalid_expr.py.snap | 2 + ...signed_pattern_non_literal_operand.py.snap | 10 + ...ple_and_compound_stmt_on_same_line.py.snap | 2 + ...ompound_stmt_on_same_line_in_block.py.snap | 5 + ...d_syntax@simple_stmts_on_same_line.py.snap | 1 + ...simple_stmts_on_same_line_in_block.py.snap | 2 + .../invalid_syntax@single_star_for.py.snap | 9 + .../invalid_syntax@single_star_return.py.snap | 6 + .../invalid_syntax@single_star_yield.py.snap | 6 + ...x@single_starred_assignment_target.py.snap | 5 + .../invalid_syntax@star_index_py310.py.snap | 11 + .../invalid_syntax@star_slices.py.snap | 1 + ...yntax@starred_comprehension_target.py.snap | 3 + ...lid_syntax@starred_list_comp_py314.py.snap | 3 + ..._syntax@starred_starred_expression.py.snap | 7 + ...atements__function_type_parameters.py.snap | 33 ++ ...ents__if_extra_closing_parentheses.py.snap | 2 + ...syntax@statements__if_extra_indent.py.snap | 13 + ...ements__invalid_assignment_targets.py.snap | 140 ++++++ ...nvalid_augmented_assignment_target.py.snap | 49 ++ ...ax@statements__match__as_pattern_0.py.snap | 5 + ...ax@statements__match__as_pattern_1.py.snap | 2 + ...ax@statements__match__as_pattern_2.py.snap | 3 + ...ax@statements__match__as_pattern_3.py.snap | 6 + ...ax@statements__match__as_pattern_4.py.snap | 4 + ...ents__match__invalid_class_pattern.py.snap | 25 + ..._match__invalid_lhs_or_rhs_pattern.py.snap | 35 ++ ...ts__match__invalid_mapping_pattern.py.snap | 27 ++ ...tements__match__star_pattern_usage.py.snap | 28 ++ ...statements__match__unary_add_usage.py.snap | 13 + ...s__with__ambiguous_lpar_with_items.py.snap | 101 ++++ ...statements__with__empty_with_items.py.snap | 4 + ...nts__with__unclosed_ambiguous_lpar.py.snap | 4 + ..._with__unclosed_ambiguous_lpar_eof.py.snap | 4 + ...__with__unparenthesized_with_items.py.snap | 22 + ...d_syntax@t_string_empty_expression.py.snap | 11 + ...g_invalid_conversion_flag_name_tok.py.snap | 6 + ..._invalid_conversion_flag_other_tok.py.snap | 11 + ...ntax@t_string_invalid_starred_expr.py.snap | 17 + ..._string_lambda_without_parentheses.py.snap | 9 + ...id_syntax@t_string_unclosed_lbrace.py.snap | 27 ++ ...ing_unclosed_lbrace_in_format_spec.py.snap | 11 + ...alid_syntax@template_strings_py313.py.snap | 13 + ...alid_syntax@try_stmt_invalid_order.py.snap | 5 + ...ax@try_stmt_missing_except_finally.py.snap | 9 + ..._syntax@try_stmt_misspelled_except.py.snap | 18 + ..._syntax@try_stmt_mixed_except_kind.py.snap | 21 + ..._syntax@tuple_context_manager_py38.py.snap | 10 + ..._syntax@type_alias_incomplete_stmt.py.snap | 1 + ...ntax@type_alias_invalid_value_expr.py.snap | 1 + ...id_syntax@type_param_default_py312.py.snap | 18 + ...ntax@type_param_invalid_bound_expr.py.snap | 5 + ...id_syntax@type_param_missing_bound.py.snap | 3 + ...syntax@type_param_param_spec_bound.py.snap | 2 + ...am_param_spec_invalid_default_expr.py.snap | 6 + ...e_param_param_spec_missing_default.py.snap | 3 + ...aram_type_var_invalid_default_expr.py.snap | 7 + ...ype_param_type_var_missing_default.py.snap | 4 + ...ax@type_param_type_var_tuple_bound.py.snap | 2 + ...ype_var_tuple_invalid_default_expr.py.snap | 7 + ...ram_type_var_tuple_missing_default.py.snap | 3 + ...yntax@type_parameter_default_order.py.snap | 14 + .../invalid_syntax@type_params_empty.py.snap | 8 + .../invalid_syntax@type_stmt_py311.py.snap | 1 + .../invalid_syntax@unary_plus_py314.py.snap | 5 + ...arenthesized_named_expr_index_py38.py.snap | 1 + ...nthesized_named_expr_set_comp_py38.py.snap | 5 + ...esized_named_expr_set_literal_py38.py.snap | 4 + ...erminated_fstring_newline_recovery.py.snap | 18 + .../invalid_syntax@walrus_py37.py.snap | 1 + ...yntax@while_stmt_invalid_test_expr.py.snap | 11 + ...id_syntax@while_stmt_missing_colon.py.snap | 4 + ...lid_syntax@while_stmt_missing_test.py.snap | 8 + ..._items_parenthesized_missing_colon.py.snap | 4 + ..._items_parenthesized_missing_comma.py.snap | 17 + ...invalid_syntax@write_to_debug_expr.py.snap | 11 + .../invalid_syntax@yield_after_comma.py.snap | 7 + ...yntax@yield_from_in_async_function.py.snap | 6 + ...ntax@all_async_comprehension_py310.py.snap | 14 + ...iguous_lpar_with_items_binary_expr.py.snap | 25 + ...@ambiguous_lpar_with_items_if_expr.py.snap | 17 + ...ntax@ann_assign_stmt_simple_target.py.snap | 5 + ...tax@args_unparenthesized_generator.py.snap | 23 + ...tax@assign_stmt_starred_expr_value.py.snap | 18 + ...d_syntax@assign_targets_terminator.py.snap | 9 + .../valid_syntax@async_for_statement.py.snap | 5 + ...d_syntax@async_function_definition.py.snap | 6 + .../valid_syntax@async_with_statement.py.snap | 4 + ...backslash_continuation_indentation.py.snap | 4 + .../valid_syntax@class_def_arguments.py.snap | 19 + ...ntax@class_keyword_in_case_pattern.py.snap | 5 + ...lid_syntax@class_type_params_py312.py.snap | 5 + ..._separated_regular_list_terminator.py.snap | 6 + .../valid_syntax@debug_rename_import.py.snap | 3 + ...id_syntax@decorator_async_function.py.snap | 6 + ...ax@decorator_await_expression_py39.py.snap | 11 + ...rator_expression_dotted_ident_py38.py.snap | 6 + ...ecorator_expression_eval_hack_py38.py.snap | 8 + ...ator_expression_identity_hack_py38.py.snap | 15 + ...d_syntax@decorator_expression_py39.py.snap | 16 + .../valid_syntax@del_debug_py38.py.snap | 2 + ...alid_syntax@del_targets_terminator.py.snap | 5 + ...x@different_match_pattern_bindings.py.snap | 23 + ...ntax@dotted_name_normalized_spaces.py.snap | 1 + ...id_syntax@duplicate_match_key_attr.py.snap | 4 + .../valid_syntax@except_star_py311.py.snap | 6 + ...x@except_stmt_as_name_soft_keyword.py.snap | 8 + ..._unparenthesized_tuple_no_as_py314.py.snap | 13 + ...alid_syntax@expressions__arguments.py.snap | 84 ++++ ...alid_syntax@expressions__attribute.py.snap | 11 + .../valid_syntax@expressions__await.py.snap | 14 + .../valid_syntax@expressions__bin_op.py.snap | 1 + .../valid_syntax@expressions__bool_op.py.snap | 16 + .../valid_syntax@expressions__call.py.snap | 40 ++ .../valid_syntax@expressions__compare.py.snap | 20 + ...lid_syntax@expressions__dictionary.py.snap | 43 ++ ...ressions__dictionary_comprehension.py.snap | 47 ++ ...valid_syntax@expressions__f_string.py.snap | 239 ++++++++++ ...alid_syntax@expressions__generator.py.snap | 30 ++ .../valid_syntax@expressions__if.py.snap | 14 + .../valid_syntax@expressions__lambda.py.snap | 145 ++++++ .../valid_syntax@expressions__list.py.snap | 36 ++ ...ax@expressions__list_comprehension.py.snap | 68 +++ .../valid_syntax@expressions__name.py.snap | 1 + .../valid_syntax@expressions__named.py.snap | 5 + ...syntax@expressions__number_literal.py.snap | 117 +++++ ..._syntax@expressions__parenthesized.py.snap | 14 + .../valid_syntax@expressions__set.py.snap | 23 + ...tax@expressions__set_comprehension.py.snap | 40 ++ .../valid_syntax@expressions__slice.py.snap | 3 + .../valid_syntax@expressions__starred.py.snap | 11 + .../valid_syntax@expressions__string.py.snap | 1 + ...alid_syntax@expressions__subscript.py.snap | 12 + ...valid_syntax@expressions__t_string.py.snap | 234 +++++++++ .../valid_syntax@expressions__tuple.py.snap | 27 ++ ...valid_syntax@expressions__unary_op.py.snap | 5 + .../valid_syntax@expressions__yield.py.snap | 12 + ...lid_syntax@expressions__yield_from.py.snap | 10 + ...id_syntax@for_in_target_valid_expr.py.snap | 16 + .../valid_syntax@for_iter_unpack_py38.py.snap | 16 + .../valid_syntax@for_iter_unpack_py39.py.snap | 16 + .../valid_syntax@from_import_no_space.py.snap | 3 + ...om_import_soft_keyword_module_name.py.snap | 6 + ...syntax@from_import_stmt_terminator.py.snap | 8 + ...tax@fstring_format_spec_terminator.py.snap | 11 + ...yntax@function_def_parameter_range.py.snap | 10 + ...ion_def_parenthesized_return_types.py.snap | 13 + ...tax@function_def_valid_return_expr.py.snap | 19 + ..._syntax@function_type_params_py312.py.snap | 7 + .../valid_syntax@global_stmt.py.snap | 1 + ...syntax@import_as_name_soft_keyword.py.snap | 1 + .../valid_syntax@import_from_star.py.snap | 2 + ...alid_syntax@import_stmt_terminator.py.snap | 2 + ...ax@irrefutable_case_pattern_at_end.py.snap | 7 + ...lid_syntax@iter_unpack_return_py37.py.snap | 11 + ...lid_syntax@iter_unpack_return_py38.py.snap | 11 + ...alid_syntax@iter_unpack_yield_py37.py.snap | 11 + ...alid_syntax@iter_unpack_yield_py38.py.snap | 18 + ...d_syntax@lambda_with_no_parameters.py.snap | 1 + ...alid_syntax@lambda_with_valid_body.py.snap | 23 + ..._syntax@lazy_import_relative_py315.py.snap | 4 + ...ntax@lazy_import_semantic_ok_py315.py.snap | 12 + ...zy_import_soft_keyword_split_py315.py.snap | 2 + ...alid_syntax@lazy_import_stmt_py315.py.snap | 7 + .../valid_syntax@match_after_py310.py.snap | 2 + ..._syntax@match_annotated_assignment.py.snap | 4 + .../valid_syntax@match_as_pattern.py.snap | 3 + ...ntax@match_as_pattern_soft_keyword.py.snap | 4 + ...ax@match_attr_pattern_soft_keyword.py.snap | 5 + ...tax@match_classify_as_identifier_1.py.snap | 2 + ...tax@match_classify_as_identifier_2.py.snap | 9 + ...syntax@match_classify_as_keyword_1.py.snap | 24 + ...syntax@match_classify_as_keyword_2.py.snap | 7 + ..._classify_as_keyword_or_identifier.py.snap | 8 + ...nce_pattern_parentheses_terminator.py.snap | 5 + ...@match_sequence_pattern_terminator.py.snap | 7 + ...lid_syntax@match_stmt_subject_expr.py.snap | 6 + ...syntax@match_stmt_valid_guard_expr.py.snap | 8 + ...ultiple_assignment_in_case_pattern.py.snap | 7 + ...multiple_starred_assignment_target.py.snap | 13 + ...syntax@nested_alternative_patterns.py.snap | 40 ++ ...x@nested_async_comprehension_py310.py.snap | 28 ++ ...x@nested_async_comprehension_py311.py.snap | 40 ++ ..._syntax@non_duplicate_keyword_args.py.snap | 23 + ...non_duplicate_type_parameter_names.py.snap | 18 + ..._nested_quote_in_format_spec_py311.py.snap | 6 + ...non_rebound_comprehension_variable.py.snap | 5 + ...nlocal_declaration_at_module_level.py.snap | 6 + .../valid_syntax@nonlocal_stmt.py.snap | 6 + .../valid_syntax@other__atom.py.snap | 1 + .../valid_syntax@other__decorator.py.snap | 45 ++ ...valid_syntax@param_with_annotation.py.snap | 18 + .../valid_syntax@param_with_default.py.snap | 32 ++ ..._syntax@param_with_star_annotation.py.snap | 16 + ...x@param_with_star_annotation_py310.py.snap | 40 ++ ...x@param_with_star_annotation_py311.py.snap | 8 + ...ntax@params_non_default_after_star.py.snap | 29 ++ ...seen_keyword_only_param_after_star.py.snap | 19 + ...parenthesized_context_manager_py39.py.snap | 10 + ...id_syntax@parenthesized_kwarg_py37.py.snap | 3 + ...arenthesized_named_expr_index_py38.py.snap | 1 + ...ntax@parenthesized_named_expr_py38.py.snap | 6 + ...tax@parenthesized_star_index_py310.py.snap | 11 + ...valid_syntax@pep701_f_string_py311.py.snap | 71 +++ ...valid_syntax@pep701_f_string_py312.py.snap | 68 +++ ...valid_syntax@pep750_t_string_py314.py.snap | 63 +++ ...798_unpacking_comprehensions_py315.py.snap | 21 + .../valid_syntax@pos_only_py38.py.snap | 8 + .../valid_syntax@read_from_debug.py.snap | 5 + ...valid_syntax@simple_stmts_in_block.py.snap | 8 + ...yntax@simple_stmts_with_semicolons.py.snap | 2 + ...thesized_item_context_manager_py38.py.snap | 11 + .../valid_syntax@single_star_in_tuple.py.snap | 23 + ...x@single_starred_assignment_target.py.snap | 16 + .../valid_syntax@star_index_py311.py.snap | 11 + ...yntax@starred_comprehension_target.py.snap | 4 + ...lid_syntax@starred_list_comp_py315.py.snap | 5 + ...atement__ambiguous_lpar_with_items.py.snap | 296 ++++++++++++ ...ax@statement__annotated_assignment.py.snap | 11 + .../valid_syntax@statement__assert.py.snap | 11 + ...valid_syntax@statement__assignment.py.snap | 78 +++ ...ax@statement__augmented_assignment.py.snap | 3 + .../valid_syntax@statement__class.py.snap | 118 +++++ .../valid_syntax@statement__delete.py.snap | 15 + .../valid_syntax@statement__for.py.snap | 67 +++ ...alid_syntax@statement__from_import.py.snap | 10 + .../valid_syntax@statement__function.py.snap | 447 ++++++++++++++++++ .../valid_syntax@statement__if.py.snap | 44 ++ .../valid_syntax@statement__import.py.snap | 1 + .../valid_syntax@statement__match.py.snap | 443 +++++++++++++++++ .../valid_syntax@statement__raise.py.snap | 13 + .../valid_syntax@statement__return.py.snap | 12 + .../valid_syntax@statement__simple.py.snap | 8 + .../valid_syntax@statement__try.py.snap | 133 ++++++ .../valid_syntax@statement__type.py.snap | 89 ++++ .../valid_syntax@statement__while.py.snap | 31 ++ .../valid_syntax@statement__with.py.snap | 29 ++ ...alid_syntax@template_strings_py314.py.snap | 13 + ..._syntax@tuple_context_manager_py38.py.snap | 5 + ...id_syntax@type_param_default_py313.py.snap | 13 + ...valid_syntax@type_param_param_spec.py.snap | 5 + .../valid_syntax@type_param_type_var.py.snap | 8 + ...d_syntax@type_param_type_var_tuple.py.snap | 6 + .../valid_syntax@type_stmt_py312.py.snap | 1 + .../valid_syntax@unary_plus_py315.py.snap | 5 + ...arenthesized_named_expr_index_py39.py.snap | 1 + ...ax@unparenthesized_named_expr_py39.py.snap | 6 + ...alid_syntax@valid_annotation_class.py.snap | 27 ++ ...ax@valid_annotation_function_py313.py.snap | 59 +++ ...alid_syntax@valid_annotation_py313.py.snap | 15 + .../valid_syntax@valid_future_feature.py.snap | 2 + .../valid_syntax@walrus_py38.py.snap | 1 + ...ax@yield_after_comma_parenthesized.py.snap | 7 + .../src/analyze/type_inference.rs | 1 + crates/ruff_python_semantic/src/imports.rs | 1 + crates/ruff_python_trivia/Cargo.toml | 7 +- crates/ruff_source_file/Cargo.toml | 7 +- crates/ruff_text_size/Cargo.toml | 7 +- crates/ty_module_resolver/src/module_name.rs | 1 + crates/ty_python_core/src/builder.rs | 18 + crates/ty_python_core/src/re_exports.rs | 11 + .../ty_python_semantic/src/semantic_model.rs | 1 + .../src/types/infer/builder.rs | 47 ++ .../src/types/infer/builder/class.rs | 2 + .../src/types/infer/builder/enum_call.rs | 2 + .../src/types/infer/builder/function.rs | 7 + .../src/types/infer/builder/imports.rs | 1 + .../src/types/infer/builder/named_tuple.rs | 2 + .../src/types/infer/builder/new_class.rs | 2 + .../suspicious_conditions/exemptions.rs | 3 +- .../src/types/infer/builder/type_call.rs | 2 + .../types/infer/builder/type_expression.rs | 2 + .../src/types/infer/builder/typed_dict.rs | 3 + crates/ty_python_semantic/src/types/narrow.rs | 1 + .../src/types/signatures.rs | 1 + fuzz/Cargo.toml | 6 +- hawk.toml | 10 +- 773 files changed, 10630 insertions(+), 989 deletions(-) create mode 100644 crates/ruff_python_formatter/src/expression/expr_constant.rs diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e1126b7fb3c3fa..e1938e27ebae2a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -384,7 +384,7 @@ jobs: runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }} needs: determine_changes if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }} - timeout-minutes: 20 + timeout-minutes: ${{ github.repository == 'astral-sh/ruff' && 20 || 40 }} env: # Line-tables-only debug info: faster builds, backtraces still work. CARGO_PROFILE_DEV_DEBUG: line-tables-only @@ -488,7 +488,7 @@ jobs: runs-on: ${{ matrix.platform }} needs: determine_changes if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }} - timeout-minutes: 20 + timeout-minutes: ${{ github.repository == 'astral-sh/ruff' && 20 || 40 }} env: # Line-tables-only debug info: faster builds, backtraces still work. CARGO_PROFILE_DEV_DEBUG: line-tables-only @@ -707,7 +707,7 @@ jobs: needs.determine_changes.outputs.linter == 'true' || needs.determine_changes.outputs.formatter == 'true' ) - timeout-minutes: 20 + timeout-minutes: ${{ github.repository == 'astral-sh/ruff' && 20 || 40 }} env: # Line-tables-only debug info: faster builds, backtraces still work. CARGO_PROFILE_DEV_DEBUG: line-tables-only @@ -827,7 +827,7 @@ jobs: - determine_changes # Only runs on pull requests, since that is the only we way we can find the base version for comparison. if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-test') && github.event_name == 'pull_request' && (needs.determine_changes.outputs.ty == 'true' || needs.determine_changes.outputs.py-fuzzer == 'true') }} - timeout-minutes: ${{ github.repository == 'astral-sh/ruff' && 10 || 20 }} + timeout-minutes: ${{ github.repository == 'astral-sh/ruff' && 10 || 30 }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a95afec6cd55cc..958ce2d03d7690 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,7 +75,7 @@ jobs: plan: permissions: "contents": "read" - runs-on: "depot-ubuntu-24.04-4" + runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-24.04-4' || 'ubuntu-latest' }} outputs: val: ${{ steps.plan.outputs.manifest }} tag: ${{ (inputs.tag != 'dry-run' && inputs.tag) || '' }} diff --git a/.github/workflows/ty-ecosystem-analyzer.yaml b/.github/workflows/ty-ecosystem-analyzer.yaml index 05bc3def4bbebe..a6c0c0816e2530 100644 --- a/.github/workflows/ty-ecosystem-analyzer.yaml +++ b/.github/workflows/ty-ecosystem-analyzer.yaml @@ -60,7 +60,7 @@ jobs: matrix: revision: [base, pr] runs-on: ${{ github.repository == 'astral-sh/ruff' && 'github-ubuntu-24.04-x86_64-32' || 'ubuntu-latest' }} - timeout-minutes: 5 + timeout-minutes: ${{ github.repository == 'astral-sh/ruff' && 5 || 10 }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: diff --git a/Cargo.lock b/Cargo.lock index af0a09d8590efe..d065d1de1f646c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2110,12 +2110,12 @@ dependencies = [ "ruff_db", "ruff_diagnostics", "ruff_index", - "ruff_python_ast", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", "rustc-hash", "rustc-stable-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "salsa", "serde", "similar 3.2.0", @@ -3130,16 +3130,16 @@ dependencies = [ "ruff_markdown", "ruff_notebook", "ruff_options_metadata", - "ruff_python_ast", "ruff_python_formatter", - "ruff_python_parser", - "ruff_python_trivia", "ruff_ranged_value", "ruff_server", - "ruff_source_file", - "ruff_text_size", "ruff_workspace", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "serde", "serde_json", "shellexpand", @@ -3178,13 +3178,13 @@ dependencies = [ "rayon", "ruff_db", "ruff_linter", - "ruff_python_ast", "ruff_python_formatter", - "ruff_python_parser", - "ruff_python_trivia", "ruff_ranged_value", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_text_size", "serde", "serde_json", "tempfile", @@ -3242,12 +3242,12 @@ dependencies = [ "ruff_diagnostics", "ruff_memory_usage", "ruff_notebook", - "ruff_python_ast", - "ruff_python_parser", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "salsa", "same-file", "schemars", @@ -3286,12 +3286,12 @@ dependencies = [ "ruff_linter", "ruff_notebook", "ruff_options_metadata", - "ruff_python_ast", "ruff_python_codegen", "ruff_python_formatter", - "ruff_python_parser", - "ruff_python_trivia", "ruff_workspace", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", "schemars", "serde", "serde_json", @@ -3315,7 +3315,7 @@ version = "0.0.16" dependencies = [ "get-size2", "is-macro", - "ruff_text_size", + "rustpython-ruff_text_size", "serde", ] @@ -3326,8 +3326,8 @@ dependencies = [ "drop_bomb", "ruff_cache", "ruff_macros", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_text_size", "schemars", "serde", "static_assertions", @@ -3346,8 +3346,8 @@ dependencies = [ "ruff_db", "ruff_linter", "ruff_macros", - "ruff_python_ast", - "ruff_python_parser", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", "salsa", "schemars", "serde", @@ -3397,20 +3397,20 @@ dependencies = [ "ruff_diagnostics", "ruff_macros", "ruff_notebook", - "ruff_python_ast", "ruff_python_codegen", "ruff_python_edits", "ruff_python_importer", "ruff_python_index", "ruff_python_literal", - "ruff_python_parser", "ruff_python_semantic", "ruff_python_stdlib", - "ruff_python_trivia", "ruff_ranged_value", - "ruff_source_file", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "schemars", "serde", "serde_json", @@ -3438,7 +3438,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "ruff_python_trivia", + "rustpython-ruff_python_trivia", "syn 3.0.4", ] @@ -3449,12 +3449,12 @@ dependencies = [ "insta", "regex", "ruff_linter", - "ruff_python_ast", "ruff_python_formatter", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", "ruff_workspace", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", ] [[package]] @@ -3467,9 +3467,9 @@ dependencies = [ "mdtest", "ruff_db", "ruff_linter", - "ruff_python_ast", "ruff_ranged_value", "ruff_workspace", + "rustpython-ruff_python_ast", "salsa", ] @@ -3487,8 +3487,8 @@ dependencies = [ "anyhow", "rand 0.10.2", "ruff_diagnostics", - "ruff_source_file", - "ruff_text_size", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "serde", "serde_json", "test-case", @@ -3503,52 +3503,26 @@ dependencies = [ "serde", ] -[[package]] -name = "ruff_python_ast" -version = "0.0.16" -dependencies = [ - "aho-corasick", - "arrayvec", - "bitflags 2.13.1", - "char_str", - "compact_str", - "get-size2", - "is-macro", - "memchr", - "ruff_cache", - "ruff_macros", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", - "rustc-hash", - "salsa", - "schemars", - "serde", - "serde_json", - "thin-vec", - "thiserror 2.0.20", -] - [[package]] name = "ruff_python_ast_integration_tests" version = "0.0.0" dependencies = [ "insta", - "ruff_python_ast", - "ruff_python_parser", - "ruff_python_trivia", - "ruff_text_size", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_text_size", ] [[package]] name = "ruff_python_codegen" version = "0.0.16" dependencies = [ - "ruff_python_ast", "ruff_python_literal", - "ruff_python_parser", - "ruff_source_file", - "ruff_text_size", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "test-case", ] @@ -3556,10 +3530,10 @@ dependencies = [ name = "ruff_python_edits" version = "0.0.16" dependencies = [ - "ruff_python_ast", - "ruff_python_parser", - "ruff_source_file", - "ruff_text_size", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", ] [[package]] @@ -3578,12 +3552,12 @@ dependencies = [ "ruff_db", "ruff_formatter", "ruff_macros", - "ruff_python_ast", - "ruff_python_parser", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "salsa", "schemars", "serde", @@ -3602,23 +3576,23 @@ dependencies = [ "anyhow", "insta", "ruff_diagnostics", - "ruff_python_ast", "ruff_python_codegen", - "ruff_python_parser", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", ] [[package]] name = "ruff_python_index" version = "0.0.16" dependencies = [ - "ruff_python_ast", - "ruff_python_parser", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", ] [[package]] @@ -3628,38 +3602,7 @@ dependencies = [ "bitflags 2.13.1", "icu_properties", "itertools 0.15.0", - "ruff_python_ast", -] - -[[package]] -name = "ruff_python_parser" -version = "0.0.16" -dependencies = [ - "anyhow", - "bitflags 2.13.1", - "bstr", - "datatest-stable", - "drop_bomb", - "get-size2", - "hashbrown 0.17.1", - "insta", - "itertools 0.15.0", - "memchr", - "ruff_annotate_snippets", - "ruff_python_ast", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", - "rustc-hash", - "serde", - "serde_json", - "stacker", - "static_assertions", - "thin-vec", - "unicode-ident", - "unicode-normalization", - "unicode_names2", - "walkdir", + "rustpython-ruff_python_ast", ] [[package]] @@ -3672,11 +3615,11 @@ dependencies = [ "ruff_cache", "ruff_index", "ruff_macros", - "ruff_python_ast", - "ruff_python_parser", "ruff_python_stdlib", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_text_size", "schemars", "serde", "smallvec", @@ -3691,27 +3634,14 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "ruff_python_trivia" -version = "0.0.16" -dependencies = [ - "itertools 0.15.0", - "memchr", - "ruff_source_file", - "ruff_text_size", - "rustc-hash", - "unicode-ident", - "unicode-normalization", -] - [[package]] name = "ruff_python_trivia_integration_tests" version = "0.0.0" dependencies = [ "insta", - "ruff_python_parser", - "ruff_python_trivia", - "ruff_text_size", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_text_size", ] [[package]] @@ -3720,8 +3650,8 @@ version = "0.0.16" dependencies = [ "get-size2", "ruff_db", - "ruff_python_ast", - "ruff_text_size", + "rustpython-ruff_python_ast", + "rustpython-ruff_text_size", "schemars", "serde", "toml 1.1.4+spec-1.1.0", @@ -3748,16 +3678,16 @@ dependencies = [ "ruff_linter", "ruff_markdown", "ruff_notebook", - "ruff_python_ast", "ruff_python_codegen", "ruff_python_formatter", "ruff_python_index", - "ruff_python_parser", "ruff_ranged_value", - "ruff_source_file", - "ruff_text_size", "ruff_workspace", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "serde", "serde_json", "shellexpand", @@ -3771,27 +3701,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "ruff_source_file" -version = "0.0.16" -dependencies = [ - "get-size2", - "memchr", - "ruff_text_size", - "serde", -] - -[[package]] -name = "ruff_text_size" -version = "0.0.16" -dependencies = [ - "get-size2", - "schemars", - "serde", - "serde_test", - "static_assertions", -] - [[package]] name = "ruff_wasm" version = "0.16.10" @@ -3803,16 +3712,16 @@ dependencies = [ "ruff_db", "ruff_formatter", "ruff_linter", - "ruff_python_ast", "ruff_python_codegen", "ruff_python_formatter", "ruff_python_index", - "ruff_python_parser", - "ruff_python_trivia", "ruff_ranged_value", - "ruff_source_file", - "ruff_text_size", "ruff_workspace", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "serde", "serde-wasm-bindgen", "wasm-bindgen", @@ -3845,13 +3754,13 @@ dependencies = [ "ruff_linter", "ruff_macros", "ruff_options_metadata", - "ruff_python_ast", "ruff_python_formatter", "ruff_python_semantic", "ruff_python_stdlib", "ruff_ranged_value", - "ruff_source_file", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_source_file", "schemars", "serde", "serde_json", @@ -3897,6 +3806,97 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustpython-ruff_python_ast" +version = "0.16.10" +dependencies = [ + "aho-corasick", + "arrayvec", + "bitflags 2.13.1", + "char_str", + "compact_str", + "get-size2", + "is-macro", + "memchr", + "ruff_cache", + "ruff_macros", + "rustc-hash", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", + "salsa", + "schemars", + "serde", + "serde_json", + "thin-vec", + "thiserror 2.0.20", +] + +[[package]] +name = "rustpython-ruff_python_parser" +version = "0.16.10" +dependencies = [ + "anyhow", + "bitflags 2.13.1", + "bstr", + "datatest-stable", + "drop_bomb", + "get-size2", + "hashbrown 0.17.1", + "insta", + "itertools 0.15.0", + "memchr", + "ruff_annotate_snippets", + "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", + "serde", + "serde_json", + "stacker", + "static_assertions", + "thin-vec", + "unicode-ident", + "unicode-normalization", + "unicode_names2", + "walkdir", +] + +[[package]] +name = "rustpython-ruff_python_trivia" +version = "0.16.10" +dependencies = [ + "itertools 0.15.0", + "memchr", + "rustc-hash", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", + "unicode-ident", + "unicode-normalization", +] + +[[package]] +name = "rustpython-ruff_source_file" +version = "0.16.10" +dependencies = [ + "get-size2", + "memchr", + "rustpython-ruff_text_size", + "serde", +] + +[[package]] +name = "rustpython-ruff_text_size" +version = "0.16.10" +dependencies = [ + "get-size2", + "schemars", + "serde", + "serde_test", + "static_assertions", +] + [[package]] name = "rustversion" version = "1.0.22" @@ -4677,9 +4677,9 @@ dependencies = [ "ruff_command_line", "ruff_db", "ruff_diagnostics", - "ruff_python_ast", - "ruff_python_trivia", "ruff_ranged_value", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_trivia", "salsa", "serde", "serde_json", @@ -4707,8 +4707,8 @@ version = "0.0.16" dependencies = [ "ordermap", "ruff_db", - "ruff_python_ast", "ruff_ranged_value", + "rustpython-ruff_python_ast", ] [[package]] @@ -4719,7 +4719,7 @@ dependencies = [ "bstr", "clap", "ruff_db", - "ruff_text_size", + "rustpython-ruff_text_size", "ty_ide", "ty_project", ] @@ -4734,7 +4734,7 @@ dependencies = [ "csv", "regex", "ruff_db", - "ruff_text_size", + "rustpython-ruff_text_size", "serde", "tempfile", "toml 1.1.4+spec-1.1.0", @@ -4761,14 +4761,14 @@ dependencies = [ "ruff_diagnostics", "ruff_index", "ruff_memory_usage", - "ruff_python_ast", "ruff_python_literal", - "ruff_python_parser", "ruff_python_stdlib", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "salsa", "smallvec", "strum", @@ -4798,9 +4798,9 @@ dependencies = [ "regex-syntax", "ruff_db", "ruff_memory_usage", - "ruff_python_ast", "ruff_python_stdlib", "rustc-hash", + "rustpython-ruff_python_ast", "salsa", "strum", "strum_macros", @@ -4836,12 +4836,12 @@ dependencies = [ "ruff_macros", "ruff_memory_usage", "ruff_options_metadata", - "ruff_python_ast", "ruff_python_formatter", - "ruff_python_trivia", "ruff_ranged_value", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_trivia", + "rustpython-ruff_text_size", "salsa", "schemars", "serde", @@ -4876,11 +4876,11 @@ dependencies = [ "ruff_index", "ruff_macros", "ruff_memory_usage", - "ruff_python_ast", - "ruff_python_parser", - "ruff_python_trivia", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_text_size", "salsa", "schemars", "serde", @@ -4923,17 +4923,17 @@ dependencies = [ "ruff_index", "ruff_macros", "ruff_memory_usage", - "ruff_python_ast", "ruff_python_codegen", "ruff_python_edits", "ruff_python_importer", "ruff_python_literal", - "ruff_python_parser", "ruff_python_stdlib", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_parser", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "salsa", "schemars", "serde", @@ -4971,12 +4971,12 @@ dependencies = [ "ruff_diagnostics", "ruff_macros", "ruff_notebook", - "ruff_python_ast", - "ruff_python_trivia", "ruff_ranged_value", - "ruff_source_file", - "ruff_text_size", "rustc-hash", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "salsa", "serde", "serde_json", @@ -5005,10 +5005,10 @@ dependencies = [ "indexmap", "ruff_annotate_snippets", "ruff_db", - "ruff_python_ast", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "strum", "strum_macros", "tempfile", @@ -5035,9 +5035,9 @@ dependencies = [ "ruff_db", "ruff_diagnostics", "ruff_notebook", - "ruff_python_ast", - "ruff_python_trivia", - "ruff_source_file", + "rustpython-ruff_python_ast", + "rustpython-ruff_python_trivia", + "rustpython-ruff_source_file", "salsa", "serde", "tempfile", @@ -5073,8 +5073,8 @@ dependencies = [ "ruff_notebook", "ruff_python_formatter", "ruff_ranged_value", - "ruff_source_file", - "ruff_text_size", + "rustpython-ruff_source_file", + "rustpython-ruff_text_size", "serde-wasm-bindgen", "tracing", "ty_ide", diff --git a/Cargo.toml b/Cargo.toml index 333dfab9e0710c..006be36c71c159 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,22 +29,22 @@ ruff_markdown = { version = "0.0.16", path = "crates/ruff_markdown" } ruff_memory_usage = { version = "0.0.16", path = "crates/ruff_memory_usage" } ruff_notebook = { version = "0.0.16", path = "crates/ruff_notebook" } ruff_options_metadata = { version = "0.0.16", path = "crates/ruff_options_metadata" } -ruff_python_ast = { version = "0.0.16", path = "crates/ruff_python_ast" } +ruff_python_ast = { package = "rustpython-ruff_python_ast", version = "0.16.10", path = "crates/ruff_python_ast" } ruff_python_codegen = { version = "0.0.16", path = "crates/ruff_python_codegen" } ruff_python_edits = { version = "0.0.16", path = "crates/ruff_python_edits" } ruff_python_formatter = { version = "0.0.16", path = "crates/ruff_python_formatter" } ruff_python_importer = { version = "0.0.16", path = "crates/ruff_python_importer" } ruff_python_index = { version = "0.0.16", path = "crates/ruff_python_index" } ruff_python_literal = { version = "0.0.16", path = "crates/ruff_python_literal" } -ruff_python_parser = { version = "0.0.16", path = "crates/ruff_python_parser" } +ruff_python_parser = { package = "rustpython-ruff_python_parser", version = "0.16.10", path = "crates/ruff_python_parser" } ruff_python_semantic = { version = "0.0.16", path = "crates/ruff_python_semantic" } ruff_python_stdlib = { version = "0.0.16", path = "crates/ruff_python_stdlib" } -ruff_python_trivia = { version = "0.0.16", path = "crates/ruff_python_trivia" } +ruff_python_trivia = { package = "rustpython-ruff_python_trivia", version = "0.16.10", path = "crates/ruff_python_trivia" } ruff_server = { version = "0.0.16", path = "crates/ruff_server" } -ruff_source_file = { version = "0.0.16", path = "crates/ruff_source_file" } +ruff_source_file = { package = "rustpython-ruff_source_file", version = "0.16.10", path = "crates/ruff_source_file" } ruff_mdtest = { path = "crates/ruff_mdtest" } ruff_ranged_value = { version = "0.0.16", path = "crates/ruff_ranged_value" } -ruff_text_size = { version = "0.0.16", path = "crates/ruff_text_size" } +ruff_text_size = { package = "rustpython-ruff_text_size", version = "0.16.10", path = "crates/ruff_text_size" } ruff_workspace = { version = "0.0.16", path = "crates/ruff_workspace" } ty = { path = "crates/ty" } @@ -326,9 +326,9 @@ codegen-units = 16 # Some crates don't change as much but benefit more from # more expensive optimization passes, so we selectively # decrease codegen-units in some cases. -[profile.release.package.ruff_python_parser] +[profile.release.package.rustpython-ruff_python_parser] codegen-units = 1 -[profile.release.package.ruff_python_ast] +[profile.release.package.rustpython-ruff_python_ast] codegen-units = 1 [profile.release.package.salsa] codegen-units = 1 @@ -356,7 +356,7 @@ opt-level = 3 # Reduce complexity of a parser function that would trigger a locals limit in a wasm tool. # https://github.com/bytecodealliance/wasm-tools/blob/b5c3d98e40590512a3b12470ef358d5c7b983b15/crates/wasmparser/src/limits.rs#L29 -[profile.dev.package.ruff_python_parser] +[profile.dev.package.rustpython-ruff_python_parser] opt-level = 1 # This profile is meant to mimic the `release` profile as closely as diff --git a/crates/ruff_graph/src/collector.rs b/crates/ruff_graph/src/collector.rs index 7d8aae3a6345cc..24bd8569ab3c2d 100644 --- a/crates/ruff_graph/src/collector.rs +++ b/crates/ruff_graph/src/collector.rs @@ -49,6 +49,7 @@ impl<'ast> SourceOrderVisitor<'ast> for Collector<'_> { is_lazy: _, range: _, node_index: _, + runtime_level: _, }) => { let module = module.as_deref(); let level = *level; @@ -106,6 +107,7 @@ impl<'ast> SourceOrderVisitor<'ast> for Collector<'_> { elif_else_clauses, range: _, node_index: _, + runtime_body: _, }) => { // Skip TYPE_CHECKING blocks if not requested if self.type_checking_imports || !is_type_checking_condition(test) { diff --git a/crates/ruff_linter/src/checkers/ast/analyze/except_handler.rs b/crates/ruff_linter/src/checkers/ast/analyze/except_handler.rs index fd8bed0e299914..bc43ca2947e5b0 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/except_handler.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/except_handler.rs @@ -16,6 +16,7 @@ pub(crate) fn except_handler(except_handler: &ExceptHandler, checker: &Checker) body, range: _, node_index: _, + runtime_body: _, }) => { if checker.is_rule_enabled(Rule::BareExcept) { pycodestyle::rules::bare_except(checker, type_.as_deref(), body, except_handler); diff --git a/crates/ruff_linter/src/checkers/ast/analyze/expression.rs b/crates/ruff_linter/src/checkers/ast/analyze/expression.rs index a4701a1566a9fb..f8f07bd0ae4eb7 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/expression.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/expression.rs @@ -206,12 +206,14 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) { range: _, node_index: _, parenthesized: _, + runtime_elts: _, }) | Expr::List(ast::ExprList { elts, ctx, range: _, node_index: _, + runtime_elts: _, }) => { if checker.is_rule_enabled(Rule::ImplicitStringConcatenationInCollectionLiteral) { flake8_implicit_str_concat::rules::implicit_string_concatenation_in_collection_literal( @@ -538,6 +540,8 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, diff --git a/crates/ruff_linter/src/checkers/ast/analyze/statement.rs b/crates/ruff_linter/src/checkers/ast/analyze/statement.rs index 59a6f527626d3e..f802860f5165fe 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/statement.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/statement.rs @@ -59,6 +59,10 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) { type_params: _, range: _, node_index: _, + runtime_decorator_list: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, }, ) => { if checker.is_rule_enabled(Rule::DjangoNonLeadingReceiverDecorator) { @@ -390,6 +394,8 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) { body, range: _, node_index: _, + runtime_decorator_list: _, + runtime_body: _, }, ) => { if checker.is_rule_enabled(Rule::NoClassmethodDecorator) { @@ -718,6 +724,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) { is_lazy: _, range: _, node_index: _, + runtime_level: _, }, ) => { let level = *level; @@ -1258,6 +1265,10 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) { is_async, range: _, node_index: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, + runtime_orelse: _, }, ) => { if checker.is_rule_enabled(Rule::TooManyNestedBlocks) { @@ -1635,6 +1646,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) { targets, range: _, node_index: _, + runtime_targets: _, }, ) => { if checker.is_rule_enabled(Rule::GlobalStatement) { diff --git a/crates/ruff_linter/src/checkers/ast/mod.rs b/crates/ruff_linter/src/checkers/ast/mod.rs index 344f6aec913021..6325cbe6f6d2b7 100644 --- a/crates/ruff_linter/src/checkers/ast/mod.rs +++ b/crates/ruff_linter/src/checkers/ast/mod.rs @@ -1161,6 +1161,7 @@ impl<'a> Visitor<'a> for Checker<'a> { is_lazy, range: _, node_index: _, + runtime_level: _, }) => { if self.semantic.at_top_level() { self.importer.visit_import(stmt); @@ -1621,6 +1622,9 @@ impl<'a> Visitor<'a> for Checker<'a> { is_async: _, range: _, node_index: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, }) => { for item in items { self.visit_with_item(item); @@ -1635,6 +1639,8 @@ impl<'a> Visitor<'a> for Checker<'a> { orelse, range: _, node_index: _, + runtime_body: _, + runtime_orelse: _, }) => { self.visit_boolean_test(test); self.visit_body(body); @@ -1651,6 +1657,10 @@ impl<'a> Visitor<'a> for Checker<'a> { iter, body, orelse, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, + runtime_orelse: _, }) => { self.visit_expr(iter); self.visit_expr(target); @@ -1667,6 +1677,7 @@ impl<'a> Visitor<'a> for Checker<'a> { elif_else_clauses, range: _, node_index: _, + runtime_body: _, }, ) => { self.visit_boolean_test(test); @@ -2136,6 +2147,7 @@ impl<'a> Visitor<'a> for Checker<'a> { items, range: _, node_index: _, + runtime_values: _, }) = arg { for ast::DictItem { key, value } in items { @@ -2277,6 +2289,7 @@ impl<'a> Visitor<'a> for Checker<'a> { range: _, node_index: _, parenthesized: _, + runtime_elts: _, }) = slice.as_ref() { let mut iter = elts.iter(); @@ -2304,6 +2317,7 @@ impl<'a> Visitor<'a> for Checker<'a> { items, range: _, node_index: _, + runtime_values: _, }) = slice.as_ref() { for item in items { @@ -2395,6 +2409,7 @@ impl<'a> Visitor<'a> for Checker<'a> { body: _, range: _, node_index: _, + runtime_body: _, }) => { if let Some(name) = name { // Store the existing binding, if any. diff --git a/crates/ruff_linter/src/importer/mod.rs b/crates/ruff_linter/src/importer/mod.rs index 27abb8b1c0e5c6..ee124685ecb8b4 100644 --- a/crates/ruff_linter/src/importer/mod.rs +++ b/crates/ruff_linter/src/importer/mod.rs @@ -474,6 +474,7 @@ impl<'a> Importer<'a> { is_lazy: _, range: _, node_index: _, + runtime_level: _, }) = stmt { if *level == 0 diff --git a/crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs b/crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs index 26f220757218a0..2b1383a2f1343d 100644 --- a/crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs +++ b/crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs @@ -264,6 +264,7 @@ fn find_runtime_varying_call<'a>( | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) + | Expr::Constant(_) | Expr::IpyEscapeCommand(_) => None, } } diff --git a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs index 6194d9cde524b6..5172a2bb78527f 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs +++ b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs @@ -649,6 +649,10 @@ pub(crate) fn definition( parameters, returns, body, + runtime_decorator_list: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, } = function; let is_method = definition.is_method(); diff --git a/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs index 1e002c7956f525..d81b5af08efe87 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs @@ -184,6 +184,7 @@ fn is_explicit_concatenation(expr: &Expr) -> Option { Expr::BytesLiteral(_) => Some(false), Expr::NoneLiteral(_) => Some(false), Expr::IpyEscapeCommand(_) => Some(false), + Expr::Constant(_) => None, // Conditionally strings. Expr::Named(ast::ExprNamed { value, .. }) => is_explicit_concatenation(value), diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_false.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_false.rs index 98a7321084c9c1..a99a15e4e4dcb1 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_false.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_false.rs @@ -71,6 +71,8 @@ fn assertion_error(msg: Option<&Expr>) -> Stmt { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/delattr_with_constant.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/delattr_with_constant.rs index 0150b672d351b5..4d319df637d24f 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/delattr_with_constant.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/delattr_with_constant.rs @@ -124,6 +124,7 @@ fn generate_del_statement(obj: &Expr, attr_name: &str, generator: Generator) -> })], range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_targets: None, }); generator.stmt(&stmt) } diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs index c38fc1ecbb5372..90ec02f9be62b0 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs @@ -121,6 +121,7 @@ fn type_pattern(elts: Vec<&Expr>) -> Expr { range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, } .into() } diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs index 84b6e95119e3e9..b308769dfbc7cc 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs @@ -64,6 +64,10 @@ pub(crate) fn loop_iterator_mutation(checker: &Checker, stmt_for: &StmtFor) { is_async: _, range: _, node_index: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, + runtime_orelse: _, } = stmt_for; let (index, target, iter) = match iter.as_ref() { @@ -343,6 +347,7 @@ impl<'a> Visitor<'a> for LoopMutationsVisitor<'a> { range, targets, node_index: _, + runtime_targets: _, }) => { self.handle_delete(*range, targets); visitor::walk_stmt(self, stmt); diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs index 3021d408ebb0ba..47870a51f60989 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs @@ -158,6 +158,7 @@ impl<'a> Visitor<'a> for GroupNameFinder<'a> { elif_else_clauses, range: _, node_index: _, + runtime_body: _, }) => { // Visit the test before pushing the branch counters as it // is evaluated unconditionally. diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/setattr_with_constant.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/setattr_with_constant.rs index 8be6e9843b3581..6ff62c95e2711a 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/setattr_with_constant.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/setattr_with_constant.rs @@ -87,6 +87,9 @@ fn assignment(obj: &Expr, name: &str, value: &Expr, generator: Generator) -> Str value: Box::new(value.clone()), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }); generator.stmt(&stmt) } diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_dict_comprehension_for_iterable.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_dict_comprehension_for_iterable.rs index 15cff71ea00dae..5083467717cd74 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_dict_comprehension_for_iterable.rs +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_dict_comprehension_for_iterable.rs @@ -216,6 +216,8 @@ fn fix_unnecessary_dict_comprehension(value: &Expr, generator: &Comprehension) - keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }; Expr::Call(ExprCall { func: Box::new(Expr::Name(ExprName { diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs index 099f378f8b9966..e697466750d78e 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs @@ -68,6 +68,8 @@ pub(crate) fn unnecessary_list_call(checker: &Checker, expr: &Expr, call: &ExprC node_index: _, args, keywords: _, + runtime_args: _, + runtime_bases: _, } = arguments; let Some(argument) = helpers::first_argument_with_matching_function("list", func, args) else { diff --git a/crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs index ddaeff80749f4c..8482f0c1f03eee 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs +++ b/crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs @@ -75,6 +75,7 @@ pub(crate) fn multiple_starts_ends_with(checker: &Checker, expr: &Expr) { values, range: _, node_index: _, + runtime_values: _, }) = expr else { return; @@ -90,6 +91,8 @@ pub(crate) fn multiple_starts_ends_with(checker: &Checker, expr: &Expr) { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, @@ -151,6 +154,8 @@ pub(crate) fn multiple_starts_ends_with(checker: &Checker, expr: &Expr) { keywords: _, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, @@ -182,6 +187,7 @@ pub(crate) fn multiple_starts_ends_with(checker: &Checker, expr: &Expr) { range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }); let node1 = Expr::Name(ast::ExprName { id: arg_name.into(), @@ -203,6 +209,8 @@ pub(crate) fn multiple_starts_ends_with(checker: &Checker, expr: &Expr) { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, @@ -226,6 +234,7 @@ pub(crate) fn multiple_starts_ends_with(checker: &Checker, expr: &Expr) { .collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_values: None, }); let bool_op = node; diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs index daf5731a84384e..98f3a9eb82bc7e 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs @@ -97,6 +97,7 @@ pub(crate) fn duplicate_literal_member<'a>(checker: &Checker, expr: &'a Expr) { node_index: ruff_python_ast::AtomicNodeIndex::NONE, ctx: ExprContext::Load, parenthesized: false, + runtime_elts: None, }) }), value: subscript.value.clone(), diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs index a11c30ecef088c..a754d0ae48afbc 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs @@ -355,6 +355,7 @@ fn check_positional_args_for_overloaded_method( vararg: None, kwonlyargs, kwarg: None, + runtime_defaults: _, } = &**parameters else { return; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/mod.rs index 88346d95fc0209..6468f795790acd 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/mod.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/mod.rs @@ -146,6 +146,7 @@ fn generate_union_fix( node_index: ruff_python_ast::AtomicNodeIndex::NONE, ctx: ExprContext::Load, parenthesized: false, + runtime_elts: None, })), ctx: ExprContext::Load, }); diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs index 50d4b5ad2787a8..2707853bb27fd9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs @@ -224,6 +224,7 @@ fn create_fix( node_index: ruff_python_ast::AtomicNodeIndex::NONE, ctx: ExprContext::Load, parenthesized: true, + runtime_elts: None, }) } else { literal_elements[0].clone() diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs index 729e8cfadebeeb..65a927cd3e0b65 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs @@ -311,6 +311,7 @@ fn is_valid_default_value_with_annotation( elts, range: _, node_index: _, + runtime_elts: _, }) => { return allow_container && elts.len() <= 10 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs index 5effecb53e26f5..ab80332884f8a7 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs @@ -145,6 +145,7 @@ pub(crate) fn unnecessary_literal_union<'a>(checker: &Checker, expr: &'a Expr) { node_index: ruff_python_ast::AtomicNodeIndex::NONE, ctx: ExprContext::Load, parenthesized: true, + runtime_elts: None, })), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, @@ -169,6 +170,7 @@ pub(crate) fn unnecessary_literal_union<'a>(checker: &Checker, expr: &'a Expr) { node_index: ruff_python_ast::AtomicNodeIndex::NONE, ctx: ExprContext::Load, parenthesized: true, + runtime_elts: None, })), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_type_union.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_type_union.rs index 2d81d84a3e7647..308c07063a33c7 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_type_union.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_type_union.rs @@ -181,6 +181,7 @@ pub(crate) fn unnecessary_type_union<'a>(checker: &Checker, union: &'a Expr) { range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, })), ctx: ExprContext::Load, range: TextRange::default(), @@ -206,6 +207,7 @@ pub(crate) fn unnecessary_type_union<'a>(checker: &Checker, union: &'a Expr) { range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, })), ctx: ExprContext::Load, range: TextRange::default(), diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs index 52261b240900ab..453629389e8b37 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs @@ -654,6 +654,7 @@ fn is_composite_condition(test: &Expr) -> CompositionKind { values, range: _, node_index: _, + runtime_values: _, }) = operand.as_ref() { // Only split cases without mixed `and` and `or`. diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs index f0bd982510f98b..395ba854fc49fb 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs @@ -381,6 +381,7 @@ fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }); diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( format!("({})", checker.generator().expr(&node)), @@ -412,6 +413,7 @@ fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr ctx: ExprContext::Load, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_elts: None, }); diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( checker.generator().expr(&node), @@ -441,6 +443,7 @@ fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr ctx: ExprContext::Load, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_elts: None, }); diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( checker.generator().expr(&node), @@ -487,6 +490,7 @@ fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }); diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( format!("({})", checker.generator().expr(&node)), diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs index da75eaa0143df7..03f36889cb6781 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs @@ -176,6 +176,7 @@ fn compare(left: &Expr, cmp_op: CmpOp, right: &Expr) -> Expr { operands: Box::from([left.clone(), right.clone()]), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_comparators: None, }) } @@ -395,6 +396,8 @@ impl UnittestAssert { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, @@ -444,6 +447,8 @@ impl UnittestAssert { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs index 3db7b8dd1a5fb8..2d3968ac2b2c40 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs @@ -323,6 +323,8 @@ fn isinstance_target<'a>(call: &'a Expr, semantic: &'a SemanticModel) -> Option< keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, @@ -348,6 +350,7 @@ pub(crate) fn duplicate_isinstance_call(checker: &Checker, expr: &Expr) { values, range: _, node_index: _, + runtime_values: _, }) = expr else { return; @@ -485,6 +488,7 @@ pub(crate) fn compare_with_tuple(checker: &Checker, expr: &Expr) { values, range: _, node_index: _, + runtime_values: _, }) = expr else { return; @@ -542,6 +546,7 @@ pub(crate) fn compare_with_tuple(checker: &Checker, expr: &Expr) { range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }; let node1 = ast::ExprName { id: id.clone(), @@ -554,6 +559,7 @@ pub(crate) fn compare_with_tuple(checker: &Checker, expr: &Expr) { operands: Box::from([node1.into(), node.into()]), range: node_range, node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_comparators: None, }; let in_expr = node2.into(); let mut diagnostic = checker.report_diagnostic( @@ -581,6 +587,7 @@ pub(crate) fn compare_with_tuple(checker: &Checker, expr: &Expr) { .collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_values: None, }; node.into() }; @@ -598,6 +605,7 @@ pub(crate) fn expr_and_not_expr(checker: &Checker, expr: &Expr) { values, range: _, node_index: _, + runtime_values: _, }) = expr else { return; @@ -656,6 +664,7 @@ pub(crate) fn expr_or_not_expr(checker: &Checker, expr: &Expr) { values, range: _, node_index: _, + runtime_values: _, }) = expr else { return; @@ -743,6 +752,7 @@ fn is_short_circuit( values, range: _, node_index: _, + runtime_values: _, }) = expr else { return None; diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs index 0a5ffa70e98de2..f3bbf89ebe048a 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs @@ -196,6 +196,8 @@ pub(crate) fn if_expr_with_true_false( keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs index d802ed3f866df2..9f5eea09520adb 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs @@ -183,6 +183,7 @@ pub(crate) fn negation_with_equal_op(checker: &Checker, expr: &Expr, op: UnaryOp operands: compare.operands.clone(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_comparators: None, }; diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( checker.generator().expr(&node.into()), @@ -231,6 +232,7 @@ pub(crate) fn negation_with_not_equal_op( operands: compare.operands.clone(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_comparators: None, }; diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( checker.generator().expr(&node.into()), @@ -281,6 +283,8 @@ pub(crate) fn double_negation(checker: &Checker, expr: &Expr, op: UnaryOp, opera keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs index 1f72dd2bc1412f..f0a3eed9a9a6f0 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs @@ -202,6 +202,8 @@ pub(crate) fn if_else_block_instead_of_dict_get(checker: &Checker, stmt_if: &ast keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, @@ -212,6 +214,9 @@ pub(crate) fn if_else_block_instead_of_dict_get(checker: &Checker, stmt_if: &ast value: Box::new(node3.into()), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }; let contents = checker.generator().stmt(&node5.into()); @@ -304,6 +309,8 @@ pub(crate) fn if_exp_instead_of_dict_get( keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs index 0ae0a887d27462..87ced474a8f7bf 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs @@ -105,6 +105,7 @@ pub(crate) fn if_else_block_instead_of_if_exp(checker: &Checker, stmt_if: &ast:: elif_else_clauses, range: _, node_index: _, + runtime_body: _, } = stmt_if; // `test: None` to only match an `else` clause @@ -280,6 +281,9 @@ fn assignment_ternary( value: Box::new(node.into()), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }; node1.into() } @@ -290,12 +294,16 @@ fn assignment_binary_and(target_var: &Expr, left_value: &Expr, right_value: &Exp values: vec![left_value.clone(), right_value.clone()], range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_values: None, }; let node1 = ast::StmtAssign { targets: vec![target_var.clone()], value: Box::new(node.into()), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }; node1.into() } @@ -311,9 +319,13 @@ fn assignment_binary_or(target_var: &Expr, left_value: &Expr, right_value: &Expr node_index: ruff_python_ast::AtomicNodeIndex::NONE, op: BoolOp::Or, values: vec![left_value.clone(), right_value.clone()], + runtime_values: None, }) .into(), ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }) .into() } diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/needless_bool.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/needless_bool.rs index 1019c0b39db5aa..e3c9dca61c1df2 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/needless_bool.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/needless_bool.rs @@ -135,12 +135,16 @@ pub(crate) fn needless_bool(checker: &Checker, stmt: &Stmt) { test: Some(elif_test), range: elif_range, node_index: _, + runtime_body: _, + runtime_orelse: _, }, ElifElseClause { body: else_body, test: None, range: else_range, node_index: _, + runtime_body: _, + runtime_orelse: _, }, ] => ( elif_test, @@ -249,6 +253,7 @@ pub(crate) fn needless_bool(checker: &Checker, stmt: &Stmt) { operands: operands.clone(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_comparators: None, })) } @@ -278,6 +283,8 @@ pub(crate) fn needless_bool(checker: &Checker, stmt: &Stmt) { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs index 00823723a2dfa6..d4b47e24064c8d 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs @@ -155,6 +155,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) { operands: compare.operands.clone(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_comparators: None, }; node.into() } else { @@ -264,6 +265,7 @@ fn match_loop(stmt: &Stmt) -> Option> { elif_else_clauses: nested_elif_else_clauses, range: _, node_index: _, + runtime_body: _, }), ] = body.as_slice() else { @@ -387,6 +389,8 @@ fn return_stmt(id: Name, test: &Expr, target: &Expr, iter: &Expr, generator: Gen is_async: false, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_ifs: None, + runtime_is_async: None, }], range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, @@ -405,6 +409,8 @@ fn return_stmt(id: Name, test: &Expr, target: &Expr, iter: &Expr, generator: Gen keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs index 0546ccd38f0274..47b20f3f679bb5 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs @@ -190,6 +190,7 @@ fn construct_replacement(elts: &[&str], flags: StringLiteralFlags) -> Expr { ctx: ExprContext::Load, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_elts: None, }) } diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs index e16a8710f009b6..abff2bfc70d098 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs @@ -113,6 +113,7 @@ fn fix_banned_relative_import( is_lazy: *is_lazy, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_level: None, }; let content = generator.stmt(&node.into()); Some(Fix::unsafe_edit(Edit::range_replacement( diff --git a/crates/ruff_linter/src/rules/flynt/helpers.rs b/crates/ruff_linter/src/rules/flynt/helpers.rs index d0ea3ea97e1f14..e3618d47961c2f 100644 --- a/crates/ruff_linter/src/rules/flynt/helpers.rs +++ b/crates/ruff_linter/src/rules/flynt/helpers.rs @@ -10,6 +10,9 @@ fn to_interpolated_string_interpolation_element(inner: &Expr) -> ast::Interpolat format_spec: None, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_formatted_value_format_spec: None, + runtime_interpolation_format_spec: None, + runtime_str: None, }) } @@ -34,6 +37,8 @@ fn is_simple_call(expr: &Expr) -> bool { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, diff --git a/crates/ruff_linter/src/rules/isort/annotate.rs b/crates/ruff_linter/src/rules/isort/annotate.rs index b70c665925a2b2..582ad32c5e9e00 100644 --- a/crates/ruff_linter/src/rules/isort/annotate.rs +++ b/crates/ruff_linter/src/rules/isort/annotate.rs @@ -67,6 +67,7 @@ pub(crate) fn annotate_imports<'a>( is_lazy, range: _, node_index: _, + runtime_level: _, }) => { // Find comments above. let mut atop = vec![]; diff --git a/crates/ruff_linter/src/rules/isort/rules/add_required_imports.rs b/crates/ruff_linter/src/rules/isort/rules/add_required_imports.rs index 0ac06f80f9546f..f3f5303208b6c9 100644 --- a/crates/ruff_linter/src/rules/isort/rules/add_required_imports.rs +++ b/crates/ruff_linter/src/rules/isort/rules/add_required_imports.rs @@ -82,6 +82,7 @@ fn includes_import(stmt: &Stmt, target: &NameImport) -> bool { is_lazy: _, range: _, node_index: _, + runtime_level: _, }) = &stmt else { return false; diff --git a/crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs b/crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs index fd47256e934331..1cd48cac910e74 100644 --- a/crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs +++ b/crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs @@ -124,6 +124,9 @@ pub(crate) fn manual_dict_comprehension(checker: &Checker, for_stmt: &ast::StmtF value, range, node_index: _, + runtime_targets: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, }) = stmt else { return; diff --git a/crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs b/crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs index f74bdb14846f6a..0ed65383aaacca 100644 --- a/crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs +++ b/crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs @@ -146,6 +146,8 @@ pub(crate) fn manual_list_comprehension(checker: &Checker, for_stmt: &ast::StmtF keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, diff --git a/crates/ruff_linter/src/rules/perflint/rules/manual_list_copy.rs b/crates/ruff_linter/src/rules/perflint/rules/manual_list_copy.rs index e34b29ccfbea22..d7c22c6d350ac3 100644 --- a/crates/ruff_linter/src/rules/perflint/rules/manual_list_copy.rs +++ b/crates/ruff_linter/src/rules/perflint/rules/manual_list_copy.rs @@ -74,6 +74,8 @@ pub(crate) fn manual_list_copy(checker: &Checker, for_stmt: &ast::StmtFor) { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, diff --git a/crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs b/crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs index 8ee945c57010b1..513a6f8ff0d62e 100644 --- a/crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs +++ b/crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs @@ -76,6 +76,8 @@ pub(crate) fn unnecessary_list_cast(checker: &Checker, iter: &Expr, body: &[Stmt keywords: _, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs index 167f736cac0ebf..04b1b594c62b69 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs @@ -247,6 +247,10 @@ fn function( type_params: None, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_body: None, + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }); let generated = checker.generator().stmt(&func); @@ -263,6 +267,10 @@ fn function( type_params: None, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_body: None, + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }); let generated = checker.generator().stmt(&function); diff --git a/crates/ruff_linter/src/rules/pylint/rules/bad_string_format_type.rs b/crates/ruff_linter/src/rules/pylint/rules/bad_string_format_type.rs index 0da09d6ce4d212..6c9419a9353f3b 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/bad_string_format_type.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/bad_string_format_type.rs @@ -243,6 +243,7 @@ pub(crate) fn bad_string_format_type( items, range: _, node_index: _, + runtime_values: _, }) => is_valid_dict(&format_strings, items), _ => is_valid_constant(&format_strings, &bin_op.right), }; diff --git a/crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs b/crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs index 1c79717bfdf44b..314e7efa94dab2 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs @@ -90,6 +90,7 @@ pub(crate) fn if_stmt_min_max(checker: &Checker, stmt_if: &ast::StmtIf) { elif_else_clauses, range: _, node_index: _, + runtime_body: _, } = stmt_if; if !elif_else_clauses.is_empty() { diff --git a/crates/ruff_linter/src/rules/pylint/rules/manual_import_from.rs b/crates/ruff_linter/src/rules/pylint/rules/manual_import_from.rs index 2a9b5d51a7484c..a044f772a65f76 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/manual_import_from.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/manual_import_from.rs @@ -102,6 +102,7 @@ pub(crate) fn manual_from_import(checker: &Checker, stmt: &Stmt, alias: &Alias, is_lazy, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_level: None, }; diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement( checker.generator().stmt(&node.into()), diff --git a/crates/ruff_linter/src/rules/pylint/rules/nested_min_max.rs b/crates/ruff_linter/src/rules/pylint/rules/nested_min_max.rs index 2ef25da39aa96a..6e08b3313245dc 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/nested_min_max.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/nested_min_max.rs @@ -137,6 +137,8 @@ fn collect_nested_args(min_max: MinMax, args: &[Expr], semantic: &SemanticModel) keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, @@ -207,6 +209,8 @@ pub(crate) fn nested_min_max( keywords: keywords.iter().cloned().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs b/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs index c3a95da7419233..5d631ca79c8a7d 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs @@ -325,6 +325,7 @@ fn assignment_targets_from_expr<'a>( elts, range: _, node_index: _, + runtime_elts: _, }) => Box::new( elts.iter() .flat_map(|elt| assignment_targets_from_expr(elt, dummy_variable_rgx)), @@ -335,6 +336,7 @@ fn assignment_targets_from_expr<'a>( range: _, node_index: _, parenthesized: _, + runtime_elts: _, }) => Box::new( elts.iter() .flat_map(|elt| assignment_targets_from_expr(elt, dummy_variable_rgx)), diff --git a/crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs b/crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs index 592987e01f6be5..9e7e66a0716b62 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs @@ -186,6 +186,7 @@ pub(crate) fn repeated_equality_comparison(checker: &Checker, bool_op: &ast::Exp elts: comparators.iter().copied().cloned().collect(), range: TextRange::default(), node_index: AtomicNodeIndex::NONE, + runtime_elts: None, }) } else { Expr::Tuple(ast::ExprTuple { @@ -194,6 +195,7 @@ pub(crate) fn repeated_equality_comparison(checker: &Checker, bool_op: &ast::Exp node_index: AtomicNodeIndex::NONE, ctx: ExprContext::Load, parenthesized: true, + runtime_elts: None, }) }; @@ -209,11 +211,13 @@ pub(crate) fn repeated_equality_comparison(checker: &Checker, bool_op: &ast::Exp operands: Box::from([expr.clone(), comparator]), range: bool_op.range(), node_index: AtomicNodeIndex::NONE, + runtime_comparators: None, }))) .chain(after) .collect(), range: bool_op.range(), node_index: AtomicNodeIndex::NONE, + runtime_values: None, })), bool_op.range(), ))); diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs index 08bf1a7c68a6f2..3922c5ec6572a4 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs @@ -178,6 +178,7 @@ fn create_field_assignment_stmt(field: Name, annotation: &Expr) -> Stmt { simple: true, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_simple: None, } .into() } @@ -241,12 +242,16 @@ fn create_class_def_stmt(typename: &str, body: Suite, base_class: &Expr) -> Stmt keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, })), body, type_params: None, decorator_list: DecoratorList::new(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_body: None, + runtime_decorator_list: None, } .into() } diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs index d3fe28f1ffbb38..bb993248b6198a 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs @@ -163,6 +163,7 @@ fn create_field_assignment_stmt(field: &str, annotation: &Expr) -> Stmt { simple: true, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_simple: None, } .into() } @@ -181,12 +182,16 @@ fn create_class_def_stmt( keywords: keywords.into(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, })), body, type_params: None, decorator_list: ast::DecoratorList::new(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_body: None, + runtime_decorator_list: None, } .into() } @@ -267,6 +272,7 @@ fn match_fields_and_keywords(arguments: &Arguments) -> Option<(Suite, &[Keyword] items, range: _, node_index: _, + runtime_values: _, }) => Some((fields_from_dict_literal(items)?, keywords)), Expr::Call(ast::ExprCall { func, diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs index 8ecac83a42f551..88d83f4fc9132f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs @@ -83,6 +83,7 @@ pub(crate) fn deprecated_c_element_tree(checker: &Checker, stmt: &Stmt) { is_lazy, range: _, node_index: _, + runtime_level: _, }) => { if *level > 0 { // Ex) `import .xml.etree.cElementTree as ET` diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs index 98f58f138cb7e4..a85ad550e2518c 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs @@ -71,6 +71,8 @@ pub(crate) fn lru_cache_with_maxsize_none(checker: &Checker, decorator_list: &[D keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/native_literals.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/native_literals.rs index 58f74144f77d04..ba3416d067d60b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/native_literals.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/native_literals.rs @@ -196,6 +196,8 @@ pub(crate) fn native_literals( keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs index c7bcb169c6da5d..8fb36d8e65a093 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs @@ -146,6 +146,7 @@ fn tuple_diagnostic(checker: &Checker, tuple: &ast::ExprTuple, aliases: &[&Expr] range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }; format!("({})", checker.generator().expr(&node.into())) }; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/mod.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/mod.rs index 2155add5297f79..07ad68ffbe04d6 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/mod.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/mod.rs @@ -164,6 +164,7 @@ impl<'a> From<&'a TypeVar<'a>> for TypeParam { elts: constraints.iter().map(|expr| (*expr).clone()).collect(), ctx: ast::ExprContext::Load, parenthesized: true, + runtime_elts: None, }))) } Some(TypeVarRestriction::AnyStr) => { @@ -186,6 +187,7 @@ impl<'a> From<&'a TypeVar<'a>> for TypeParam { ], ctx: ast::ExprContext::Load, parenthesized: true, + runtime_elts: None, }))) } None => None, diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs index 7396addf2643eb..b6390b44d8344c 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs @@ -237,6 +237,7 @@ fn clean_params_dictionary(right: &Expr, locator: &Locator, stylist: &Stylist) - items, range: _, node_index: _, + runtime_values: _, }) = &right { let mut arguments: Vec = vec![]; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs index 4933330ba5adea..045e91601b44df 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs @@ -159,6 +159,7 @@ fn tuple_diagnostic(checker: &Checker, tuple: &ast::ExprTuple, aliases: &[&Expr] range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }; format!("({})", checker.generator().expr(&node.into())) }; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs index a1c76c016bbcfd..abf3cd3582e68b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs @@ -87,6 +87,7 @@ pub(crate) fn unnecessary_default_type_args(checker: &Checker, expr: &Expr) { range: _, node_index: _, parenthesized: _, + runtime_elts: _, }) = slice.as_ref() else { return; @@ -131,6 +132,7 @@ pub(crate) fn unnecessary_default_type_args(checker: &Checker, expr: &Expr) { range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }) }), ctx: ast::ExprContext::Load, diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs index e7fdb3ee6ad0f3..7d44175bffeced 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs @@ -326,6 +326,7 @@ fn is_allowed_value(expr: &Expr) -> bool { | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) + | Expr::Constant(_) | Expr::Attribute(_) | Expr::Subscript(_) | Expr::Name(_) diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs index dfa34e7b29eb8a..0de36d1be1f7e0 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs @@ -83,6 +83,10 @@ pub(crate) fn yield_in_for_loop(checker: &Checker, stmt_for: &ast::StmtFor) { is_async: _, range: _, node_index: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, + runtime_orelse: _, } = stmt_for; // If there is an else statement, don't rewrite. diff --git a/crates/ruff_linter/src/rules/refurb/helpers.rs b/crates/ruff_linter/src/rules/refurb/helpers.rs index ca9fe538102e09..2cb4ca949e3d52 100644 --- a/crates/ruff_linter/src/rules/refurb/helpers.rs +++ b/crates/ruff_linter/src/rules/refurb/helpers.rs @@ -36,6 +36,8 @@ pub(super) fn generate_method_call(name: Name, method: &str, generator: Generato keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, @@ -70,6 +72,7 @@ pub(super) fn replace_with_identity_check( operands: [left.clone(), ast::ExprNoneLiteral::default().into()].into(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_comparators: None, }); let new_content = generator.expr(&new_expr); diff --git a/crates/ruff_linter/src/rules/refurb/rules/bit_count.rs b/crates/ruff_linter/src/rules/refurb/rules/bit_count.rs index 150b439f6e78c4..8b800854e1ab11 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/bit_count.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/bit_count.rs @@ -157,6 +157,7 @@ pub(crate) fn bit_count(checker: &Checker, call: &ExprCall) { | Expr::Compare(_) | Expr::Tuple(_) | Expr::Generator(_) + | Expr::Constant(_) | Expr::IpyEscapeCommand(_) => true, Expr::Call(_) diff --git a/crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs b/crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs index 246fe7800cd538..3f080c95a49df9 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs @@ -192,6 +192,8 @@ fn make_suggestion(set: &ast::ExprName, element: &Expr, generator: Generator) -> keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs b/crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs index 4b80046487a1d0..a4b8f300c3cbd2 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs @@ -183,6 +183,8 @@ fn make_suggestion(open: &FileOpen<'_>, generator: Generator) -> String { keywords: open.keywords.iter().copied().cloned().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs b/crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs index 55d24484b88793..9be236189855f8 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs @@ -324,6 +324,8 @@ fn construct_starmap_call(starmap_binding: Name, iter: &Expr, func: &Expr) -> as keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, @@ -345,6 +347,8 @@ fn wrap_with_call_to(call: ast::ExprCall, func_name: Name) -> ast::ExprCall { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs b/crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs index f28da1ba5925da..9297ec6977576c 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs @@ -346,6 +346,7 @@ fn make_suggestion(group: &AppendGroup, generator: Generator) -> String { range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }; // Make `var.extend`. // NOTE: receiver is the same for all appends and that's why we can take the first. @@ -364,6 +365,8 @@ fn make_suggestion(group: &AppendGroup, generator: Generator) -> String { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs b/crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs index 5c23bdae1d46f9..6299cd659732e0 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs @@ -189,6 +189,7 @@ fn affix_removal_data_stmt(if_stmt: &ast::StmtIf) -> Option> elif_else_clauses, range: _, node_index: _, + runtime_body: _, } = if_stmt; // Cannot safely transform, e.g., @@ -222,6 +223,9 @@ fn affix_removal_data_stmt(if_stmt: &ast::StmtIf) -> Option> targets, range: _, node_index: _, + runtime_targets: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, } = statement.as_assign_stmt()?; let [target] = targets.as_slice() else { return None; diff --git a/crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs b/crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs index 0f59b8b3c90ef9..f2c7faff84d784 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs @@ -252,6 +252,8 @@ fn generate_range_len_call(name: Name, generator: Generator) -> String { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, @@ -272,6 +274,8 @@ fn generate_range_len_call(name: Name, generator: Generator) -> String { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_linter/src/rules/ruff/rules/assert_with_print_message.rs b/crates/ruff_linter/src/rules/ruff/rules/assert_with_print_message.rs index bab669f7b677c3..8be5855a71c614 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/assert_with_print_message.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/assert_with_print_message.rs @@ -134,6 +134,9 @@ mod print_arguments { format_spec: None, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_formatted_value_format_spec: None, + runtime_interpolation_format_spec: None, + runtime_str: None, }, )], } @@ -252,6 +255,8 @@ mod print_arguments { }), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_joined_str: None, + runtime_values: None, })) } diff --git a/crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs b/crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs index 629407c172e8c9..ec5351f771462a 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs @@ -169,6 +169,7 @@ fn concatenate_expressions(expr: &Expr) -> Option<(Expr, Type)> { ctx: ExprContext::Load, range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_elts: None, } .into(), Type::Tuple => ast::ExprTuple { @@ -177,6 +178,7 @@ fn concatenate_expressions(expr: &Expr) -> Option<(Expr, Type)> { range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, } .into(), }; diff --git a/crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs b/crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs index 9d2d6bfe5bb2ee..1c7f4506724eef 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs @@ -322,6 +322,7 @@ const fn is_valid_enclosing_node(node: AnyNodeRef) -> bool { | AnyNodeRef::ExprList(_) | AnyNodeRef::ExprTuple(_) | AnyNodeRef::ExprSlice(_) + | AnyNodeRef::ExprConstant(_) | AnyNodeRef::ExprIpyEscapeCommand(_) | AnyNodeRef::PatternMatchValue(_) | AnyNodeRef::PatternMatchSingleton(_) diff --git a/crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs b/crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs index 6d5fb72c5d97b5..387a834f6ab451 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs @@ -266,6 +266,8 @@ fn generate_with_statement( }) .as_slice() .into(), + runtime_args: None, + runtime_bases: None, }, }; @@ -278,6 +280,8 @@ fn generate_with_statement( range: TextRange::default(), args: func_args.into(), keywords: func_keywords.into(), + runtime_args: None, + runtime_bases: None, }, }; @@ -287,6 +291,9 @@ fn generate_with_statement( range: TextRange::default(), targets: assign_targets.to_vec(), value: Box::new(func_call.into()), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }) } else { Stmt::Expr(StmtExpr { @@ -307,5 +314,8 @@ fn generate_with_statement( optional_vars: optional_vars.map(|var| Box::new(var.clone())), }], body: ast::Suite::from([body]), + runtime_body: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }) } diff --git a/crates/ruff_linter/src/rules/ruff/rules/map_int_version_parsing.rs b/crates/ruff_linter/src/rules/ruff/rules/map_int_version_parsing.rs index 132d6f309c6db3..3e20cbd2dbe522 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/map_int_version_parsing.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/map_int_version_parsing.rs @@ -71,6 +71,8 @@ fn map_call_with_two_arguments<'a>( keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, range_start: _, node_index: _, diff --git a/crates/ruff_linter/src/rules/ruff/rules/mutable_fromkeys_value.rs b/crates/ruff_linter/src/rules/ruff/rules/mutable_fromkeys_value.rs index 04552bfa7707c0..8593906cfbdee5 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/mutable_fromkeys_value.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/mutable_fromkeys_value.rs @@ -119,6 +119,8 @@ fn generate_dict_comprehension( range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, is_async: false, + runtime_ifs: None, + runtime_is_async: None, }; // Construct the dict comprehension. let dict_comp = ast::ExprDictComp { diff --git a/crates/ruff_linter/src/rules/ruff/rules/never_union.rs b/crates/ruff_linter/src/rules/ruff/rules/never_union.rs index 2b060b0106436e..bc4b07dd21af02 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/never_union.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/never_union.rs @@ -192,6 +192,7 @@ pub(crate) fn never_union(checker: &Checker, expr: &Expr) { range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, })), ctx: ast::ExprContext::Load, range: TextRange::default(), diff --git a/crates/ruff_linter/src/rules/ruff/rules/none_not_at_end_of_union.rs b/crates/ruff_linter/src/rules/ruff/rules/none_not_at_end_of_union.rs index 7b26826b0d5bb8..6b67f5bfde56a6 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/none_not_at_end_of_union.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/none_not_at_end_of_union.rs @@ -186,6 +186,7 @@ fn generate_fix( range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, parenthesized: false, + runtime_elts: None, })), ctx: ruff_python_ast::ExprContext::Load, range: TextRange::default(), diff --git a/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs b/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs index b6c2d12833a407..33b0faae72834a 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs @@ -230,6 +230,7 @@ impl<'a> StringLiteralDisplay<'a> { elts, range, node_index: _, + runtime_elts: _, }) => { let kind = DisplayKind::Sequence(SequenceKind::Set); Self { diff --git a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs index 6ad14cb512313b..cce4f9d7867f4a 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs @@ -121,6 +121,7 @@ pub(crate) fn unnecessary_nested_literal<'a>(checker: &Checker, literal_expr: &' node_index: ruff_python_ast::AtomicNodeIndex::NONE, ctx: ExprContext::Load, parenthesized: false, + runtime_elts: None, }) }), value: subscript.value.clone(), diff --git a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs index 7be3413aa910b2..a84295305f74a6 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs @@ -336,6 +336,7 @@ impl<'a> ReFunc<'a> { operands: Box::new([left.clone(), right.clone()]), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_comparators: None, }) } @@ -356,6 +357,8 @@ impl<'a> ReFunc<'a> { keywords: std::iter::empty().collect(), range: TextRange::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, + runtime_args: None, + runtime_bases: None, }, range_start: ruff_text_size::TextSize::default(), node_index: ruff_python_ast::AtomicNodeIndex::NONE, diff --git a/crates/ruff_python_ast/Cargo.toml b/crates/ruff_python_ast/Cargo.toml index 9b4ba3cc8a85a1..4dcd66c6b6eeb5 100644 --- a/crates/ruff_python_ast/Cargo.toml +++ b/crates/ruff_python_ast/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "ruff_python_ast" -version = "0.0.16" -description = "This is an internal component crate of Ruff" +description = "Unofficial fork for RustPython" +name = "rustpython-ruff_python_ast" +version = "0.16.10" authors = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } @@ -15,6 +15,7 @@ license = { workspace = true } ignored = ["ruff_cache"] [lib] +name = "ruff_python_ast" [dependencies] ruff_cache = { workspace = true, optional = true } diff --git a/crates/ruff_python_ast/ast.toml b/crates/ruff_python_ast/ast.toml index 8c6494951b6941..c730de0542ae44 100644 --- a/crates/ruff_python_ast/ast.toml +++ b/crates/ruff_python_ast/ast.toml @@ -69,7 +69,10 @@ doc = "See also [mod](https://docs.python.org/3/library/ast.html#ast.mod)" [Mod.nodes.ModModule] doc = "See also [Module](https://docs.python.org/3/library/ast.html#ast.Module)" -fields = [{ name = "body", type = "ThinVec" }] +fields = [ + { name = "body", type = "ThinVec" }, + { name = "runtime_body", type = "Vec>?", skip_visit = true }, +] [Mod.nodes.ModExpression] doc = "See also [Module](https://docs.python.org/3/library/ast.html#ast.Module)" @@ -93,6 +96,10 @@ fields = [ { name = "parameters", type = "Box" }, { name = "returns", type = "Expr?", is_annotation = true }, { name = "body", type = "ThinVec" }, + { name = "runtime_decorator_list", type = "Vec>?", skip_visit = true }, + { name = "runtime_type_comment", type = "Box?", skip_visit = true }, + { name = "runtime_type_comment_bytes", type = "Vec?", skip_visit = true }, + { name = "runtime_body", type = "Vec>?", skip_visit = true }, ] [Stmt.nodes.StmtClassDef] @@ -103,6 +110,8 @@ fields = [ { name = "type_params", type = "Box?" }, { name = "arguments", type = "Box?" }, { name = "body", type = "ThinVec" }, + { name = "runtime_decorator_list", type = "Vec>?", skip_visit = true }, + { name = "runtime_body", type = "Vec>?", skip_visit = true }, ] [Stmt.nodes.StmtReturn] @@ -111,7 +120,10 @@ fields = [{ name = "value", type = "Expr?" }] [Stmt.nodes.StmtDelete] doc = "See also [Delete](https://docs.python.org/3/library/ast.html#ast.Delete)" -fields = [{ name = "targets", type = "Expr*" }] +fields = [ + { name = "targets", type = "Expr*" }, + { name = "runtime_targets", type = "Vec>?", skip_visit = true }, +] [Stmt.nodes.StmtTypeAlias] doc = "See also [TypeAlias](https://docs.python.org/3/library/ast.html#ast.TypeAlias)" @@ -126,6 +138,9 @@ doc = "See also [Assign](https://docs.python.org/3/library/ast.html#ast.Assign)" fields = [ { name = "targets", type = "Expr*" }, { name = "value", type = "Expr" }, + { name = "runtime_targets", type = "Vec>?", skip_visit = true }, + { name = "runtime_type_comment", type = "Box?", skip_visit = true }, + { name = "runtime_type_comment_bytes", type = "Vec?", skip_visit = true }, ] [Stmt.nodes.StmtAugAssign] @@ -143,6 +158,7 @@ fields = [ { name = "annotation", type = "Expr", is_annotation = true }, { name = "value", type = "Expr?" }, { name = "simple", type = "bool" }, + { name = "runtime_simple", type = "i32?", skip_visit = true }, ] [Stmt.nodes.StmtFor] @@ -156,6 +172,10 @@ fields = [ { name = "iter", type = "Expr" }, { name = "body", type = "ThinVec" }, { name = "orelse", type = "ThinVec" }, + { name = "runtime_type_comment", type = "Box?", skip_visit = true }, + { name = "runtime_type_comment_bytes", type = "Vec?", skip_visit = true }, + { name = "runtime_body", type = "Vec>?", skip_visit = true }, + { name = "runtime_orelse", type = "Vec>?", skip_visit = true }, ] [Stmt.nodes.StmtWhile] @@ -165,6 +185,8 @@ fields = [ { name = "test", type = "Expr" }, { name = "body", type = "ThinVec" }, { name = "orelse", type = "ThinVec" }, + { name = "runtime_body", type = "Vec>?", skip_visit = true }, + { name = "runtime_orelse", type = "Vec>?", skip_visit = true }, ] [Stmt.nodes.StmtIf] @@ -174,6 +196,7 @@ fields = [ { name = "test", type = "Expr" }, { name = "body", type = "ThinVec" }, { name = "elif_else_clauses", type = "ElifElseClause*" }, + { name = "runtime_body", type = "Vec>?", skip_visit = true }, ] [Stmt.nodes.StmtWith] @@ -185,6 +208,9 @@ fields = [ { name = "is_async", type = "bool" }, { name = "items", type = "WithItem*" }, { name = "body", type = "ThinVec" }, + { name = "runtime_type_comment", type = "Box?", skip_visit = true }, + { name = "runtime_type_comment_bytes", type = "Vec?", skip_visit = true }, + { name = "runtime_body", type = "Vec>?", skip_visit = true }, ] [Stmt.nodes.StmtMatch] @@ -207,6 +233,10 @@ fields = [ { name = "orelse", type = "ThinVec" }, { name = "finalbody", type = "ThinVec" }, { name = "is_star", type = "bool" }, + { name = "runtime_body", type = "Vec>?", skip_visit = true }, + { name = "runtime_handlers", type = "Vec>?", skip_visit = true }, + { name = "runtime_orelse", type = "Vec>?", skip_visit = true }, + { name = "runtime_finalbody", type = "Vec>?", skip_visit = true }, ] [Stmt.nodes.StmtAssert] @@ -227,6 +257,7 @@ fields = [ { name = "names", type = "Alias*" }, { name = "level", type = "u32" }, { name = "is_lazy", type = "bool" }, + { name = "runtime_level", type = "i32?", skip_visit = true }, ] [Stmt.nodes.StmtGlobal] @@ -321,7 +352,11 @@ doc = "See also [expr](https://docs.python.org/3/library/ast.html#ast.expr)" [Expr.nodes.ExprBoolOp] doc = "See also [BoolOp](https://docs.python.org/3/library/ast.html#ast.BoolOp)" -fields = [{ name = "op", type = "BoolOp" }, { name = "values", type = "Expr*" }] +fields = [ + { name = "op", type = "BoolOp" }, + { name = "values", type = "Expr*" }, + { name = "runtime_values", type = "Vec>?", skip_visit = true }, +] custom_source_order = true [Expr.nodes.ExprNamed] @@ -361,12 +396,18 @@ source_order = ["body", "test", "orelse"] [Expr.nodes.ExprDict] doc = "See also [Dict](https://docs.python.org/3/library/ast.html#ast.Dict)" -fields = [{ name = "items", type = "DictItem*" }] +fields = [ + { name = "items", type = "DictItem*" }, + { name = "runtime_values", type = "Vec>?", skip_visit = true }, +] custom_source_order = true [Expr.nodes.ExprSet] doc = "See also [Set](https://docs.python.org/3/library/ast.html#ast.Set)" -fields = [{ name = "elts", type = "Expr*" }] +fields = [ + { name = "elts", type = "Expr*" }, + { name = "runtime_elts", type = "Vec>?", skip_visit = true }, +] [Expr.nodes.ExprListComp] doc = "See also [ListComp](https://docs.python.org/3/library/ast.html#ast.ListComp)" @@ -421,6 +462,7 @@ See also [Compare](https://docs.python.org/3/library/ast.html#ast.Compare).""" fields = [ { name = "ops", type = "Box<[CmpOp]>" }, { name = "operands", type = "Box<[Expr]>" }, + { name = "runtime_comparators", type = "Vec>?", skip_visit = true }, ] # The fields must be visited simultaneously custom_source_order = true @@ -449,7 +491,11 @@ doesn't join the implicitly concatenated parts into a single string. Instead, it keeps them separate and provide various methods to access the parts. See also [JoinedStr](https://docs.python.org/3/library/ast.html#ast.JoinedStr)""" -fields = [{ name = "value", type = "FStringValue" }] +fields = [ + { name = "value", type = "FStringValue" }, + { name = "runtime_joined_str", type = "Vec?", skip_visit = true }, + { name = "runtime_values", type = "Vec>?", skip_visit = true }, +] custom_source_order = true [Expr.nodes.ExprTString] @@ -461,7 +507,11 @@ doesn't join the implicitly concatenated parts into a single string. Instead, it keeps them separate and provide various methods to access the parts. See also [TemplateStr](https://docs.python.org/3/library/ast.html#ast.TemplateStr)""" -fields = [{ name = "value", type = "TStringValue" }] +fields = [ + { name = "value", type = "TStringValue" }, + { name = "runtime_template_str", type = "Vec?", skip_visit = true }, + { name = "runtime_values", type = "Vec>?", skip_visit = true }, +] custom_source_order = true [Expr.nodes.ExprStringLiteral] @@ -493,6 +543,14 @@ derives = ["Default"] fields = [] derives = ["Default"] +[Expr.nodes.ExprConstant] +doc = "See also [Constant](https://docs.python.org/3/library/ast.html#ast.Constant)" +fields = [ + { name = "value", type = "ConstantValue", skip_visit = true }, + { name = "kind", type = "Box?", skip_visit = true }, + { name = "invalid_type", type = "Box?", skip_visit = true }, +] + [Expr.nodes.ExprAttribute] doc = "See also [Attribute](https://docs.python.org/3/library/ast.html#ast.Attribute)" fields = [ @@ -528,6 +586,7 @@ doc = "See also [List](https://docs.python.org/3/library/ast.html#ast.List)" fields = [ { name = "elts", type = "Expr*" }, { name = "ctx", type = "ExprContext" }, + { name = "runtime_elts", type = "Vec>?", skip_visit = true }, ] [Expr.nodes.ExprTuple] @@ -536,6 +595,7 @@ fields = [ { name = "elts", type = "Expr*" }, { name = "ctx", type = "ExprContext" }, { name = "parenthesized", type = "bool" }, + { name = "runtime_elts", type = "Vec>?", skip_visit = true }, ] [Expr.nodes.ExprSlice] @@ -588,7 +648,10 @@ fields = [{ name = "value", type = "Singleton" }] [Pattern.nodes.PatternMatchSequence] doc = "See also [MatchSequence](https://docs.python.org/3/library/ast.html#ast.MatchSequence)" -fields = [{ name = "patterns", type = "Pattern*" }] +fields = [ + { name = "patterns", type = "Pattern*" }, + { name = "runtime_patterns", type = "Vec>?", skip_visit = true }, +] [Pattern.nodes.PatternMatchMapping] doc = "See also [MatchMapping](https://docs.python.org/3/library/ast.html#ast.MatchMapping)" @@ -596,6 +659,8 @@ fields = [ { name = "keys", type = "ThinVec" }, { name = "patterns", type = "ThinVec" }, { name = "rest", type = "Identifier?" }, + { name = "runtime_keys", type = "Vec>?", skip_visit = true }, + { name = "runtime_patterns", type = "Vec>?", skip_visit = true }, ] custom_source_order = true @@ -604,6 +669,9 @@ doc = "See also [MatchClass](https://docs.python.org/3/library/ast.html#ast.Matc fields = [ { name = "cls", type = "Box" }, { name = "arguments", type = "PatternArguments" }, + { name = "runtime_patterns", type = "Vec>?", skip_visit = true }, + { name = "runtime_kwd_attrs", type = "Vec?", skip_visit = true }, + { name = "runtime_kwd_patterns", type = "Vec>?", skip_visit = true }, ] [Pattern.nodes.PatternMatchStar] @@ -619,7 +687,10 @@ fields = [ [Pattern.nodes.PatternMatchOr] doc = "See also [MatchOr](https://docs.python.org/3/library/ast.html#ast.MatchOr)" -fields = [{ name = "patterns", type = "Pattern*" }] +fields = [ + { name = "patterns", type = "Pattern*" }, + { name = "runtime_patterns", type = "Vec>?", skip_visit = true }, +] [TypeParam] doc = "See also [type_param](https://docs.python.org/3/library/ast.html#ast.type_param)" diff --git a/crates/ruff_python_ast/generate.py b/crates/ruff_python_ast/generate.py index e290807f260079..d5baccf359204c 100755 --- a/crates/ruff_python_ast/generate.py +++ b/crates/ruff_python_ast/generate.py @@ -44,6 +44,7 @@ "Alias", "Singleton", "PatternArguments", + "ConstantValue", } @@ -275,10 +276,10 @@ def __init__(self, rule: str) -> None: rule = rule[:-1] self.sequence_kind, self.name = split_sequence_type(rule) - if self.optional and self.sequence_kind is not None: + if self.optional and self.sequence_kind is not None and "<" not in rule: raise ValueError(f"optional field cannot be sequence or slice: {self.rule}") if self.sequence_kind is not None and ( - not self.name or any(ch in self.name for ch in "?*&[]<>") + not self.name or any(ch in self.name for ch in "?*&[]") ): raise ValueError(f"Invalid collection element type: {rule}") diff --git a/crates/ruff_python_ast/src/comparable.rs b/crates/ruff_python_ast/src/comparable.rs index e52f914c69500a..a2adf692c55acd 100644 --- a/crates/ruff_python_ast/src/comparable.rs +++ b/crates/ruff_python_ast/src/comparable.rs @@ -16,7 +16,7 @@ //! have the same shape in that they evaluate to the same value. use crate as ast; -use crate::{Expr, Number}; +use crate::{ConstantValue, Expr, Number}; use std::borrow::Cow; use std::hash::Hash; @@ -365,6 +365,44 @@ impl<'a> From<&'a ast::Number> for ComparableNumber<'a> { } } +#[derive(Debug, PartialEq, Eq, Hash)] +pub enum ComparableConstantValue<'a> { + None, + Boolean(bool), + Str(&'a str), + Bytes(Cow<'a, [u8]>), + Integer(&'a str), + Tuple(Vec), + Frozenset(Vec), + Float(u64), + Complex { real: u64, imag: u64 }, + Ellipsis, +} + +impl<'a> From<&'a ConstantValue> for ComparableConstantValue<'a> { + fn from(value: &'a ConstantValue) -> Self { + match value { + ConstantValue::None => Self::None, + ConstantValue::Boolean(value) => Self::Boolean(*value), + ConstantValue::Str(value) => Self::Str(value), + ConstantValue::Bytes(value) => Self::Bytes(Cow::from(value.as_ref())), + ConstantValue::Integer(value) => Self::Integer(value), + ConstantValue::Tuple(elements) => { + Self::Tuple(elements.iter().map(Into::into).collect()) + } + ConstantValue::Frozenset(elements) => { + Self::Frozenset(elements.iter().map(Into::into).collect()) + } + ConstantValue::Float(value) => Self::Float(value.to_bits()), + ConstantValue::Complex { real, imag } => Self::Complex { + real: real.to_bits(), + imag: imag.to_bits(), + }, + ConstantValue::Ellipsis => Self::Ellipsis, + } + } +} + #[derive(Debug, Default, PartialEq, Eq, Hash)] pub struct ComparableArguments<'a> { args: Vec>, @@ -575,8 +613,7 @@ impl<'a> From<&'a ast::InterpolatedElement> for InterpolatedElement<'a> { debug_text, conversion, format_spec, - range: _, - node_index: _, + .. } = interpolated_element; Self { @@ -609,6 +646,7 @@ impl<'a> From<&'a ast::ElifElseClause> for ComparableElifElseClause<'a> { node_index: _, test, body, + .. } = elif_else_clause; Self { test: test.as_ref().map(Into::into), @@ -984,6 +1022,11 @@ pub struct ExprNumberLiteral<'a> { value: ComparableNumber<'a>, } +#[derive(Debug, PartialEq, Eq, Hash)] +pub struct ExprConstant<'a> { + value: ComparableConstantValue<'a>, +} + #[derive(Debug, PartialEq, Eq, Hash)] pub struct ExprBoolLiteral { value: bool, @@ -1060,6 +1103,7 @@ pub enum ComparableExpr<'a> { StringLiteral(ExprStringLiteral<'a>), BytesLiteral(ExprBytesLiteral<'a>), NumberLiteral(ExprNumberLiteral<'a>), + Constant(ExprConstant<'a>), BoolLiteral(ExprBoolLiteral), NoneLiteral, EllipsisLiteral, @@ -1088,92 +1132,54 @@ impl<'a> From<&'a Box> for ComparableExpr<'a> { impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> { fn from(expr: &'a ast::Expr) -> Self { match expr { - ast::Expr::BoolOp(ast::ExprBoolOp { - op, - values, - range: _, - node_index: _, - }) => Self::BoolOp(ExprBoolOp { + ast::Expr::BoolOp(ast::ExprBoolOp { op, values, .. }) => Self::BoolOp(ExprBoolOp { op: (*op).into(), values: values.iter().map(Into::into).collect(), }), - ast::Expr::Named(ast::ExprNamed { - target, - value, - range: _, - node_index: _, - }) => Self::NamedExpr(ExprNamed { + ast::Expr::Named(ast::ExprNamed { target, value, .. }) => Self::NamedExpr(ExprNamed { target: target.into(), value: value.into(), }), ast::Expr::BinOp(ast::ExprBinOp { - left, - op, - right, - range: _, - node_index: _, + left, op, right, .. }) => Self::BinOp(ExprBinOp { left: left.into(), op: (*op).into(), right: right.into(), }), - ast::Expr::UnaryOp(ast::ExprUnaryOp { - op, - operand, - range: _, - node_index: _, - }) => Self::UnaryOp(ExprUnaryOp { - op: (*op).into(), - operand: operand.into(), - }), + ast::Expr::UnaryOp(ast::ExprUnaryOp { op, operand, .. }) => { + Self::UnaryOp(ExprUnaryOp { + op: (*op).into(), + operand: operand.into(), + }) + } ast::Expr::Lambda(ast::ExprLambda { - parameters, - body, - range: _, - node_index: _, + parameters, body, .. }) => Self::Lambda(ExprLambda { parameters: parameters.as_ref().map(Into::into), body: body.into(), }), ast::Expr::If(ast::ExprIf { - test, - body, - orelse, - range: _, - node_index: _, + test, body, orelse, .. }) => Self::IfExp(ExprIf { test: test.into(), body: body.into(), orelse: orelse.into(), }), - ast::Expr::Dict(ast::ExprDict { - items, - range: _, - node_index: _, - }) => Self::Dict(ExprDict { + ast::Expr::Dict(ast::ExprDict { items, .. }) => Self::Dict(ExprDict { items: items.iter().map(ComparableDictItem::from).collect(), }), - ast::Expr::Set(ast::ExprSet { - elts, - range: _, - node_index: _, - }) => Self::Set(ExprSet { + ast::Expr::Set(ast::ExprSet { elts, .. }) => Self::Set(ExprSet { elts: elts.iter().map(Into::into).collect(), }), ast::Expr::ListComp(ast::ExprListComp { - elt, - generators, - range: _, - node_index: _, + elt, generators, .. }) => Self::ListComp(ExprListComp { elt: elt.into(), generators: generators.iter().map(Into::into).collect(), }), ast::Expr::SetComp(ast::ExprSetComp { - elt, - generators, - range: _, - node_index: _, + elt, generators, .. }) => Self::SetComp(ExprSetComp { elt: elt.into(), generators: generators.iter().map(Into::into).collect(), @@ -1182,171 +1188,110 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> { key, value, generators, - range: _, - node_index: _, + .. }) => Self::DictComp(ExprDictComp { key: key.as_ref().map(Into::into), value: value.into(), generators: generators.iter().map(Into::into).collect(), }), ast::Expr::Generator(ast::ExprGenerator { - elt, - generators, - range: _, - node_index: _, - parenthesized: _, + elt, generators, .. }) => Self::GeneratorExp(ExprGenerator { elt: elt.into(), generators: generators.iter().map(Into::into).collect(), }), - ast::Expr::Await(ast::ExprAwait { - value, - range: _, - node_index: _, - }) => Self::Await(ExprAwait { + ast::Expr::Await(ast::ExprAwait { value, .. }) => Self::Await(ExprAwait { value: value.into(), }), - ast::Expr::Yield(ast::ExprYield { - value, - range: _, - node_index: _, - }) => Self::Yield(ExprYield { + ast::Expr::Yield(ast::ExprYield { value, .. }) => Self::Yield(ExprYield { value: value.as_ref().map(Into::into), }), - ast::Expr::YieldFrom(ast::ExprYieldFrom { - value, - range: _, - node_index: _, - }) => Self::YieldFrom(ExprYieldFrom { - value: value.into(), - }), + ast::Expr::YieldFrom(ast::ExprYieldFrom { value, .. }) => { + Self::YieldFrom(ExprYieldFrom { + value: value.into(), + }) + } ast::Expr::Compare(ast::ExprCompare { ops, operands, range: _, node_index: _, + runtime_comparators: _, }) => Self::Compare(ExprCompare { ops: ops.iter().copied().map(Into::into).collect(), operands: operands.iter().map(Into::into).collect(), }), ast::Expr::Call(ast::ExprCall { - func, - arguments, - range_start: _, - node_index: _, + func, arguments, .. }) => Self::Call(ExprCall { func: func.into(), arguments: arguments.into(), }), - ast::Expr::FString(ast::ExprFString { - value, - range: _, - node_index: _, - }) => Self::FString(ExprFString { + ast::Expr::FString(ast::ExprFString { value, .. }) => Self::FString(ExprFString { value: value.into(), }), - ast::Expr::TString(ast::ExprTString { - value, - range: _, - node_index: _, - }) => Self::TString(ExprTString { + ast::Expr::TString(ast::ExprTString { value, .. }) => Self::TString(ExprTString { value: value.into(), }), - ast::Expr::StringLiteral(ast::ExprStringLiteral { - value, - range: _, - node_index: _, - }) => Self::StringLiteral(ExprStringLiteral { - value: ComparableStringLiteral { - value: value.to_str(), - }, - }), - ast::Expr::BytesLiteral(ast::ExprBytesLiteral { - value, - range: _, - node_index: _, - }) => Self::BytesLiteral(ExprBytesLiteral { - value: ComparableBytesLiteral { - value: Cow::from(value), - }, - }), - ast::Expr::NumberLiteral(ast::ExprNumberLiteral { - value, - range: _, - node_index: _, - }) => Self::NumberLiteral(ExprNumberLiteral { + ast::Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => { + Self::StringLiteral(ExprStringLiteral { + value: ComparableStringLiteral { + value: value.to_str(), + }, + }) + } + ast::Expr::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => { + Self::BytesLiteral(ExprBytesLiteral { + value: ComparableBytesLiteral { + value: Cow::from(value), + }, + }) + } + ast::Expr::NumberLiteral(ast::ExprNumberLiteral { value, .. }) => { + Self::NumberLiteral(ExprNumberLiteral { + value: value.into(), + }) + } + ast::Expr::Constant(ast::ExprConstant { value, .. }) => Self::Constant(ExprConstant { value: value.into(), }), - ast::Expr::BooleanLiteral(ast::ExprBooleanLiteral { - value, - range: _, - node_index: _, - }) => Self::BoolLiteral(ExprBoolLiteral { value: *value }), + ast::Expr::BooleanLiteral(ast::ExprBooleanLiteral { value, .. }) => { + Self::BoolLiteral(ExprBoolLiteral { value: *value }) + } ast::Expr::NoneLiteral(_) => Self::NoneLiteral, ast::Expr::EllipsisLiteral(_) => Self::EllipsisLiteral, - ast::Expr::Attribute(ast::ExprAttribute { - value, - attr, - ctx: _, - range: _, - node_index: _, - }) => Self::Attribute(ExprAttribute { - value: value.into(), - attr: attr.as_str(), - }), - ast::Expr::Subscript(ast::ExprSubscript { - value, - slice, - ctx: _, - range: _, - node_index: _, - }) => Self::Subscript(ExprSubscript { - value: value.into(), - slice: slice.into(), - }), - ast::Expr::Starred(ast::ExprStarred { - value, - ctx: _, - range: _, - node_index: _, - }) => Self::Starred(ExprStarred { + ast::Expr::Attribute(ast::ExprAttribute { value, attr, .. }) => { + Self::Attribute(ExprAttribute { + value: value.into(), + attr: attr.as_str(), + }) + } + ast::Expr::Subscript(ast::ExprSubscript { value, slice, .. }) => { + Self::Subscript(ExprSubscript { + value: value.into(), + slice: slice.into(), + }) + } + ast::Expr::Starred(ast::ExprStarred { value, .. }) => Self::Starred(ExprStarred { value: value.into(), }), ast::Expr::Name(name) => name.into(), - ast::Expr::List(ast::ExprList { - elts, - ctx: _, - range: _, - node_index: _, - }) => Self::List(ExprList { + ast::Expr::List(ast::ExprList { elts, .. }) => Self::List(ExprList { elts: elts.iter().map(Into::into).collect(), }), - ast::Expr::Tuple(ast::ExprTuple { - elts, - ctx: _, - range: _, - node_index: _, - parenthesized: _, - }) => Self::Tuple(ExprTuple { + ast::Expr::Tuple(ast::ExprTuple { elts, .. }) => Self::Tuple(ExprTuple { elts: elts.iter().map(Into::into).collect(), }), ast::Expr::Slice(ast::ExprSlice { - lower, - upper, - step, - range: _, - node_index: _, + lower, upper, step, .. }) => Self::Slice(ExprSlice { lower: lower.as_ref().map(Into::into), upper: upper.as_ref().map(Into::into), step: step.as_ref().map(Into::into), }), - ast::Expr::IpyEscapeCommand(ast::ExprIpyEscapeCommand { - kind, - value, - range: _, - node_index: _, - }) => Self::IpyEscapeCommand(ExprIpyEscapeCommand { kind: *kind, value }), + ast::Expr::IpyEscapeCommand(ast::ExprIpyEscapeCommand { kind, value, .. }) => { + Self::IpyEscapeCommand(ExprIpyEscapeCommand { kind: *kind, value }) + } } } } @@ -1429,31 +1374,24 @@ impl<'a> From<&'a ast::TypeParam> for ComparableTypeParam<'a> { name, bound, default, - range: _, - node_index: _, + .. }) => Self::TypeVar(TypeParamTypeVar { name: name.as_str(), bound: bound.as_ref().map(Into::into), default: default.as_ref().map(Into::into), }), - ast::TypeParam::TypeVarTuple(ast::TypeParamTypeVarTuple { - name, - default, - range: _, - node_index: _, - }) => Self::TypeVarTuple(TypeParamTypeVarTuple { - name: name.as_str(), - default: default.as_ref().map(Into::into), - }), - ast::TypeParam::ParamSpec(ast::TypeParamParamSpec { - name, - default, - range: _, - node_index: _, - }) => Self::ParamSpec(TypeParamParamSpec { - name: name.as_str(), - default: default.as_ref().map(Into::into), - }), + ast::TypeParam::TypeVarTuple(ast::TypeParamTypeVarTuple { name, default, .. }) => { + Self::TypeVarTuple(TypeParamTypeVarTuple { + name: name.as_str(), + default: default.as_ref().map(Into::into), + }) + } + ast::TypeParam::ParamSpec(ast::TypeParamParamSpec { name, default, .. }) => { + Self::ParamSpec(TypeParamParamSpec { + name: name.as_str(), + default: default.as_ref().map(Into::into), + }) + } } } } @@ -1630,8 +1568,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { decorator_list, returns, type_params, - range: _, - node_index: _, + .. }) => Self::FunctionDef(StmtFunctionDef { is_async: *is_async, name: name.as_str(), @@ -1647,8 +1584,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { body, decorator_list, type_params, - range: _, - node_index: _, + .. }) => Self::ClassDef(StmtClassDef { name: name.as_str(), arguments: arguments.as_ref().map(Into::into).unwrap_or_default(), @@ -1656,18 +1592,10 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { decorator_list: decorator_list.iter().map(Into::into).collect(), type_params: type_params.as_ref().map(Into::into), }), - ast::Stmt::Return(ast::StmtReturn { - value, - range: _, - node_index: _, - }) => Self::Return(StmtReturn { + ast::Stmt::Return(ast::StmtReturn { value, .. }) => Self::Return(StmtReturn { value: value.as_ref().map(Into::into), }), - ast::Stmt::Delete(ast::StmtDelete { - targets, - range: _, - node_index: _, - }) => Self::Delete(StmtDelete { + ast::Stmt::Delete(ast::StmtDelete { targets, .. }) => Self::Delete(StmtDelete { targets: targets.iter().map(Into::into).collect(), }), ast::Stmt::TypeAlias(ast::StmtTypeAlias { @@ -1681,21 +1609,12 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { type_params: type_params.as_ref().map(Into::into), value: value.into(), }), - ast::Stmt::Assign(ast::StmtAssign { - targets, - value, - range: _, - node_index: _, - }) => Self::Assign(StmtAssign { + ast::Stmt::Assign(ast::StmtAssign { targets, value, .. }) => Self::Assign(StmtAssign { targets: targets.iter().map(Into::into).collect(), value: value.into(), }), ast::Stmt::AugAssign(ast::StmtAugAssign { - target, - op, - value, - range: _, - node_index: _, + target, op, value, .. }) => Self::AugAssign(StmtAugAssign { target: target.into(), op: (*op).into(), @@ -1706,8 +1625,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { annotation, value, simple, - range: _, - node_index: _, + .. }) => Self::AnnAssign(StmtAnnAssign { target: target.into(), annotation: annotation.into(), @@ -1720,8 +1638,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { iter, body, orelse, - range: _, - node_index: _, + .. }) => Self::For(StmtFor { is_async: *is_async, target: target.into(), @@ -1730,11 +1647,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { orelse: orelse.iter().map(Into::into).collect(), }), ast::Stmt::While(ast::StmtWhile { - test, - body, - orelse, - range: _, - node_index: _, + test, body, orelse, .. }) => Self::While(StmtWhile { test: test.into(), body: body.iter().map(Into::into).collect(), @@ -1744,8 +1657,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { test, body, elif_else_clauses, - range: _, - node_index: _, + .. }) => Self::If(StmtIf { test: test.into(), body: body.iter().map(Into::into).collect(), @@ -1755,28 +1667,17 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { is_async, items, body, - range: _, - node_index: _, + .. }) => Self::With(StmtWith { is_async: *is_async, items: items.iter().map(Into::into).collect(), body: body.iter().map(Into::into).collect(), }), - ast::Stmt::Match(ast::StmtMatch { - subject, - cases, - range: _, - node_index: _, - }) => Self::Match(StmtMatch { + ast::Stmt::Match(ast::StmtMatch { subject, cases, .. }) => Self::Match(StmtMatch { subject: subject.into(), cases: cases.iter().map(Into::into).collect(), }), - ast::Stmt::Raise(ast::StmtRaise { - exc, - cause, - range: _, - node_index: _, - }) => Self::Raise(StmtRaise { + ast::Stmt::Raise(ast::StmtRaise { exc, cause, .. }) => Self::Raise(StmtRaise { exc: exc.as_ref().map(Into::into), cause: cause.as_ref().map(Into::into), }), @@ -1786,8 +1687,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { orelse, finalbody, is_star, - range: _, - node_index: _, + .. }) => Self::Try(StmtTry { body: body.iter().map(Into::into).collect(), handlers: handlers.iter().map(Into::into).collect(), @@ -1795,21 +1695,11 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { finalbody: finalbody.iter().map(Into::into).collect(), is_star: *is_star, }), - ast::Stmt::Assert(ast::StmtAssert { - test, - msg, - range: _, - node_index: _, - }) => Self::Assert(StmtAssert { + ast::Stmt::Assert(ast::StmtAssert { test, msg, .. }) => Self::Assert(StmtAssert { test: test.into(), msg: msg.as_ref().map(Into::into), }), - ast::Stmt::Import(ast::StmtImport { - names, - is_lazy, - range: _, - node_index: _, - }) => Self::Import(StmtImport { + ast::Stmt::Import(ast::StmtImport { names, is_lazy, .. }) => Self::Import(StmtImport { names: names.iter().map(Into::into).collect(), is_lazy: *is_lazy, }), @@ -1818,39 +1708,23 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { names, level, is_lazy, - range: _, - node_index: _, + .. }) => Self::ImportFrom(StmtImportFrom { module: module.as_deref(), names: names.iter().map(Into::into).collect(), level: *level, is_lazy: *is_lazy, }), - ast::Stmt::Global(ast::StmtGlobal { - names, - range: _, - node_index: _, - }) => Self::Global(StmtGlobal { + ast::Stmt::Global(ast::StmtGlobal { names, .. }) => Self::Global(StmtGlobal { names: names.iter().map(ast::Identifier::as_str).collect(), }), - ast::Stmt::Nonlocal(ast::StmtNonlocal { - names, - range: _, - node_index: _, - }) => Self::Nonlocal(StmtNonlocal { + ast::Stmt::Nonlocal(ast::StmtNonlocal { names, .. }) => Self::Nonlocal(StmtNonlocal { names: names.iter().map(ast::Identifier::as_str).collect(), }), - ast::Stmt::IpyEscapeCommand(ast::StmtIpyEscapeCommand { - kind, - value, - range: _, - node_index: _, - }) => Self::IpyEscapeCommand(StmtIpyEscapeCommand { kind: *kind, value }), - ast::Stmt::Expr(ast::StmtExpr { - value, - range: _, - node_index: _, - }) => Self::Expr(StmtExpr { + ast::Stmt::IpyEscapeCommand(ast::StmtIpyEscapeCommand { kind, value, .. }) => { + Self::IpyEscapeCommand(StmtIpyEscapeCommand { kind: *kind, value }) + } + ast::Stmt::Expr(ast::StmtExpr { value, .. }) => Self::Expr(StmtExpr { value: value.into(), }), ast::Stmt::Pass(_) => Self::Pass, @@ -2052,6 +1926,12 @@ impl<'a> From<&'a Expr> for HashableExpr<'a> { Expr::BooleanLiteral(boolean) => Some(HashableNumber::real(HashableReal::Integer( i128::from(u8::from(boolean.value)), ))), + Expr::Constant(ast::ExprConstant { + value: ConstantValue::Boolean(value), + .. + }) => Some(HashableNumber::real(HashableReal::Integer(i128::from( + u8::from(*value), + )))), Expr::NumberLiteral(number) => match &number.value { Number::Int(int) => HashableReal::from_int(int).map(HashableNumber::real), Number::Float(float) => { diff --git a/crates/ruff_python_ast/src/generated.rs b/crates/ruff_python_ast/src/generated.rs index ff3437b1b93ab2..99f1c09cb6b549 100644 --- a/crates/ruff_python_ast/src/generated.rs +++ b/crates/ruff_python_ast/src/generated.rs @@ -1321,6 +1321,7 @@ pub enum Expr { BooleanLiteral(crate::ExprBooleanLiteral), NoneLiteral(crate::ExprNoneLiteral), EllipsisLiteral(crate::ExprEllipsisLiteral), + Constant(crate::ExprConstant), Attribute(crate::ExprAttribute), Subscript(crate::ExprSubscript), Starred(crate::ExprStarred), @@ -1481,6 +1482,12 @@ impl From for Expr { } } +impl From for Expr { + fn from(node: crate::ExprConstant) -> Self { + Self::Constant(node) + } +} + impl From for Expr { fn from(node: crate::ExprAttribute) -> Self { Self::Attribute(node) @@ -1557,6 +1564,7 @@ impl ruff_text_size::Ranged for Expr { Self::BooleanLiteral(node) => node.range(), Self::NoneLiteral(node) => node.range(), Self::EllipsisLiteral(node) => node.range(), + Self::Constant(node) => node.range(), Self::Attribute(node) => node.range(), Self::Subscript(node) => node.range(), Self::Starred(node) => node.range(), @@ -1597,6 +1605,7 @@ impl crate::HasNodeIndex for Expr { Self::BooleanLiteral(node) => node.node_index(), Self::NoneLiteral(node) => node.node_index(), Self::EllipsisLiteral(node) => node.node_index(), + Self::Constant(node) => node.node_index(), Self::Attribute(node) => node.node_index(), Self::Subscript(node) => node.node_index(), Self::Starred(node) => node.node_index(), @@ -2536,6 +2545,43 @@ impl Expr { } } + #[inline] + pub const fn is_constant_expr(&self) -> bool { + matches!(self, Self::Constant(_)) + } + + #[inline] + pub fn constant_expr(self) -> Option { + match self { + Self::Constant(val) => Some(val), + _ => None, + } + } + + #[inline] + pub fn expect_constant_expr(self) -> crate::ExprConstant { + match self { + Self::Constant(val) => val, + _ => panic!("called expect on {self:?}"), + } + } + + #[inline] + pub fn as_constant_expr_mut(&mut self) -> Option<&mut crate::ExprConstant> { + match self { + Self::Constant(val) => Some(val), + _ => None, + } + } + + #[inline] + pub fn as_constant_expr(&self) -> Option<&crate::ExprConstant> { + match self { + Self::Constant(val) => Some(val), + _ => None, + } + } + #[inline] pub const fn is_attribute_expr(&self) -> bool { matches!(self, Self::Attribute(_)) @@ -3870,6 +3916,12 @@ impl ruff_text_size::Ranged for crate::ExprEllipsisLiteral { } } +impl ruff_text_size::Ranged for crate::ExprConstant { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + impl ruff_text_size::Ranged for crate::ExprAttribute { fn range(&self) -> ruff_text_size::TextRange { self.range @@ -4434,6 +4486,12 @@ impl crate::HasNodeIndex for crate::ExprEllipsisLiteral { } } +impl crate::HasNodeIndex for crate::ExprConstant { + fn node_index(&self) -> &crate::AtomicNodeIndex { + &self.node_index + } +} + impl crate::HasNodeIndex for crate::ExprAttribute { fn node_index(&self) -> &crate::AtomicNodeIndex { &self.node_index @@ -4767,6 +4825,7 @@ impl Expr { Expr::BooleanLiteral(node) => node.visit_source_order(visitor), Expr::NoneLiteral(node) => node.visit_source_order(visitor), Expr::EllipsisLiteral(node) => node.visit_source_order(visitor), + Expr::Constant(node) => node.visit_source_order(visitor), Expr::Attribute(node) => node.visit_source_order(visitor), Expr::Subscript(node) => node.visit_source_order(visitor), Expr::Starred(node) => node.visit_source_order(visitor), @@ -5240,6 +5299,8 @@ pub enum ExprRef<'a> { NoneLiteral(&'a crate::ExprNoneLiteral), #[is(name = "ellipsis_literal_expr")] EllipsisLiteral(&'a crate::ExprEllipsisLiteral), + #[is(name = "constant_expr")] + Constant(&'a crate::ExprConstant), #[is(name = "attribute_expr")] Attribute(&'a crate::ExprAttribute), #[is(name = "subscript_expr")] @@ -5286,6 +5347,7 @@ impl<'a> From<&'a Expr> for ExprRef<'a> { Expr::BooleanLiteral(node) => ExprRef::BooleanLiteral(node), Expr::NoneLiteral(node) => ExprRef::NoneLiteral(node), Expr::EllipsisLiteral(node) => ExprRef::EllipsisLiteral(node), + Expr::Constant(node) => ExprRef::Constant(node), Expr::Attribute(node) => ExprRef::Attribute(node), Expr::Subscript(node) => ExprRef::Subscript(node), Expr::Starred(node) => ExprRef::Starred(node), @@ -5448,6 +5510,12 @@ impl<'a> From<&'a crate::ExprEllipsisLiteral> for ExprRef<'a> { } } +impl<'a> From<&'a crate::ExprConstant> for ExprRef<'a> { + fn from(node: &'a crate::ExprConstant) -> Self { + Self::Constant(node) + } +} + impl<'a> From<&'a crate::ExprAttribute> for ExprRef<'a> { fn from(node: &'a crate::ExprAttribute) -> Self { Self::Attribute(node) @@ -5524,6 +5592,7 @@ impl ruff_text_size::Ranged for ExprRef<'_> { Self::BooleanLiteral(node) => node.range(), Self::NoneLiteral(node) => node.range(), Self::EllipsisLiteral(node) => node.range(), + Self::Constant(node) => node.range(), Self::Attribute(node) => node.range(), Self::Subscript(node) => node.range(), Self::Starred(node) => node.range(), @@ -5564,6 +5633,7 @@ impl crate::HasNodeIndex for ExprRef<'_> { Self::BooleanLiteral(node) => node.node_index(), Self::NoneLiteral(node) => node.node_index(), Self::EllipsisLiteral(node) => node.node_index(), + Self::Constant(node) => node.node_index(), Self::Attribute(node) => node.node_index(), Self::Subscript(node) => node.node_index(), Self::Starred(node) => node.node_index(), @@ -5881,6 +5951,7 @@ pub enum AnyNodeRef<'a> { ExprBooleanLiteral(&'a crate::ExprBooleanLiteral), ExprNoneLiteral(&'a crate::ExprNoneLiteral), ExprEllipsisLiteral(&'a crate::ExprEllipsisLiteral), + ExprConstant(&'a crate::ExprConstant), ExprAttribute(&'a crate::ExprAttribute), ExprSubscript(&'a crate::ExprSubscript), ExprStarred(&'a crate::ExprStarred), @@ -6080,6 +6151,7 @@ impl<'a> From<&'a Expr> for AnyNodeRef<'a> { Expr::BooleanLiteral(node) => AnyNodeRef::ExprBooleanLiteral(node), Expr::NoneLiteral(node) => AnyNodeRef::ExprNoneLiteral(node), Expr::EllipsisLiteral(node) => AnyNodeRef::ExprEllipsisLiteral(node), + Expr::Constant(node) => AnyNodeRef::ExprConstant(node), Expr::Attribute(node) => AnyNodeRef::ExprAttribute(node), Expr::Subscript(node) => AnyNodeRef::ExprSubscript(node), Expr::Starred(node) => AnyNodeRef::ExprStarred(node), @@ -6120,6 +6192,7 @@ impl<'a> From> for AnyNodeRef<'a> { ExprRef::BooleanLiteral(node) => AnyNodeRef::ExprBooleanLiteral(node), ExprRef::NoneLiteral(node) => AnyNodeRef::ExprNoneLiteral(node), ExprRef::EllipsisLiteral(node) => AnyNodeRef::ExprEllipsisLiteral(node), + ExprRef::Constant(node) => AnyNodeRef::ExprConstant(node), ExprRef::Attribute(node) => AnyNodeRef::ExprAttribute(node), ExprRef::Subscript(node) => AnyNodeRef::ExprSubscript(node), ExprRef::Starred(node) => AnyNodeRef::ExprStarred(node), @@ -6160,6 +6233,7 @@ impl<'a> AnyNodeRef<'a> { Self::ExprBooleanLiteral(node) => Some(ExprRef::BooleanLiteral(node)), Self::ExprNoneLiteral(node) => Some(ExprRef::NoneLiteral(node)), Self::ExprEllipsisLiteral(node) => Some(ExprRef::EllipsisLiteral(node)), + Self::ExprConstant(node) => Some(ExprRef::Constant(node)), Self::ExprAttribute(node) => Some(ExprRef::Attribute(node)), Self::ExprSubscript(node) => Some(ExprRef::Subscript(node)), Self::ExprStarred(node) => Some(ExprRef::Starred(node)), @@ -6630,6 +6704,12 @@ impl<'a> From<&'a crate::ExprEllipsisLiteral> for AnyNodeRef<'a> { } } +impl<'a> From<&'a crate::ExprConstant> for AnyNodeRef<'a> { + fn from(node: &'a crate::ExprConstant) -> AnyNodeRef<'a> { + AnyNodeRef::ExprConstant(node) + } +} + impl<'a> From<&'a crate::ExprAttribute> for AnyNodeRef<'a> { fn from(node: &'a crate::ExprAttribute) -> AnyNodeRef<'a> { AnyNodeRef::ExprAttribute(node) @@ -6937,6 +7017,7 @@ impl ruff_text_size::Ranged for AnyNodeRef<'_> { AnyNodeRef::ExprBooleanLiteral(node) => node.range(), AnyNodeRef::ExprNoneLiteral(node) => node.range(), AnyNodeRef::ExprEllipsisLiteral(node) => node.range(), + AnyNodeRef::ExprConstant(node) => node.range(), AnyNodeRef::ExprAttribute(node) => node.range(), AnyNodeRef::ExprSubscript(node) => node.range(), AnyNodeRef::ExprStarred(node) => node.range(), @@ -7038,6 +7119,7 @@ impl crate::HasNodeIndex for AnyNodeRef<'_> { AnyNodeRef::ExprBooleanLiteral(node) => node.node_index(), AnyNodeRef::ExprNoneLiteral(node) => node.node_index(), AnyNodeRef::ExprEllipsisLiteral(node) => node.node_index(), + AnyNodeRef::ExprConstant(node) => node.node_index(), AnyNodeRef::ExprAttribute(node) => node.node_index(), AnyNodeRef::ExprSubscript(node) => node.node_index(), AnyNodeRef::ExprStarred(node) => node.node_index(), @@ -7139,6 +7221,7 @@ impl AnyNodeRef<'_> { AnyNodeRef::ExprBooleanLiteral(node) => std::ptr::NonNull::from(*node).cast(), AnyNodeRef::ExprNoneLiteral(node) => std::ptr::NonNull::from(*node).cast(), AnyNodeRef::ExprEllipsisLiteral(node) => std::ptr::NonNull::from(*node).cast(), + AnyNodeRef::ExprConstant(node) => std::ptr::NonNull::from(*node).cast(), AnyNodeRef::ExprAttribute(node) => std::ptr::NonNull::from(*node).cast(), AnyNodeRef::ExprSubscript(node) => std::ptr::NonNull::from(*node).cast(), AnyNodeRef::ExprStarred(node) => std::ptr::NonNull::from(*node).cast(), @@ -7246,6 +7329,7 @@ impl<'a> AnyNodeRef<'a> { AnyNodeRef::ExprBooleanLiteral(node) => node.visit_source_order(visitor), AnyNodeRef::ExprNoneLiteral(node) => node.visit_source_order(visitor), AnyNodeRef::ExprEllipsisLiteral(node) => node.visit_source_order(visitor), + AnyNodeRef::ExprConstant(node) => node.visit_source_order(visitor), AnyNodeRef::ExprAttribute(node) => node.visit_source_order(visitor), AnyNodeRef::ExprSubscript(node) => node.visit_source_order(visitor), AnyNodeRef::ExprStarred(node) => node.visit_source_order(visitor), @@ -7363,6 +7447,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::ExprBooleanLiteral(_) | AnyNodeRef::ExprNoneLiteral(_) | AnyNodeRef::ExprEllipsisLiteral(_) + | AnyNodeRef::ExprConstant(_) | AnyNodeRef::ExprAttribute(_) | AnyNodeRef::ExprSubscript(_) | AnyNodeRef::ExprStarred(_) @@ -8135,6 +8220,16 @@ impl<'a> TryFrom> for &'a crate::ExprEllipsisLiteral { } } +impl<'a> TryFrom> for &'a crate::ExprConstant { + type Error = (); + fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprConstant, ()> { + match node { + AnyRootNodeRef::Expr(Expr::Constant(node)) => Ok(node), + _ => Err(()), + } + } +} + impl<'a> TryFrom> for &'a crate::ExprAttribute { type Error = (); fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a crate::ExprAttribute, ()> { @@ -9127,6 +9222,7 @@ pub enum NodeKind { ExprBooleanLiteral, ExprNoneLiteral, ExprEllipsisLiteral, + ExprConstant, ExprAttribute, ExprSubscript, ExprStarred, @@ -9226,6 +9322,7 @@ impl AnyNodeRef<'_> { AnyNodeRef::ExprBooleanLiteral(_) => NodeKind::ExprBooleanLiteral, AnyNodeRef::ExprNoneLiteral(_) => NodeKind::ExprNoneLiteral, AnyNodeRef::ExprEllipsisLiteral(_) => NodeKind::ExprEllipsisLiteral, + AnyNodeRef::ExprConstant(_) => NodeKind::ExprConstant, AnyNodeRef::ExprAttribute(_) => NodeKind::ExprAttribute, AnyNodeRef::ExprSubscript(_) => NodeKind::ExprSubscript, AnyNodeRef::ExprStarred(_) => NodeKind::ExprStarred, @@ -9281,6 +9378,7 @@ pub struct ModModule { pub node_index: crate::AtomicNodeIndex, pub range: ruff_text_size::TextRange, pub body: thin_vec::ThinVec, + pub runtime_body: Option>>, } /// See also [Module](https://docs.python.org/3/library/ast.html#ast.Module) @@ -9308,6 +9406,10 @@ pub struct StmtFunctionDef { pub parameters: Box, pub returns: Option>, pub body: thin_vec::ThinVec, + pub runtime_decorator_list: Option>>, + pub runtime_type_comment: Option>, + pub runtime_type_comment_bytes: Option>, + pub runtime_body: Option>>, } /// See also [ClassDef](https://docs.python.org/3/library/ast.html#ast.ClassDef) @@ -9321,6 +9423,8 @@ pub struct StmtClassDef { pub type_params: Option>, pub arguments: Option>, pub body: thin_vec::ThinVec, + pub runtime_decorator_list: Option>>, + pub runtime_body: Option>>, } /// See also [Return](https://docs.python.org/3/library/ast.html#ast.Return) @@ -9339,6 +9443,7 @@ pub struct StmtDelete { pub node_index: crate::AtomicNodeIndex, pub range: ruff_text_size::TextRange, pub targets: Vec, + pub runtime_targets: Option>>, } /// See also [TypeAlias](https://docs.python.org/3/library/ast.html#ast.TypeAlias) @@ -9360,6 +9465,9 @@ pub struct StmtAssign { pub range: ruff_text_size::TextRange, pub targets: Vec, pub value: Box, + pub runtime_targets: Option>>, + pub runtime_type_comment: Option>, + pub runtime_type_comment_bytes: Option>, } /// See also [AugAssign](https://docs.python.org/3/library/ast.html#ast.AugAssign) @@ -9383,6 +9491,7 @@ pub struct StmtAnnAssign { pub annotation: Box, pub value: Option>, pub simple: bool, + pub runtime_simple: Option, } /// See also [For](https://docs.python.org/3/library/ast.html#ast.For) @@ -9399,6 +9508,10 @@ pub struct StmtFor { pub iter: Box, pub body: thin_vec::ThinVec, pub orelse: thin_vec::ThinVec, + pub runtime_type_comment: Option>, + pub runtime_type_comment_bytes: Option>, + pub runtime_body: Option>>, + pub runtime_orelse: Option>>, } /// See also [While](https://docs.python.org/3/library/ast.html#ast.While) @@ -9411,6 +9524,8 @@ pub struct StmtWhile { pub test: Box, pub body: thin_vec::ThinVec, pub orelse: thin_vec::ThinVec, + pub runtime_body: Option>>, + pub runtime_orelse: Option>>, } /// See also [If](https://docs.python.org/3/library/ast.html#ast.If) @@ -9422,6 +9537,7 @@ pub struct StmtIf { pub test: Box, pub body: thin_vec::ThinVec, pub elif_else_clauses: Vec, + pub runtime_body: Option>>, } /// See also [With](https://docs.python.org/3/library/ast.html#ast.With) @@ -9436,6 +9552,9 @@ pub struct StmtWith { pub is_async: bool, pub items: Vec, pub body: thin_vec::ThinVec, + pub runtime_type_comment: Option>, + pub runtime_type_comment_bytes: Option>, + pub runtime_body: Option>>, } /// See also [Match](https://docs.python.org/3/library/ast.html#ast.Match) @@ -9470,6 +9589,10 @@ pub struct StmtTry { pub orelse: thin_vec::ThinVec, pub finalbody: thin_vec::ThinVec, pub is_star: bool, + pub runtime_body: Option>>, + pub runtime_handlers: Option>>, + pub runtime_orelse: Option>>, + pub runtime_finalbody: Option>>, } /// See also [Assert](https://docs.python.org/3/library/ast.html#ast.Assert) @@ -9502,6 +9625,7 @@ pub struct StmtImportFrom { pub names: Vec, pub level: u32, pub is_lazy: bool, + pub runtime_level: Option, } /// See also [Global](https://docs.python.org/3/library/ast.html#ast.Global) @@ -9626,6 +9750,7 @@ pub struct ExprBoolOp { pub range: ruff_text_size::TextRange, pub op: crate::BoolOp, pub values: Vec, + pub runtime_values: Option>>, } /// See also [NamedExpr](https://docs.python.org/3/library/ast.html#ast.NamedExpr) @@ -9687,6 +9812,7 @@ pub struct ExprDict { pub node_index: crate::AtomicNodeIndex, pub range: ruff_text_size::TextRange, pub items: Vec, + pub runtime_values: Option>>, } /// See also [Set](https://docs.python.org/3/library/ast.html#ast.Set) @@ -9696,6 +9822,7 @@ pub struct ExprSet { pub node_index: crate::AtomicNodeIndex, pub range: ruff_text_size::TextRange, pub elts: Vec, + pub runtime_elts: Option>>, } /// See also [ListComp](https://docs.python.org/3/library/ast.html#ast.ListComp) @@ -9781,6 +9908,7 @@ pub struct ExprCompare { pub range: ruff_text_size::TextRange, pub ops: Box<[crate::CmpOp]>, pub operands: Box<[Expr]>, + pub runtime_comparators: Option>>, } /// A call expression whose end offset is derived from its arguments. @@ -9812,6 +9940,8 @@ pub struct ExprFString { pub node_index: crate::AtomicNodeIndex, pub range: ruff_text_size::TextRange, pub value: crate::FStringValue, + pub runtime_joined_str: Option>, + pub runtime_values: Option>>, } /// An AST node that represents either a single-part t-string literal @@ -9828,6 +9958,8 @@ pub struct ExprTString { pub node_index: crate::AtomicNodeIndex, pub range: ruff_text_size::TextRange, pub value: crate::TStringValue, + pub runtime_template_str: Option>, + pub runtime_values: Option>>, } /// An AST node that represents either a single-part string literal @@ -9880,6 +10012,17 @@ pub struct ExprEllipsisLiteral { pub range: ruff_text_size::TextRange, } +/// See also [Constant](https://docs.python.org/3/library/ast.html#ast.Constant) +#[derive(Clone, Debug, PartialEq)] +#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))] +pub struct ExprConstant { + pub node_index: crate::AtomicNodeIndex, + pub range: ruff_text_size::TextRange, + pub value: crate::ConstantValue, + pub kind: Option>, + pub invalid_type: Option>, +} + /// See also [Attribute](https://docs.python.org/3/library/ast.html#ast.Attribute) #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "get-size", derive(get_size2::GetSize))] @@ -9930,6 +10073,7 @@ pub struct ExprList { pub range: ruff_text_size::TextRange, pub elts: Vec, pub ctx: crate::ExprContext, + pub runtime_elts: Option>>, } /// See also [Tuple](https://docs.python.org/3/library/ast.html#ast.Tuple) @@ -9941,6 +10085,7 @@ pub struct ExprTuple { pub elts: Vec, pub ctx: crate::ExprContext, pub parenthesized: bool, + pub runtime_elts: Option>>, } /// See also [Slice](https://docs.python.org/3/library/ast.html#ast.Slice) @@ -9999,6 +10144,7 @@ pub struct PatternMatchSequence { pub node_index: crate::AtomicNodeIndex, pub range: ruff_text_size::TextRange, pub patterns: Vec, + pub runtime_patterns: Option>>, } /// See also [MatchMapping](https://docs.python.org/3/library/ast.html#ast.MatchMapping) @@ -10010,6 +10156,8 @@ pub struct PatternMatchMapping { pub keys: thin_vec::ThinVec, pub patterns: thin_vec::ThinVec, pub rest: Option, + pub runtime_keys: Option>>, + pub runtime_patterns: Option>>, } /// See also [MatchClass](https://docs.python.org/3/library/ast.html#ast.MatchClass) @@ -10020,6 +10168,9 @@ pub struct PatternMatchClass { pub range: ruff_text_size::TextRange, pub cls: Box, pub arguments: crate::PatternArguments, + pub runtime_patterns: Option>>, + pub runtime_kwd_attrs: Option>, + pub runtime_kwd_patterns: Option>>, } /// See also [MatchStar](https://docs.python.org/3/library/ast.html#ast.MatchStar) @@ -10048,6 +10199,7 @@ pub struct PatternMatchOr { pub node_index: crate::AtomicNodeIndex, pub range: ruff_text_size::TextRange, pub patterns: Vec, + pub runtime_patterns: Option>>, } /// See also [TypeVar](https://docs.python.org/3/library/ast.html#ast.TypeVar) @@ -10088,6 +10240,7 @@ impl ModModule { { let ModModule { body, + runtime_body: _, range: _, node_index: _, } = self; @@ -10122,6 +10275,10 @@ impl StmtFunctionDef { parameters, returns, body, + runtime_decorator_list: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, range: _, node_index: _, } = self; @@ -10156,6 +10313,8 @@ impl StmtClassDef { type_params, arguments, body, + runtime_decorator_list: _, + runtime_body: _, range: _, node_index: _, } = self; @@ -10201,6 +10360,7 @@ impl StmtDelete { { let StmtDelete { targets, + runtime_targets: _, range: _, node_index: _, } = self; @@ -10241,6 +10401,9 @@ impl StmtAssign { let StmtAssign { targets, value, + runtime_targets: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, range: _, node_index: _, } = self; @@ -10280,6 +10443,7 @@ impl StmtAnnAssign { annotation, value, simple: _, + runtime_simple: _, range: _, node_index: _, } = self; @@ -10303,6 +10467,10 @@ impl StmtFor { iter, body, orelse, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, + runtime_orelse: _, range: _, node_index: _, } = self; @@ -10322,6 +10490,8 @@ impl StmtWhile { test, body, orelse, + runtime_body: _, + runtime_orelse: _, range: _, node_index: _, } = self; @@ -10340,6 +10510,7 @@ impl StmtIf { test, body, elif_else_clauses, + runtime_body: _, range: _, node_index: _, } = self; @@ -10361,6 +10532,9 @@ impl StmtWith { is_async: _, items, body, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, range: _, node_index: _, } = self; @@ -10424,6 +10598,10 @@ impl StmtTry { orelse, finalbody, is_star: _, + runtime_body: _, + runtime_handlers: _, + runtime_orelse: _, + runtime_finalbody: _, range: _, node_index: _, } = self; @@ -10484,6 +10662,7 @@ impl StmtImportFrom { names, level: _, is_lazy: _, + runtime_level: _, range: _, node_index: _, } = self; @@ -10691,6 +10870,7 @@ impl ExprSet { { let ExprSet { elts, + runtime_elts: _, range: _, node_index: _, } = self; @@ -10895,6 +11075,21 @@ impl ExprEllipsisLiteral { } } +impl ExprConstant { + pub(crate) fn visit_source_order<'a, V>(&'a self, _: &mut V) + where + V: SourceOrderVisitor<'a> + ?Sized, + { + let ExprConstant { + value: _, + kind: _, + invalid_type: _, + range: _, + node_index: _, + } = self; + } +} + impl ExprAttribute { pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) where @@ -10966,6 +11161,7 @@ impl ExprList { let ExprList { elts, ctx: _, + runtime_elts: _, range: _, node_index: _, } = self; @@ -10985,6 +11181,7 @@ impl ExprTuple { elts, ctx: _, parenthesized: _, + runtime_elts: _, range: _, node_index: _, } = self; @@ -11071,6 +11268,7 @@ impl PatternMatchSequence { { let PatternMatchSequence { patterns, + runtime_patterns: _, range: _, node_index: _, } = self; @@ -11089,6 +11287,9 @@ impl PatternMatchClass { let PatternMatchClass { cls, arguments, + runtime_patterns: _, + runtime_kwd_attrs: _, + runtime_kwd_patterns: _, range: _, node_index: _, } = self; @@ -11143,6 +11344,7 @@ impl PatternMatchOr { { let PatternMatchOr { patterns, + runtime_patterns: _, range: _, node_index: _, } = self; diff --git a/crates/ruff_python_ast/src/helpers.rs b/crates/ruff_python_ast/src/helpers.rs index 920c9cb8fdd3e9..f4517c714e7827 100644 --- a/crates/ruff_python_ast/src/helpers.rs +++ b/crates/ruff_python_ast/src/helpers.rs @@ -12,8 +12,8 @@ use crate::statement_visitor::StatementVisitor; use crate::token::{Tokens, parenthesized_range}; use crate::visitor::Visitor; use crate::{ - self as ast, Arguments, AtomicNodeIndex, CmpOp, DictItem, ExceptHandler, Expr, ExprNoneLiteral, - InterpolatedStringElement, MatchCase, Operator, Pattern, Stmt, TypeParam, + self as ast, Arguments, AtomicNodeIndex, CmpOp, ConstantValue, DictItem, ExceptHandler, Expr, + ExprNoneLiteral, InterpolatedStringElement, MatchCase, Operator, Pattern, Stmt, TypeParam, }; use crate::{AnyNodeRef, ExprContext}; @@ -142,6 +142,7 @@ impl SideEffect { | Expr::StringLiteral(_) | Expr::BytesLiteral(_) | Expr::NumberLiteral(_) + | Expr::Constant(_) | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) => Self::Absent, @@ -154,6 +155,7 @@ const fn is_known_safe_binop_operand(expr: &Expr) -> bool { Expr::StringLiteral(_) | Expr::BytesLiteral(_) | Expr::NumberLiteral(_) + | Expr::Constant(_) | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) @@ -192,6 +194,7 @@ fn is_definitely_side_effect_free_interpolation_expr(expr: &Expr) -> bool { matches!( expr, Expr::NumberLiteral(_) + | Expr::Constant(_) | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) @@ -303,21 +306,15 @@ where || any_over_expr(body, &mut *func) || any_over_expr(orelse, &mut *func) } - Expr::Dict(ast::ExprDict { - items, - range: _, - node_index: _, - }) => items.iter().any(|ast::DictItem { key, value }| { - any_over_expr(value, &mut *func) - || key - .as_ref() - .is_some_and(|key| any_over_expr(key, &mut *func)) - }), - Expr::Set(ast::ExprSet { - elts, - range: _, - node_index: _, - }) + Expr::Dict(ast::ExprDict { items, .. }) => { + items.iter().any(|ast::DictItem { key, value }| { + any_over_expr(value, &mut *func) + || key + .as_ref() + .is_some_and(|key| any_over_expr(key, &mut *func)) + }) + } + Expr::Set(ast::ExprSet { elts, .. }) | Expr::List(ast::ExprList { elts, .. }) | Expr::Tuple(ast::ExprTuple { elts, .. }) => { elts.iter().any(|expr| any_over_expr(expr, &mut *func)) @@ -434,6 +431,7 @@ where | Expr::StringLiteral(_) | Expr::BytesLiteral(_) | Expr::NumberLiteral(_) + | Expr::Constant(_) | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) @@ -471,11 +469,7 @@ fn any_over_pattern(pattern: &Pattern, func: &mut dyn FnMut(&Expr) -> bool) -> b node_index: _, }) => any_over_expr(value, func), Pattern::MatchSingleton(_) => false, - Pattern::MatchSequence(ast::PatternMatchSequence { - patterns, - range: _, - node_index: _, - }) => patterns + Pattern::MatchSequence(ast::PatternMatchSequence { patterns, .. }) => patterns .iter() .any(|pattern| any_over_pattern(pattern, &mut *func)), Pattern::MatchMapping(ast::PatternMatchMapping { keys, patterns, .. }) => { @@ -499,11 +493,7 @@ fn any_over_pattern(pattern: &Pattern, func: &mut dyn FnMut(&Expr) -> bool) -> b Pattern::MatchAs(ast::PatternMatchAs { pattern, .. }) => pattern .as_ref() .is_some_and(|pattern| any_over_pattern(pattern, func)), - Pattern::MatchOr(ast::PatternMatchOr { - patterns, - range: _, - node_index: _, - }) => patterns + Pattern::MatchOr(ast::PatternMatchOr { patterns, .. }) => patterns .iter() .any(|pattern| any_over_pattern(pattern, &mut *func)), } @@ -597,11 +587,9 @@ where }) => value .as_ref() .is_some_and(|value| any_over_expr(value, func)), - Stmt::Delete(ast::StmtDelete { - targets, - range: _, - node_index: _, - }) => targets.iter().any(|expr| any_over_expr(expr, &mut *func)), + Stmt::Delete(ast::StmtDelete { targets, .. }) => { + targets.iter().any(|expr| any_over_expr(expr, &mut *func)) + } Stmt::TypeAlias(ast::StmtTypeAlias { name, type_params, @@ -648,11 +636,7 @@ where || any_over_body(orelse, &mut *func) } Stmt::While(ast::StmtWhile { - test, - body, - orelse, - range: _, - node_index: _, + test, body, orelse, .. }) => { any_over_expr(test, &mut *func) || any_over_body(body, &mut *func) @@ -662,8 +646,7 @@ where test, body, elif_else_clauses, - range: _, - node_index: _, + .. }) => { any_over_expr(test, &mut *func) || any_over_body(body, &mut *func) @@ -701,9 +684,7 @@ where handlers, orelse, finalbody, - is_star: _, - range: _, - node_index: _, + .. }) => { any_over_body(body, &mut *func) || handlers.iter().any(|handler| { @@ -743,8 +724,7 @@ where pattern, guard, body, - range: _, - node_index: _, + .. } = case; any_over_pattern(pattern, &mut *func) || guard @@ -816,7 +796,13 @@ pub fn is_assignment_to_a_dunder(stmt: &Stmt) -> bool { const fn is_singleton(expr: &Expr) -> bool { matches!( expr, - Expr::NoneLiteral(_) | Expr::BooleanLiteral(_) | Expr::EllipsisLiteral(_) + Expr::NoneLiteral(_) + | Expr::BooleanLiteral(_) + | Expr::EllipsisLiteral(_) + | Expr::Constant(ast::ExprConstant { + value: ConstantValue::None | ConstantValue::Boolean(_) | ConstantValue::Ellipsis, + .. + }) ) } @@ -1559,6 +1545,7 @@ fn is_non_empty_f_string(expr: &ast::ExprFString) -> bool { Expr::SetComp(_) => true, Expr::DictComp(_) => true, Expr::NumberLiteral(_) => true, + Expr::Constant(_) => true, Expr::BooleanLiteral(_) => true, Expr::NoneLiteral(_) => true, Expr::EllipsisLiteral(_) => true, @@ -1718,6 +1705,7 @@ pub fn pep_604_union(elts: &[Expr]) -> Expr { range: TextRange::default(), node_index: AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }), [Expr::Tuple(ast::ExprTuple { elts, .. })] => pep_604_union(elts), [elt] => elt.clone(), @@ -1765,6 +1753,7 @@ pub fn typing_union(elts: &[Expr], binding: Name) -> Expr { elts: elts.to_vec(), ctx: ExprContext::Load, parenthesized: false, + runtime_elts: None, })), ctx: ExprContext::Load, range: TextRange::default(), @@ -1947,6 +1936,7 @@ mod tests { type_params: vec![type_var_one, type_var_two], range: TextRange::default(), node_index: AtomicNodeIndex::NONE, + runtime_type_params: None, })), value: Box::new(constant_three.clone()), range: TextRange::default(), diff --git a/crates/ruff_python_ast/src/node.rs b/crates/ruff_python_ast/src/node.rs index 1fa5f267a18d37..bddfee6119610f 100644 --- a/crates/ruff_python_ast/src/node.rs +++ b/crates/ruff_python_ast/src/node.rs @@ -15,6 +15,7 @@ impl ast::ElifElseClause { node_index: _, test, body, + .. } = self; if let Some(test) = test { visitor.visit_expr(test); @@ -28,11 +29,7 @@ impl ast::ExprDict { where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprDict { - items, - range: _, - node_index: _, - } = self; + let ast::ExprDict { items, .. } = self; for ast::DictItem { key, value } in items { if let Some(key) = key { @@ -48,12 +45,7 @@ impl ast::ExprBoolOp { where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprBoolOp { - op, - values, - range: _, - node_index: _, - } = self; + let ast::ExprBoolOp { op, values, .. } = self; match values.as_slice() { [left, rest @ ..] => { visitor.visit_expr(left); @@ -131,11 +123,7 @@ impl ast::ExprFString { where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprFString { - value, - range: _, - node_index: _, - } = self; + let ast::ExprFString { value, .. } = self; for f_string_part in value { match f_string_part { @@ -155,11 +143,7 @@ impl ast::ExprTString { where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprTString { - value, - range: _, - node_index: _, - } = self; + let ast::ExprTString { value, .. } = self; for t_string in value { visitor.visit_t_string(t_string); @@ -172,11 +156,7 @@ impl ast::ExprStringLiteral { where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprStringLiteral { - value, - range: _, - node_index: _, - } = self; + let ast::ExprStringLiteral { value, .. } = self; for string_literal in value { visitor.visit_string_literal(string_literal); @@ -189,11 +169,7 @@ impl ast::ExprBytesLiteral { where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprBytesLiteral { - value, - range: _, - node_index: _, - } = self; + let ast::ExprBytesLiteral { value, .. } = self; for bytes_literal in value { visitor.visit_bytes_literal(bytes_literal); @@ -212,6 +188,7 @@ impl ast::ExceptHandlerExceptHandler { type_, name, body, + .. } = self; if let Some(expr) = type_ { visitor.visit_expr(expr); @@ -234,8 +211,7 @@ impl ast::PatternMatchMapping { keys, patterns, rest, - range: _, - node_index: _, + .. } = self; let mut rest = rest.as_ref(); @@ -301,7 +277,7 @@ impl ast::Comprehension { target, iter, ifs, - is_async: _, + .. } = self; visitor.visit_expr(target); visitor.visit_expr(iter); @@ -352,6 +328,7 @@ impl ast::Parameter { node_index: _, name, annotation, + .. } = self; visitor.visit_identifier(name); @@ -448,6 +425,7 @@ impl ast::MatchCase { pattern, guard, body, + .. } = self; visitor.visit_pattern(pattern); @@ -482,6 +460,7 @@ impl ast::TypeParams { range: _, node_index: _, type_params, + .. } = self; for type_param in type_params { diff --git a/crates/ruff_python_ast/src/nodes.rs b/crates/ruff_python_ast/src/nodes.rs index 62d57ffe82adb8..aeaf3efeface1c 100644 --- a/crates/ruff_python_ast/src/nodes.rs +++ b/crates/ruff_python_ast/src/nodes.rs @@ -28,6 +28,21 @@ use crate::{ str::{Quote, TripleQuotes}, }; +#[derive(Clone, Debug, PartialEq)] +#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))] +pub enum ConstantValue { + None, + Boolean(bool), + Str(Box), + Bytes(Box<[u8]>), + Integer(Box), + Tuple(Vec), + Frozenset(Vec), + Float(f64), + Complex { real: f64, imag: f64 }, + Ellipsis, +} + impl StmtClassDef { /// Return an iterator over the bases of the class. pub fn bases(&self) -> &[Expr] { @@ -53,6 +68,8 @@ pub struct ElifElseClause { pub node_index: AtomicNodeIndex, pub test: Option, pub body: Suite, + pub runtime_body: Option>>, + pub runtime_orelse: Option>>, } impl Expr { @@ -66,6 +83,7 @@ impl Expr { Expr::StringLiteral(_) | Expr::BytesLiteral(_) | Expr::NumberLiteral(_) + | Expr::Constant(_) | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) @@ -410,6 +428,9 @@ pub struct InterpolatedElement { pub debug_text: Option, pub conversion: ConversionFlag, pub format_spec: Option>, + pub runtime_str: Option, + pub runtime_interpolation_format_spec: Option>, + pub runtime_formatted_value_format_spec: Option>, } /// An `FStringLiteralElement` with an empty `value` is an invalid f-string element. @@ -1394,6 +1415,8 @@ impl From for Expr { node_index: payload.node_index.clone(), range: payload.range, value: FStringValue::single(payload), + runtime_joined_str: None, + runtime_values: None, } .into() } @@ -1486,6 +1509,8 @@ impl From for Expr { node_index: payload.node_index.clone(), range: payload.range, value: TStringValue::single(payload), + runtime_template_str: None, + runtime_values: None, } .into() } @@ -2988,6 +3013,8 @@ pub struct Comprehension { pub iter: Expr, pub ifs: Vec, pub is_async: bool, + pub runtime_ifs: Option>>, + pub runtime_is_async: Option, } /// See also [ExceptHandler](https://docs.python.org/3/library/ast.html#ast.ExceptHandler) @@ -2999,6 +3026,7 @@ pub struct ExceptHandlerExceptHandler { pub type_: Option>, pub name: Option, pub body: Suite, + pub runtime_body: Option>>, } /// See also [arg](https://docs.python.org/3/library/ast.html#ast.arg) @@ -3009,6 +3037,8 @@ pub struct Parameter { pub node_index: AtomicNodeIndex, pub name: Identifier, pub annotation: Option>, + pub runtime_type_comment: Option>, + pub runtime_type_comment_bytes: Option>, } impl Parameter { @@ -3060,6 +3090,7 @@ pub struct MatchCase { pub pattern: Pattern, pub guard: Option>, pub body: Suite, + pub runtime_body: Option>>, } impl Pattern { @@ -3318,6 +3349,7 @@ pub struct Parameters { pub vararg: Option>, pub kwonlyargs: ThinVec, pub kwarg: Option>, + pub runtime_defaults: Option>>, } impl Parameters { @@ -3359,6 +3391,7 @@ impl Parameters { vararg, kwonlyargs, kwarg, + .. } = self; // Safety: a Python function can have an arbitrary number of parameters, // so theoretically this could be a number that wouldn't fit into a usize, @@ -3429,6 +3462,7 @@ impl<'a> ParametersIterator<'a> { vararg, kwonlyargs, kwarg, + .. } = parameters; Self { posonlyargs: posonlyargs.iter(), @@ -3677,6 +3711,8 @@ pub struct Arguments { pub node_index: AtomicNodeIndex, pub args: ThinVec, pub keywords: ThinVec, + pub runtime_args: Option>>, + pub runtime_bases: Option>>, } /// An entry in the argument list of a function call. @@ -3883,6 +3919,7 @@ pub struct TypeParams { pub range: TextRange, pub node_index: AtomicNodeIndex, pub type_params: Vec, + pub runtime_type_params: Option>>, } impl Deref for TypeParams { @@ -4177,45 +4214,45 @@ mod tests { #[test] #[cfg(target_pointer_width = "64")] fn size() { - assert_eq!(std::mem::size_of::(), 88); - assert_eq!(std::mem::size_of::(), 88); - assert_eq!(std::mem::size_of::(), 80); - assert_eq!(std::mem::size_of::(), 64); - assert_eq!(std::mem::size_of::(), 32); - assert_eq!(std::mem::size_of::(), 72); - assert_eq!(std::mem::size_of::(), 56); - assert_eq!(std::mem::size_of::(), 32); - assert_eq!(std::mem::size_of::(), 56); + assert_eq!(std::mem::size_of::(), 176); + assert_eq!(std::mem::size_of::(), 176); + assert_eq!(std::mem::size_of::(), 128); + assert_eq!(std::mem::size_of::(), 160); + assert_eq!(std::mem::size_of::(), 48); + assert_eq!(std::mem::size_of::(), 144); + assert_eq!(std::mem::size_of::(), 80); + assert_eq!(std::mem::size_of::(), 80); + assert_eq!(std::mem::size_of::(), 104); assert_eq!(std::mem::size_of::(), 56); assert_eq!(std::mem::size_of::(), 24); assert_eq!(std::mem::size_of::(), 32); - assert_eq!(std::mem::size_of::(), 40); + assert_eq!(std::mem::size_of::(), 64); assert_eq!(std::mem::size_of::(), 16); assert_eq!(std::mem::size_of::(), 48); - assert_eq!(std::mem::size_of::(), 48); - assert_eq!(std::mem::size_of::(), 48); - assert_eq!(std::mem::size_of::(), 40); + assert_eq!(std::mem::size_of::(), 96); + assert_eq!(std::mem::size_of::(), 72); + assert_eq!(std::mem::size_of::(), 64); assert_eq!(std::mem::size_of::(), 48); assert_eq!(std::mem::size_of::(), 12); - assert_eq!(std::mem::size_of::(), 48); + assert_eq!(std::mem::size_of::(), 96); assert_eq!(std::mem::size_of::(), 48); assert_eq!(std::mem::size_of::(), 40); assert_eq!(std::mem::size_of::(), 32); assert_eq!(std::mem::size_of::(), 32); - assert_eq!(std::mem::size_of::(), 40); + assert_eq!(std::mem::size_of::(), 64); assert_eq!(std::mem::size_of::(), 48); assert_eq!(std::mem::size_of::(), 32); assert_eq!(std::mem::size_of::(), 32); assert_eq!(std::mem::size_of::(), 12); assert_eq!(std::mem::size_of::(), 40); - assert_eq!(std::mem::size_of::(), 40); + assert_eq!(std::mem::size_of::(), 64); assert_eq!(std::mem::size_of::(), 48); assert_eq!(std::mem::size_of::(), 40); assert_eq!(std::mem::size_of::(), 24); assert_eq!(std::mem::size_of::(), 48); assert_eq!(std::mem::size_of::(), 32); - assert_eq!(std::mem::size_of::(), 48); - assert_eq!(std::mem::size_of::(), 40); + assert_eq!(std::mem::size_of::(), 96); + assert_eq!(std::mem::size_of::(), 64); assert_eq!(std::mem::size_of::(), 24); assert_eq!(std::mem::size_of::(), 24); assert_eq!(std::mem::size_of::(), 24); diff --git a/crates/ruff_python_ast/src/operator_precedence.rs b/crates/ruff_python_ast/src/operator_precedence.rs index c509ec0fc34e6b..ab945f182b6567 100644 --- a/crates/ruff_python_ast/src/operator_precedence.rs +++ b/crates/ruff_python_ast/src/operator_precedence.rs @@ -69,6 +69,7 @@ impl OperatorPrecedence { | ExprRef::StringLiteral(_) | ExprRef::BytesLiteral(_) | ExprRef::NumberLiteral(_) + | ExprRef::Constant(_) | ExprRef::BooleanLiteral(_) | ExprRef::NoneLiteral(_) | ExprRef::EllipsisLiteral(_) diff --git a/crates/ruff_python_ast/src/relocate.rs b/crates/ruff_python_ast/src/relocate.rs index 64fd01bed9d5c9..75bfc04c235009 100644 --- a/crates/ruff_python_ast/src/relocate.rs +++ b/crates/ruff_python_ast/src/relocate.rs @@ -89,6 +89,9 @@ impl Transformer for Relocator { Expr::NumberLiteral(ast::ExprNumberLiteral { range, .. }) => { *range = self.range; } + Expr::Constant(ast::ExprConstant { range, .. }) => { + *range = self.range; + } Expr::BooleanLiteral(ast::ExprBooleanLiteral { range, .. }) => { *range = self.range; } diff --git a/crates/ruff_python_ast/src/visitor.rs b/crates/ruff_python_ast/src/visitor.rs index fc396e243ba68c..94847655206efa 100644 --- a/crates/ruff_python_ast/src/visitor.rs +++ b/crates/ruff_python_ast/src/visitor.rs @@ -172,20 +172,12 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { } visitor.visit_body(body); } - Stmt::Return(ast::StmtReturn { - value, - range: _, - node_index: _, - }) => { + Stmt::Return(ast::StmtReturn { value, .. }) => { if let Some(expr) = value { visitor.visit_expr(expr); } } - Stmt::Delete(ast::StmtDelete { - targets, - range: _, - node_index: _, - }) => { + Stmt::Delete(ast::StmtDelete { targets, .. }) => { for expr in targets { visitor.visit_expr(expr); } @@ -210,11 +202,7 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { } } Stmt::AugAssign(ast::StmtAugAssign { - target, - op, - value, - range: _, - node_index: _, + target, op, value, .. }) => { visitor.visit_expr(value); visitor.visit_operator(op); @@ -245,11 +233,7 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { visitor.visit_body(orelse); } Stmt::While(ast::StmtWhile { - test, - body, - orelse, - range: _, - node_index: _, + test, body, orelse, .. }) => { visitor.visit_expr(test); visitor.visit_body(body); @@ -259,8 +243,7 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { test, body, elif_else_clauses, - range: _, - node_index: _, + .. }) => { visitor.visit_expr(test); visitor.visit_body(body); @@ -274,23 +257,13 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { } visitor.visit_body(body); } - Stmt::Match(ast::StmtMatch { - subject, - cases, - range: _, - node_index: _, - }) => { + Stmt::Match(ast::StmtMatch { subject, cases, .. }) => { visitor.visit_expr(subject); for match_case in cases { visitor.visit_match_case(match_case); } } - Stmt::Raise(ast::StmtRaise { - exc, - cause, - range: _, - node_index: _, - }) => { + Stmt::Raise(ast::StmtRaise { exc, cause, .. }) => { if let Some(expr) = exc { visitor.visit_expr(expr); } @@ -303,9 +276,7 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { handlers, orelse, finalbody, - is_star: _, - range: _, - node_index: _, + .. }) => { visitor.visit_body(body); for except_handler in handlers { @@ -314,23 +285,13 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { visitor.visit_body(orelse); visitor.visit_body(finalbody); } - Stmt::Assert(ast::StmtAssert { - test, - msg, - range: _, - node_index: _, - }) => { + Stmt::Assert(ast::StmtAssert { test, msg, .. }) => { visitor.visit_expr(test); if let Some(expr) = msg { visitor.visit_expr(expr); } } - Stmt::Import(ast::StmtImport { - names, - is_lazy: _, - range: _, - node_index: _, - }) => { + Stmt::Import(ast::StmtImport { names, .. }) => { for alias in names { visitor.visit_alias(alias); } @@ -342,11 +303,7 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { } Stmt::Global(_) => {} Stmt::Nonlocal(_) => {} - Stmt::Expr(ast::StmtExpr { - value, - range: _, - node_index: _, - }) => visitor.visit_expr(value), + Stmt::Expr(ast::StmtExpr { value, .. }) => visitor.visit_expr(value), Stmt::Pass(_) | Stmt::Break(_) | Stmt::Continue(_) | Stmt::IpyEscapeCommand(_) => {} } } @@ -361,51 +318,29 @@ pub fn walk_decorator<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, decorator: & pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { match expr { - Expr::BoolOp(ast::ExprBoolOp { - op, - values, - range: _, - node_index: _, - }) => { + Expr::BoolOp(ast::ExprBoolOp { op, values, .. }) => { visitor.visit_bool_op(op); for expr in values { visitor.visit_expr(expr); } } - Expr::Named(ast::ExprNamed { - target, - value, - range: _, - node_index: _, - }) => { + Expr::Named(ast::ExprNamed { target, value, .. }) => { visitor.visit_expr(value); visitor.visit_expr(target); } Expr::BinOp(ast::ExprBinOp { - left, - op, - right, - range: _, - node_index: _, + left, op, right, .. }) => { visitor.visit_expr(left); visitor.visit_operator(op); visitor.visit_expr(right); } - Expr::UnaryOp(ast::ExprUnaryOp { - op, - operand, - range: _, - node_index: _, - }) => { + Expr::UnaryOp(ast::ExprUnaryOp { op, operand, .. }) => { visitor.visit_unary_op(op); visitor.visit_expr(operand); } Expr::Lambda(ast::ExprLambda { - parameters, - body, - range: _, - node_index: _, + parameters, body, .. }) => { if let Some(parameters) = parameters { visitor.visit_parameters(parameters); @@ -413,21 +348,13 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { visitor.visit_expr(body); } Expr::If(ast::ExprIf { - test, - body, - orelse, - range: _, - node_index: _, + test, body, orelse, .. }) => { visitor.visit_expr(test); visitor.visit_expr(body); visitor.visit_expr(orelse); } - Expr::Dict(ast::ExprDict { - items, - range: _, - node_index: _, - }) => { + Expr::Dict(ast::ExprDict { items, .. }) => { for ast::DictItem { key, value } in items { if let Some(key) = key { visitor.visit_expr(key); @@ -435,20 +362,13 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { visitor.visit_expr(value); } } - Expr::Set(ast::ExprSet { - elts, - range: _, - node_index: _, - }) => { + Expr::Set(ast::ExprSet { elts, .. }) => { for expr in elts { visitor.visit_expr(expr); } } Expr::ListComp(ast::ExprListComp { - elt, - generators, - range: _, - node_index: _, + elt, generators, .. }) => { for comprehension in generators { visitor.visit_comprehension(comprehension); @@ -456,10 +376,7 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { visitor.visit_expr(elt); } Expr::SetComp(ast::ExprSetComp { - elt, - generators, - range: _, - node_index: _, + elt, generators, .. }) => { for comprehension in generators { visitor.visit_comprehension(comprehension); @@ -470,8 +387,7 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { key, value, generators, - range: _, - node_index: _, + .. }) => { for comprehension in generators { visitor.visit_comprehension(comprehension); @@ -482,27 +398,15 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { visitor.visit_expr(value); } Expr::Generator(ast::ExprGenerator { - elt, - generators, - range: _, - node_index: _, - parenthesized: _, + elt, generators, .. }) => { for comprehension in generators { visitor.visit_comprehension(comprehension); } visitor.visit_expr(elt); } - Expr::Await(ast::ExprAwait { - value, - range: _, - node_index: _, - }) => visitor.visit_expr(value), - Expr::Yield(ast::ExprYield { - value, - range: _, - node_index: _, - }) => { + Expr::Await(ast::ExprAwait { value, .. }) => visitor.visit_expr(value), + Expr::Yield(ast::ExprYield { value, .. }) => { if let Some(expr) = value { visitor.visit_expr(expr); } @@ -522,10 +426,7 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { } } Expr::Call(ast::ExprCall { - func, - arguments, - range_start: _, - node_index: _, + func, arguments, .. }) => { visitor.visit_expr(func); visitor.visit_arguments(arguments); @@ -556,6 +457,7 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { } } Expr::NumberLiteral(_) + | Expr::Constant(_) | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) => {} @@ -564,57 +466,33 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { visitor.visit_expr_context(ctx); } Expr::Subscript(ast::ExprSubscript { - value, - slice, - ctx, - range: _, - node_index: _, + value, slice, ctx, .. }) => { visitor.visit_expr(value); visitor.visit_expr(slice); visitor.visit_expr_context(ctx); } - Expr::Starred(ast::ExprStarred { - value, - ctx, - range: _, - node_index: _, - }) => { + Expr::Starred(ast::ExprStarred { value, ctx, .. }) => { visitor.visit_expr(value); visitor.visit_expr_context(ctx); } Expr::Name(ast::ExprName { ctx, .. }) => { visitor.visit_expr_context(ctx); } - Expr::List(ast::ExprList { - elts, - ctx, - range: _, - node_index: _, - }) => { + Expr::List(ast::ExprList { elts, ctx, .. }) => { for expr in elts { visitor.visit_expr(expr); } visitor.visit_expr_context(ctx); } - Expr::Tuple(ast::ExprTuple { - elts, - ctx, - range: _, - node_index: _, - parenthesized: _, - }) => { + Expr::Tuple(ast::ExprTuple { elts, ctx, .. }) => { for expr in elts { visitor.visit_expr(expr); } visitor.visit_expr_context(ctx); } Expr::Slice(ast::ExprSlice { - lower, - upper, - step, - range: _, - node_index: _, + lower, upper, step, .. }) => { if let Some(expr) = lower { visitor.visit_expr(expr); @@ -706,13 +584,7 @@ pub fn walk_type_params<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, type_param pub fn walk_type_param<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, type_param: &'a TypeParam) { match type_param { - TypeParam::TypeVar(TypeParamTypeVar { - bound, - default, - name: _, - range: _, - node_index: _, - }) => { + TypeParam::TypeVar(TypeParamTypeVar { bound, default, .. }) => { if let Some(expr) = bound { visitor.visit_expr(expr); } @@ -720,22 +592,12 @@ pub fn walk_type_param<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, type_param: visitor.visit_expr(expr); } } - TypeParam::TypeVarTuple(TypeParamTypeVarTuple { - default, - name: _, - range: _, - node_index: _, - }) => { + TypeParam::TypeVarTuple(TypeParamTypeVarTuple { default, .. }) => { if let Some(expr) = default { visitor.visit_expr(expr); } } - TypeParam::ParamSpec(TypeParamParamSpec { - default, - name: _, - range: _, - node_index: _, - }) => { + TypeParam::ParamSpec(TypeParamParamSpec { default, .. }) => { if let Some(expr) = default { visitor.visit_expr(expr); } diff --git a/crates/ruff_python_ast/src/visitor/source_order.rs b/crates/ruff_python_ast/src/visitor/source_order.rs index 9c74f53146804e..97934844d6a628 100644 --- a/crates/ruff_python_ast/src/visitor/source_order.rs +++ b/crates/ruff_python_ast/src/visitor/source_order.rs @@ -290,6 +290,7 @@ where Expr::StringLiteral(expr) => expr.visit_source_order(visitor), Expr::BytesLiteral(expr) => expr.visit_source_order(visitor), Expr::NumberLiteral(expr) => expr.visit_source_order(visitor), + Expr::Constant(expr) => expr.visit_source_order(visitor), Expr::BooleanLiteral(expr) => expr.visit_source_order(visitor), Expr::NoneLiteral(expr) => expr.visit_source_order(visitor), Expr::EllipsisLiteral(expr) => expr.visit_source_order(visitor), diff --git a/crates/ruff_python_ast/src/visitor/transformer.rs b/crates/ruff_python_ast/src/visitor/transformer.rs index cc21d472020eaa..e795de538454ca 100644 --- a/crates/ruff_python_ast/src/visitor/transformer.rs +++ b/crates/ruff_python_ast/src/visitor/transformer.rs @@ -159,20 +159,12 @@ pub fn walk_stmt(visitor: &V, stmt: &mut Stmt) { } visitor.visit_body(body); } - Stmt::Return(ast::StmtReturn { - value, - range: _, - node_index: _, - }) => { + Stmt::Return(ast::StmtReturn { value, .. }) => { if let Some(expr) = value { visitor.visit_expr(expr); } } - Stmt::Delete(ast::StmtDelete { - targets, - range: _, - node_index: _, - }) => { + Stmt::Delete(ast::StmtDelete { targets, .. }) => { for expr in targets { visitor.visit_expr(expr); } @@ -197,11 +189,7 @@ pub fn walk_stmt(visitor: &V, stmt: &mut Stmt) { } } Stmt::AugAssign(ast::StmtAugAssign { - target, - op, - value, - range: _, - node_index: _, + target, op, value, .. }) => { visitor.visit_expr(value); visitor.visit_operator(op); @@ -232,11 +220,7 @@ pub fn walk_stmt(visitor: &V, stmt: &mut Stmt) { visitor.visit_body(orelse); } Stmt::While(ast::StmtWhile { - test, - body, - orelse, - range: _, - node_index: _, + test, body, orelse, .. }) => { visitor.visit_expr(test); visitor.visit_body(body); @@ -246,8 +230,7 @@ pub fn walk_stmt(visitor: &V, stmt: &mut Stmt) { test, body, elif_else_clauses, - range: _, - node_index: _, + .. }) => { visitor.visit_expr(test); visitor.visit_body(body); @@ -261,23 +244,13 @@ pub fn walk_stmt(visitor: &V, stmt: &mut Stmt) { } visitor.visit_body(body); } - Stmt::Match(ast::StmtMatch { - subject, - cases, - range: _, - node_index: _, - }) => { + Stmt::Match(ast::StmtMatch { subject, cases, .. }) => { visitor.visit_expr(subject); for match_case in cases { visitor.visit_match_case(match_case); } } - Stmt::Raise(ast::StmtRaise { - exc, - cause, - range: _, - node_index: _, - }) => { + Stmt::Raise(ast::StmtRaise { exc, cause, .. }) => { if let Some(expr) = exc { visitor.visit_expr(expr); } @@ -290,9 +263,7 @@ pub fn walk_stmt(visitor: &V, stmt: &mut Stmt) { handlers, orelse, finalbody, - is_star: _, - range: _, - node_index: _, + .. }) => { visitor.visit_body(body); for except_handler in handlers { @@ -301,23 +272,13 @@ pub fn walk_stmt(visitor: &V, stmt: &mut Stmt) { visitor.visit_body(orelse); visitor.visit_body(finalbody); } - Stmt::Assert(ast::StmtAssert { - test, - msg, - range: _, - node_index: _, - }) => { + Stmt::Assert(ast::StmtAssert { test, msg, .. }) => { visitor.visit_expr(test); if let Some(expr) = msg { visitor.visit_expr(expr); } } - Stmt::Import(ast::StmtImport { - names, - is_lazy: _, - range: _, - node_index: _, - }) => { + Stmt::Import(ast::StmtImport { names, .. }) => { for alias in names { visitor.visit_alias(alias); } @@ -329,11 +290,7 @@ pub fn walk_stmt(visitor: &V, stmt: &mut Stmt) { } Stmt::Global(_) => {} Stmt::Nonlocal(_) => {} - Stmt::Expr(ast::StmtExpr { - value, - range: _, - node_index: _, - }) => visitor.visit_expr(value), + Stmt::Expr(ast::StmtExpr { value, .. }) => visitor.visit_expr(value), Stmt::Pass(_) | Stmt::Break(_) | Stmt::Continue(_) | Stmt::IpyEscapeCommand(_) => {} } } @@ -348,51 +305,29 @@ pub fn walk_decorator(visitor: &V, decorator: &mut Deco pub fn walk_expr(visitor: &V, expr: &mut Expr) { match expr { - Expr::BoolOp(ast::ExprBoolOp { - op, - values, - range: _, - node_index: _, - }) => { + Expr::BoolOp(ast::ExprBoolOp { op, values, .. }) => { visitor.visit_bool_op(op); for expr in values { visitor.visit_expr(expr); } } - Expr::Named(ast::ExprNamed { - target, - value, - range: _, - node_index: _, - }) => { + Expr::Named(ast::ExprNamed { target, value, .. }) => { visitor.visit_expr(value); visitor.visit_expr(target); } Expr::BinOp(ast::ExprBinOp { - left, - op, - right, - range: _, - node_index: _, + left, op, right, .. }) => { visitor.visit_expr(left); visitor.visit_operator(op); visitor.visit_expr(right); } - Expr::UnaryOp(ast::ExprUnaryOp { - op, - operand, - range: _, - node_index: _, - }) => { + Expr::UnaryOp(ast::ExprUnaryOp { op, operand, .. }) => { visitor.visit_unary_op(op); visitor.visit_expr(operand); } Expr::Lambda(ast::ExprLambda { - parameters, - body, - range: _, - node_index: _, + parameters, body, .. }) => { if let Some(parameters) = parameters { visitor.visit_parameters(parameters); @@ -400,21 +335,13 @@ pub fn walk_expr(visitor: &V, expr: &mut Expr) { visitor.visit_expr(body); } Expr::If(ast::ExprIf { - test, - body, - orelse, - range: _, - node_index: _, + test, body, orelse, .. }) => { visitor.visit_expr(test); visitor.visit_expr(body); visitor.visit_expr(orelse); } - Expr::Dict(ast::ExprDict { - items, - range: _, - node_index: _, - }) => { + Expr::Dict(ast::ExprDict { items, .. }) => { for ast::DictItem { key, value } in items { if let Some(key) = key { visitor.visit_expr(key); @@ -422,20 +349,13 @@ pub fn walk_expr(visitor: &V, expr: &mut Expr) { visitor.visit_expr(value); } } - Expr::Set(ast::ExprSet { - elts, - range: _, - node_index: _, - }) => { + Expr::Set(ast::ExprSet { elts, .. }) => { for expr in elts { visitor.visit_expr(expr); } } Expr::ListComp(ast::ExprListComp { - elt, - generators, - range: _, - node_index: _, + elt, generators, .. }) => { for comprehension in generators { visitor.visit_comprehension(comprehension); @@ -443,10 +363,7 @@ pub fn walk_expr(visitor: &V, expr: &mut Expr) { visitor.visit_expr(elt); } Expr::SetComp(ast::ExprSetComp { - elt, - generators, - range: _, - node_index: _, + elt, generators, .. }) => { for comprehension in generators { visitor.visit_comprehension(comprehension); @@ -457,8 +374,7 @@ pub fn walk_expr(visitor: &V, expr: &mut Expr) { key, value, generators, - range: _, - node_index: _, + .. }) => { for comprehension in generators { visitor.visit_comprehension(comprehension); @@ -469,41 +385,26 @@ pub fn walk_expr(visitor: &V, expr: &mut Expr) { visitor.visit_expr(value); } Expr::Generator(ast::ExprGenerator { - elt, - generators, - range: _, - node_index: _, - parenthesized: _, + elt, generators, .. }) => { for comprehension in generators { visitor.visit_comprehension(comprehension); } visitor.visit_expr(elt); } - Expr::Await(ast::ExprAwait { - value, - range: _, - node_index: _, - }) => visitor.visit_expr(value), - Expr::Yield(ast::ExprYield { - value, - range: _, - node_index: _, - }) => { + Expr::Await(ast::ExprAwait { value, .. }) => visitor.visit_expr(value), + Expr::Yield(ast::ExprYield { value, .. }) => { if let Some(expr) = value { visitor.visit_expr(expr); } } - Expr::YieldFrom(ast::ExprYieldFrom { - value, - range: _, - node_index: _, - }) => visitor.visit_expr(value), + Expr::YieldFrom(ast::ExprYieldFrom { value, .. }) => visitor.visit_expr(value), Expr::Compare(ast::ExprCompare { ops, operands, range: _, node_index: _, + runtime_comparators: _, }) => { if let Some((left, comparators)) = operands.split_first_mut() { visitor.visit_expr(left); @@ -516,10 +417,7 @@ pub fn walk_expr(visitor: &V, expr: &mut Expr) { } } Expr::Call(ast::ExprCall { - func, - arguments, - range_start: _, - node_index: _, + func, arguments, .. }) => { visitor.visit_expr(func); visitor.visit_arguments(arguments); @@ -552,6 +450,7 @@ pub fn walk_expr(visitor: &V, expr: &mut Expr) { } } Expr::NumberLiteral(_) + | Expr::Constant(_) | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) => {} @@ -560,57 +459,33 @@ pub fn walk_expr(visitor: &V, expr: &mut Expr) { visitor.visit_expr_context(ctx); } Expr::Subscript(ast::ExprSubscript { - value, - slice, - ctx, - range: _, - node_index: _, + value, slice, ctx, .. }) => { visitor.visit_expr(value); visitor.visit_expr(slice); visitor.visit_expr_context(ctx); } - Expr::Starred(ast::ExprStarred { - value, - ctx, - range: _, - node_index: _, - }) => { + Expr::Starred(ast::ExprStarred { value, ctx, .. }) => { visitor.visit_expr(value); visitor.visit_expr_context(ctx); } Expr::Name(ast::ExprName { ctx, .. }) => { visitor.visit_expr_context(ctx); } - Expr::List(ast::ExprList { - elts, - ctx, - range: _, - node_index: _, - }) => { + Expr::List(ast::ExprList { elts, ctx, .. }) => { for expr in elts { visitor.visit_expr(expr); } visitor.visit_expr_context(ctx); } - Expr::Tuple(ast::ExprTuple { - elts, - ctx, - range: _, - node_index: _, - parenthesized: _, - }) => { + Expr::Tuple(ast::ExprTuple { elts, ctx, .. }) => { for expr in elts { visitor.visit_expr(expr); } visitor.visit_expr_context(ctx); } Expr::Slice(ast::ExprSlice { - lower, - upper, - step, - range: _, - node_index: _, + lower, upper, step, .. }) => { if let Some(expr) = lower { visitor.visit_expr(expr); @@ -720,13 +595,7 @@ pub fn walk_type_params(visitor: &V, type_params: &mut pub fn walk_type_param(visitor: &V, type_param: &mut TypeParam) { match type_param { - TypeParam::TypeVar(TypeParamTypeVar { - bound, - default, - name: _, - range: _, - node_index: _, - }) => { + TypeParam::TypeVar(TypeParamTypeVar { bound, default, .. }) => { if let Some(expr) = bound { visitor.visit_expr(expr); } @@ -734,22 +603,12 @@ pub fn walk_type_param(visitor: &V, type_param: &mut Ty visitor.visit_expr(expr); } } - TypeParam::TypeVarTuple(TypeParamTypeVarTuple { - default, - name: _, - range: _, - node_index: _, - }) => { + TypeParam::TypeVarTuple(TypeParamTypeVarTuple { default, .. }) => { if let Some(expr) = default { visitor.visit_expr(expr); } } - TypeParam::ParamSpec(TypeParamParamSpec { - default, - name: _, - range: _, - node_index: _, - }) => { + TypeParam::ParamSpec(TypeParamParamSpec { default, .. }) => { if let Some(expr) = default { visitor.visit_expr(expr); } diff --git a/crates/ruff_python_ast_integration_tests/tests/visitor.rs b/crates/ruff_python_ast_integration_tests/tests/visitor.rs index 5f1d01f071b3ca..27ae76b60e30d4 100644 --- a/crates/ruff_python_ast_integration_tests/tests/visitor.rs +++ b/crates/ruff_python_ast_integration_tests/tests/visitor.rs @@ -182,6 +182,7 @@ where body, range: _, node_index: _, + runtime_body: _, }) => { visitor.visit_body(body); } diff --git a/crates/ruff_python_codegen/src/generator.rs b/crates/ruff_python_codegen/src/generator.rs index 67c182567c6706..4b633c18bcb1e8 100644 --- a/crates/ruff_python_codegen/src/generator.rs +++ b/crates/ruff_python_codegen/src/generator.rs @@ -304,6 +304,8 @@ impl<'a> Generator<'a> { type_params, range: _, node_index: _, + runtime_decorator_list: _, + runtime_body: _, }) => { self.newlines(if self.indent_depth == 0 { 2 } else { 1 }); for decorator in decorator_list { @@ -366,6 +368,7 @@ impl<'a> Generator<'a> { targets, range: _, node_index: _, + runtime_targets: _, }) => { statement!({ self.p("del "); @@ -421,6 +424,7 @@ impl<'a> Generator<'a> { simple, range: _, node_index: _, + runtime_simple: _, }) => { statement!({ let need_parens = matches!(target.as_ref(), Expr::Name(_)) && !simple; @@ -467,6 +471,8 @@ impl<'a> Generator<'a> { orelse, range: _, node_index: _, + runtime_body: _, + runtime_orelse: _, }) => { statement!({ self.p("while "); @@ -487,6 +493,7 @@ impl<'a> Generator<'a> { elif_else_clauses, range: _, node_index: _, + runtime_body: _, }) => { statement!({ self.p("if "); @@ -592,6 +599,10 @@ impl<'a> Generator<'a> { is_star, range: _, node_index: _, + runtime_body: _, + runtime_handlers: _, + runtime_orelse: _, + runtime_finalbody: _, }) => { statement!({ self.p("try:"); @@ -657,6 +668,7 @@ impl<'a> Generator<'a> { is_lazy, range: _, node_index: _, + runtime_level: _, }) => { statement!({ if *is_lazy { @@ -747,6 +759,7 @@ impl<'a> Generator<'a> { body, range: _, node_index: _, + runtime_body: _, }) => { self.p("except"); if star { @@ -786,6 +799,7 @@ impl<'a> Generator<'a> { patterns, range: _, node_index: _, + runtime_patterns: _, }) => { self.p("["); let mut first = true; @@ -801,6 +815,8 @@ impl<'a> Generator<'a> { rest, range: _, node_index: _, + runtime_keys: _, + runtime_patterns: _, }) => { self.p("{"); let mut first = true; @@ -850,6 +866,7 @@ impl<'a> Generator<'a> { patterns, range: _, node_index: _, + runtime_patterns: _, }) => { let mut first = true; for pattern in patterns { @@ -947,6 +964,7 @@ impl<'a> Generator<'a> { values, range: _, node_index: _, + runtime_values: _, }) => { let (op, prec) = opprec!(bin, op, BoolOp, And("and", AND), Or("or", OR)); group_if!(prec, { @@ -1367,6 +1385,7 @@ impl<'a> Generator<'a> { Expr::IpyEscapeCommand(ast::ExprIpyEscapeCommand { kind, value, .. }) => { self.p(&format!("{kind}{value}")); } + Expr::Constant(_) => unreachable!("RustPython-only AST node"), } } @@ -1540,6 +1559,9 @@ impl<'a> Generator<'a> { format_spec, range: _, node_index: _, + runtime_str: _, + runtime_interpolation_format_spec: _, + runtime_formatted_value_format_spec: _, }) => self.unparse_interpolated_element( expression, debug_text.as_ref(), diff --git a/crates/ruff_python_formatter/generate.py b/crates/ruff_python_formatter/generate.py index 9ce8acddb7a1b2..cab116ae06c771 100755 --- a/crates/ruff_python_formatter/generate.py +++ b/crates/ruff_python_formatter/generate.py @@ -101,7 +101,7 @@ def to_camel_case(node: str) -> str: code = f""" use ruff_formatter::write; use ruff_python_ast::{node}; - use crate::verbatim_text; + use crate::verbatim::verbatim_text; use crate::prelude::*; #[derive(Default)] diff --git a/crates/ruff_python_formatter/src/expression/expr_constant.rs b/crates/ruff_python_formatter/src/expression/expr_constant.rs new file mode 100644 index 00000000000000..a3402037f6e209 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_constant.rs @@ -0,0 +1,13 @@ +use crate::prelude::*; +use crate::verbatim::verbatim_text; +use ruff_formatter::write; +use ruff_python_ast::ExprConstant; + +#[derive(Default)] +pub struct FormatExprConstant; + +impl FormatNodeRule for FormatExprConstant { + fn fmt_fields(&self, item: &ExprConstant, f: &mut PyFormatter) -> FormatResult<()> { + write!(f, [verbatim_text(item)]) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_dict.rs b/crates/ruff_python_formatter/src/expression/expr_dict.rs index 9e5b4f111225bc..20c41a1b0ba09a 100644 --- a/crates/ruff_python_formatter/src/expression/expr_dict.rs +++ b/crates/ruff_python_formatter/src/expression/expr_dict.rs @@ -17,6 +17,7 @@ impl FormatNodeRule for FormatExprDict { range: _, node_index: _, items, + runtime_values: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/expression/expr_list.rs b/crates/ruff_python_formatter/src/expression/expr_list.rs index 4e295001d3865b..0c04fc1e8cadad 100644 --- a/crates/ruff_python_formatter/src/expression/expr_list.rs +++ b/crates/ruff_python_formatter/src/expression/expr_list.rs @@ -18,6 +18,7 @@ impl FormatNodeRule for FormatExprList { node_index: _, elts, ctx: _, + runtime_elts: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/expression/expr_set.rs b/crates/ruff_python_formatter/src/expression/expr_set.rs index 45d7f2f1701875..8913879e10d175 100644 --- a/crates/ruff_python_formatter/src/expression/expr_set.rs +++ b/crates/ruff_python_formatter/src/expression/expr_set.rs @@ -14,6 +14,7 @@ impl FormatNodeRule for FormatExprSet { range: _, node_index: _, elts, + runtime_elts: _, } = item; // That would be a dict expression assert!(!elts.is_empty()); diff --git a/crates/ruff_python_formatter/src/expression/expr_tuple.rs b/crates/ruff_python_formatter/src/expression/expr_tuple.rs index 8eba63a2ac23f7..f0100a22291fea 100644 --- a/crates/ruff_python_formatter/src/expression/expr_tuple.rs +++ b/crates/ruff_python_formatter/src/expression/expr_tuple.rs @@ -118,6 +118,7 @@ impl FormatNodeRule for FormatExprTuple { range: _, node_index: _, parenthesized: is_parenthesized, + runtime_elts: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/expression/mod.rs b/crates/ruff_python_formatter/src/expression/mod.rs index 2dfabab92a71f6..99e37a36670e0a 100644 --- a/crates/ruff_python_formatter/src/expression/mod.rs +++ b/crates/ruff_python_formatter/src/expression/mod.rs @@ -30,6 +30,7 @@ pub(crate) mod expr_boolean_literal; pub(crate) mod expr_bytes_literal; pub(crate) mod expr_call; pub(crate) mod expr_compare; +pub(crate) mod expr_constant; pub(crate) mod expr_dict; pub(crate) mod expr_dict_comp; pub(crate) mod expr_ellipsis_literal; @@ -110,6 +111,7 @@ impl FormatRule> for FormatExpr { Expr::Tuple(expr) => expr.format().fmt(f), Expr::Slice(expr) => expr.format().fmt(f), Expr::IpyEscapeCommand(expr) => expr.format().fmt(f), + Expr::Constant(expr) => expr.format().fmt(f), }); let parenthesize = match parentheses { Parentheses::Preserve => f.context().is_expression_parenthesized(expression.into()), @@ -290,6 +292,7 @@ fn format_with_parentheses_comments( Expr::Tuple(expr) => FormatNodeRule::fmt_fields(expr.format().rule(), expr, f), Expr::Slice(expr) => FormatNodeRule::fmt_fields(expr.format().rule(), expr, f), Expr::IpyEscapeCommand(expr) => FormatNodeRule::fmt_fields(expr.format().rule(), expr, f), + Expr::Constant(_) => unreachable!("RustPython-only AST node"), }); leading_comments(leading_outer).fmt(f)?; @@ -486,6 +489,7 @@ impl NeedsParentheses for Expr { Expr::Tuple(expr) => expr.needs_parentheses(parent, context), Expr::Slice(expr) => expr.needs_parentheses(parent, context), Expr::IpyEscapeCommand(expr) => expr.needs_parentheses(parent, context), + Expr::Constant(_) => OptionalParentheses::Never, } } } @@ -676,6 +680,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { node_index: _, op: _, values, + runtime_values: _, }) => self.update_max_precedence_with_count( OperatorPrecedence::BooleanOperation, values.len().saturating_sub(1) as u32, @@ -701,6 +706,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { node_index: _, ops, operands: _, + runtime_comparators: _, }) => { self.update_max_precedence_with_count( OperatorPrecedence::Comparator, @@ -781,6 +787,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { | Expr::EllipsisLiteral(_) | Expr::Name(_) | Expr::Slice(_) + | Expr::Constant(_) | Expr::IpyEscapeCommand(_) => { return; } @@ -1300,6 +1307,7 @@ pub(crate) fn is_expression_huggable(expr: &Expr, context: &PyFormatContext) -> | Expr::BytesLiteral(_) | Expr::FString(_) | Expr::TString(_) + | Expr::Constant(_) | Expr::EllipsisLiteral(_) => false, } } @@ -1357,6 +1365,7 @@ pub(crate) fn is_splittable_expression(expr: &Expr, context: &PyFormatContext) - | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) | Expr::EllipsisLiteral(_) + | Expr::Constant(_) | Expr::Slice(_) | Expr::IpyEscapeCommand(_) => false, @@ -1467,6 +1476,7 @@ pub(crate) fn left_most<'expr>(expression: &'expr Expr, trivia: &TriviaRanges) - | Expr::Lambda(_) | Expr::Named(_) | Expr::IpyEscapeCommand(_) + | Expr::Constant(_) | Expr::Generator(_) => None, }; diff --git a/crates/ruff_python_formatter/src/generated.rs b/crates/ruff_python_formatter/src/generated.rs index 3abc77a5388196..dfae88f53295ad 100644 --- a/crates/ruff_python_formatter/src/generated.rs +++ b/crates/ruff_python_formatter/src/generated.rs @@ -1814,6 +1814,42 @@ impl<'ast> IntoFormat> for ast::ExprEllipsisLiteral { } } +impl FormatRule> + for crate::expression::expr_constant::FormatExprConstant +{ + #[inline] + fn fmt(&self, node: &ast::ExprConstant, f: &mut PyFormatter) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprConstant { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprConstant, + crate::expression::expr_constant::FormatExprConstant, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_constant::FormatExprConstant::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprConstant { + type Format = FormatOwnedWithRule< + ast::ExprConstant, + crate::expression::expr_constant::FormatExprConstant, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_constant::FormatExprConstant::default(), + ) + } +} + impl FormatRule> for crate::expression::expr_attribute::FormatExprAttribute { diff --git a/crates/ruff_python_formatter/src/module/mod_module.rs b/crates/ruff_python_formatter/src/module/mod_module.rs index f24eb904291596..89eeb0eaae136c 100644 --- a/crates/ruff_python_formatter/src/module/mod_module.rs +++ b/crates/ruff_python_formatter/src/module/mod_module.rs @@ -15,6 +15,7 @@ impl FormatNodeRule for FormatModModule { range, body, node_index: _, + runtime_body: _, } = item; if body.is_empty() { diff --git a/crates/ruff_python_formatter/src/other/arguments.rs b/crates/ruff_python_formatter/src/other/arguments.rs index 04c702cb5cf23d..4702d645a40698 100644 --- a/crates/ruff_python_formatter/src/other/arguments.rs +++ b/crates/ruff_python_formatter/src/other/arguments.rs @@ -20,6 +20,8 @@ impl FormatNodeRule for FormatArguments { args, keywords, node_index: _, + runtime_args: _, + runtime_bases: _, } = item; // We have a case with `f()` without any argument, which is a special case because we can // have a comment with no node attachment inside: diff --git a/crates/ruff_python_formatter/src/other/comprehension.rs b/crates/ruff_python_formatter/src/other/comprehension.rs index 597b8182b7f75c..32b077fb299227 100644 --- a/crates/ruff_python_formatter/src/other/comprehension.rs +++ b/crates/ruff_python_formatter/src/other/comprehension.rs @@ -53,6 +53,8 @@ impl FormatNodeRule for FormatComprehension { iter, ifs, is_async, + runtime_ifs: _, + runtime_is_async: _, } = item; if *is_async { diff --git a/crates/ruff_python_formatter/src/other/except_handler_except_handler.rs b/crates/ruff_python_formatter/src/other/except_handler_except_handler.rs index bcb972032961c0..28218ad1c9f1fc 100644 --- a/crates/ruff_python_formatter/src/other/except_handler_except_handler.rs +++ b/crates/ruff_python_formatter/src/other/except_handler_except_handler.rs @@ -47,6 +47,7 @@ impl FormatNodeRule for FormatExceptHandlerExceptHan type_, name, body, + runtime_body: _, } = item; let comments_info = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/other/match_case.rs b/crates/ruff_python_formatter/src/other/match_case.rs index 3221f133dbf150..baa73658737560 100644 --- a/crates/ruff_python_formatter/src/other/match_case.rs +++ b/crates/ruff_python_formatter/src/other/match_case.rs @@ -30,6 +30,7 @@ impl FormatNodeRule for FormatMatchCase { pattern, guard, body, + runtime_body: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/other/parameter.rs b/crates/ruff_python_formatter/src/other/parameter.rs index c2eeb6aa6a21a6..686af9f7f259ff 100644 --- a/crates/ruff_python_formatter/src/other/parameter.rs +++ b/crates/ruff_python_formatter/src/other/parameter.rs @@ -11,6 +11,8 @@ impl FormatNodeRule for FormatParameter { node_index: _, name, annotation, + runtime_type_comment: _, + runtime_type_comment_bytes: _, } = item; name.format().fmt(f)?; diff --git a/crates/ruff_python_formatter/src/other/parameters.rs b/crates/ruff_python_formatter/src/other/parameters.rs index 89338226ebf5c2..0c02acb680acb7 100644 --- a/crates/ruff_python_formatter/src/other/parameters.rs +++ b/crates/ruff_python_formatter/src/other/parameters.rs @@ -57,6 +57,7 @@ impl FormatNodeRule for FormatParameters { vararg, kwonlyargs, kwarg, + runtime_defaults: _, } = item; let (slash, star) = find_parameter_separators(f.context().source(), item); diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_class.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_class.rs index ce1583049406b8..f8cdf82a1f434c 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_class.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_class.rs @@ -16,6 +16,9 @@ impl FormatNodeRule for FormatPatternMatchClass { node_index: _, cls, arguments, + runtime_patterns: _, + runtime_kwd_attrs: _, + runtime_kwd_patterns: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs index cb5568f707035f..7b5fe88176fddb 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs @@ -22,6 +22,8 @@ impl FormatNodeRule for FormatPatternMatchMapping { rest, range: _, node_index: _, + runtime_keys: _, + runtime_patterns: _, } = item; debug_assert_eq!(keys.len(), patterns.len()); @@ -165,6 +167,8 @@ fn find_double_star(pattern: &PatternMatchMapping, source: &str) -> Option<(Text rest, range: _, node_index: _, + runtime_keys: _, + runtime_patterns: _, } = pattern; // If there's no `rest` element, there's no `**`. diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs index b0b21f49e902a8..232cab59fb1cfb 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs @@ -18,6 +18,7 @@ impl FormatNodeRule for FormatPatternMatchOr { range: _, node_index: _, patterns, + runtime_patterns: _, } = item; let inner = format_with(|f: &mut PyFormatter| { let mut patterns = patterns.iter(); diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs index 8753760ec69123..fc03828008225c 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs @@ -18,6 +18,7 @@ impl FormatNodeRule for FormatPatternMatchSequence { patterns, range, node_index: _, + runtime_patterns: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/range.rs b/crates/ruff_python_formatter/src/range.rs index 47266fb53431f2..26bd414435446d 100644 --- a/crates/ruff_python_formatter/src/range.rs +++ b/crates/ruff_python_formatter/src/range.rs @@ -418,6 +418,10 @@ impl SourceOrderVisitor<'_> for NarrowRange<'_> { is_star: _, range: _, node_index: _, + runtime_body: _, + runtime_handlers: _, + runtime_orelse: _, + runtime_finalbody: _, }) => { self.visit_body(body); if let Some(except_handler_saved) = @@ -703,6 +707,7 @@ impl Format> for FormatEnclosingNode<'_> { | AnyNodeRef::ExprTuple(_) | AnyNodeRef::ExprSlice(_) | AnyNodeRef::ExprIpyEscapeCommand(_) + | AnyNodeRef::ExprConstant(_) | AnyNodeRef::FString(_) | AnyNodeRef::StringLiteral(_) | AnyNodeRef::TString(_) diff --git a/crates/ruff_python_formatter/src/statement/clause.rs b/crates/ruff_python_formatter/src/statement/clause.rs index b4320bcab360c1..ba10764bd2bec5 100644 --- a/crates/ruff_python_formatter/src/statement/clause.rs +++ b/crates/ruff_python_formatter/src/statement/clause.rs @@ -126,6 +126,8 @@ impl<'a> ClauseHeader<'a> { decorator_list: _, name: _, body: _, + runtime_decorator_list: _, + runtime_body: _, }) => { if let Some(type_params) = type_params.as_deref() { visit(type_params, visitor); @@ -145,6 +147,10 @@ impl<'a> ClauseHeader<'a> { name: _, returns, body: _, + runtime_decorator_list: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, }) => { if let Some(type_params) = type_params.as_deref() { visit(type_params, visitor); @@ -161,6 +167,7 @@ impl<'a> ClauseHeader<'a> { node_index: _, body: _, elif_else_clauses: _, + runtime_body: _, }) => { visit(test.as_ref(), visitor); } @@ -169,6 +176,8 @@ impl<'a> ClauseHeader<'a> { range: _, node_index: _, body: _, + runtime_body: _, + runtime_orelse: _, }) => { if let Some(test) = test.as_ref() { visit(test, visitor); @@ -181,6 +190,7 @@ impl<'a> ClauseHeader<'a> { node_index: _, name: _, body: _, + runtime_body: _, }) => { if let Some(type_expr) = type_expr.as_deref() { visit(type_expr, visitor); @@ -200,6 +210,7 @@ impl<'a> ClauseHeader<'a> { range: _, node_index: _, body: _, + runtime_body: _, }) => { visit(pattern, visitor); @@ -215,6 +226,10 @@ impl<'a> ClauseHeader<'a> { is_async: _, body: _, orelse: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, + runtime_orelse: _, }) => { visit(target.as_ref(), visitor); visit(iter.as_ref(), visitor); @@ -225,6 +240,8 @@ impl<'a> ClauseHeader<'a> { node_index: _, body: _, orelse: _, + runtime_body: _, + runtime_orelse: _, }) => { visit(test.as_ref(), visitor); } @@ -234,6 +251,9 @@ impl<'a> ClauseHeader<'a> { node_index: _, is_async: _, body: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, }) => { for item in items { visit(item, visitor); diff --git a/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs b/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs index 09ad3240a9f037..4646480c0f356d 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs @@ -21,6 +21,7 @@ impl FormatNodeRule for FormatStmtAnnAssign { annotation, value, simple: _, + runtime_simple: _, } = item; let comments = f.context().comments().clone(); let annotation_parentheses = annotation diff --git a/crates/ruff_python_formatter/src/statement/stmt_assign.rs b/crates/ruff_python_formatter/src/statement/stmt_assign.rs index 16bbb1dfe6441b..b008df406283cf 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_assign.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_assign.rs @@ -36,6 +36,9 @@ impl FormatNodeRule for FormatStmtAssign { node_index: _, targets, value, + runtime_targets: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, } = item; let (first, rest) = targets.split_first().ok_or(FormatError::syntax_error( diff --git a/crates/ruff_python_formatter/src/statement/stmt_class_def.rs b/crates/ruff_python_formatter/src/statement/stmt_class_def.rs index 941fc43aa38f6a..7de3a7fd8e084c 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_class_def.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_class_def.rs @@ -24,6 +24,8 @@ impl FormatNodeRule for FormatStmtClassDef { body, type_params, decorator_list, + runtime_decorator_list: _, + runtime_body: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/statement/stmt_delete.rs b/crates/ruff_python_formatter/src/statement/stmt_delete.rs index 0f66beb403de8a..1bbc3458f217d3 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_delete.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_delete.rs @@ -17,6 +17,7 @@ impl FormatNodeRule for FormatStmtDelete { range: _, node_index: _, targets, + runtime_targets: _, } = item; write!(f, [token("del"), space()])?; diff --git a/crates/ruff_python_formatter/src/statement/stmt_for.rs b/crates/ruff_python_formatter/src/statement/stmt_for.rs index d8e1cd082e5549..a969542a9066b7 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_for.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_for.rs @@ -37,6 +37,10 @@ impl FormatNodeRule for FormatStmtFor { orelse, range: _, node_index: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, + runtime_orelse: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/statement/stmt_function_def.rs b/crates/ruff_python_formatter/src/statement/stmt_function_def.rs index 61b333c72dbdba..2dfbcbcea7985e 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_function_def.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_function_def.rs @@ -102,6 +102,10 @@ fn format_function_header(f: &mut PyFormatter, item: &StmtFunctionDef) -> Format parameters, returns, body: _, + runtime_decorator_list: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/statement/stmt_if.rs b/crates/ruff_python_formatter/src/statement/stmt_if.rs index 899c03c054cacf..c4a5bb638a0a96 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_if.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_if.rs @@ -19,6 +19,7 @@ impl FormatNodeRule for FormatStmtIf { test, body, elif_else_clauses, + runtime_body: _, } = item; let comments = f.context().comments().clone(); @@ -67,6 +68,8 @@ pub(crate) fn format_elif_else_clause( node_index: _, test, body, + runtime_body: _, + runtime_orelse: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/statement/stmt_import_from.rs b/crates/ruff_python_formatter/src/statement/stmt_import_from.rs index 6b715eab830dd0..e1aeae80f8b878 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_import_from.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_import_from.rs @@ -19,6 +19,7 @@ impl FormatNodeRule for FormatStmtImportFrom { is_lazy, range: _, node_index: _, + runtime_level: _, } = item; if *is_lazy { diff --git a/crates/ruff_python_formatter/src/statement/stmt_try.rs b/crates/ruff_python_formatter/src/statement/stmt_try.rs index 2ea085b67d35d8..b4ff67842c7dbb 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_try.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_try.rs @@ -67,6 +67,10 @@ impl FormatNodeRule for FormatStmtTry { is_star, range: _, node_index: _, + runtime_body: _, + runtime_handlers: _, + runtime_orelse: _, + runtime_finalbody: _, } = item; let comments_info = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/statement/stmt_while.rs b/crates/ruff_python_formatter/src/statement/stmt_while.rs index fdcc2e4c9a31ed..1a233b84c01f88 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_while.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_while.rs @@ -19,6 +19,8 @@ impl FormatNodeRule for FormatStmtWhile { test, body, orelse, + runtime_body: _, + runtime_orelse: _, } = item; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_parser/Cargo.toml b/crates/ruff_python_parser/Cargo.toml index 2c243f9095fa06..c90093900fe71d 100644 --- a/crates/ruff_python_parser/Cargo.toml +++ b/crates/ruff_python_parser/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "ruff_python_parser" -version = "0.0.16" -description = "This is an internal component crate of Ruff" +description = "Unofficial fork for RustPython" +name = "rustpython-ruff_python_parser" +version = "0.16.10" authors = ["Charlie Marsh ", "RustPython Team"] edition = { workspace = true } rust-version = { workspace = true } @@ -11,6 +11,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +name = "ruff_python_parser" [dependencies] ruff_python_ast = { workspace = true, features = ["get-size"] } diff --git a/crates/ruff_python_parser/src/lib.rs b/crates/ruff_python_parser/src/lib.rs index 49beaf37b58a11..a6066bda687cf1 100644 --- a/crates/ruff_python_parser/src/lib.rs +++ b/crates/ruff_python_parser/src/lib.rs @@ -375,6 +375,7 @@ pub fn parse_cells_unchecked( node_index: AtomicNodeIndex::NONE, range: module_range.unwrap_or_default(), body, + runtime_body: None, }, tokens: Tokens::new(tokens), errors, diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 2b653ea9f167f0..05da2d80fe13bd 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -736,6 +736,8 @@ impl<'src> Parser<'src> { node_index: AtomicNodeIndex::NONE, args: ThinVec::new(), keywords: ThinVec::default(), + runtime_args: None, + runtime_bases: None, }; } @@ -873,6 +875,8 @@ impl<'src> Parser<'src> { node_index: AtomicNodeIndex::NONE, args: self.expr_scratch.take_thin_vec(args_snapshot), keywords, + runtime_args: None, + runtime_bases: None, }; self.validate_arguments(&arguments, has_trailing_comma, context); @@ -939,6 +943,7 @@ impl<'src> Parser<'src> { range: self.node_range(slice_start), parenthesized: false, node_index: AtomicNodeIndex::NONE, + runtime_elts: None, }); } else if slice.is_starred_expr() { // If the only slice element is a starred expression, that is represented @@ -950,6 +955,7 @@ impl<'src> Parser<'src> { range: self.node_range(slice_start), parenthesized: false, node_index: AtomicNodeIndex::NONE, + runtime_elts: None, }); } @@ -1195,6 +1201,7 @@ impl<'src> Parser<'src> { op, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_values: None, } } @@ -1277,6 +1284,7 @@ impl<'src> Parser<'src> { operands: self.expr_scratch.take(operands_snapshot), range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_comparators: None, } } @@ -1438,6 +1446,8 @@ impl<'src> Parser<'src> { value: ast::TStringValue::concatenated(values), range, node_index: AtomicNodeIndex::NONE, + runtime_template_str: None, + runtime_values: None, }); } } @@ -1500,6 +1510,8 @@ impl<'src> Parser<'src> { value: ast::FStringValue::concatenated(parts), range, node_index: AtomicNodeIndex::NONE, + runtime_joined_str: None, + runtime_values: None, }) } @@ -2025,6 +2037,9 @@ impl<'src> Parser<'src> { format_spec, range, node_index: AtomicNodeIndex::NONE, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, } } @@ -2055,6 +2070,7 @@ impl<'src> Parser<'src> { ctx: ExprContext::Load, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_elts: None, }); } @@ -2146,6 +2162,7 @@ impl<'src> Parser<'src> { items: vec![], range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_values: None, }); } @@ -2309,6 +2326,7 @@ impl<'src> Parser<'src> { range: self.node_range(start), node_index: AtomicNodeIndex::NONE, parenthesized: true, + runtime_elts: None, }) .into(); } @@ -2403,6 +2421,7 @@ impl<'src> Parser<'src> { range: self.node_range(start), node_index: AtomicNodeIndex::NONE, parenthesized: parenthesized.is_yes(), + runtime_elts: None, } } @@ -2431,6 +2450,7 @@ impl<'src> Parser<'src> { ctx: ExprContext::Load, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_elts: None, } } @@ -2482,6 +2502,7 @@ impl<'src> Parser<'src> { range: self.node_range(start), node_index: AtomicNodeIndex::NONE, elts: self.expr_scratch.take(elts_snapshot), + runtime_elts: None, } } @@ -2527,6 +2548,7 @@ impl<'src> Parser<'src> { range: self.node_range(start), node_index: AtomicNodeIndex::NONE, items, + runtime_values: None, } } @@ -2600,6 +2622,8 @@ impl<'src> Parser<'src> { iter: iter.expr, ifs: self.expr_scratch.take(ifs_snapshot), is_async, + runtime_ifs: None, + runtime_is_async: None, } } diff --git a/crates/ruff_python_parser/src/parser/helpers.rs b/crates/ruff_python_parser/src/parser/helpers.rs index 4024eadb1dd43a..562cf0fc48b6e8 100644 --- a/crates/ruff_python_parser/src/parser/helpers.rs +++ b/crates/ruff_python_parser/src/parser/helpers.rs @@ -75,6 +75,7 @@ pub(super) fn detect_invalid_pre_py39_decorator_node( Number::Float(_) => "a float literal", Number::Complex { .. } => "a complex literal", }, + Expr::Constant(_) => "a constant literal", Expr::BoolOp(_) => "boolean expression", Expr::BinOp(_) => "binary-operation expression", diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index 2042d524f08aab..f728bcc94debbe 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -243,6 +243,7 @@ impl<'src> Parser<'src> { body, range: TextRange::new(self.start_offset, self.current_token_range().end()), node_index: AtomicNodeIndex::NONE, + runtime_body: None, } } diff --git a/crates/ruff_python_parser/src/parser/pattern.rs b/crates/ruff_python_parser/src/parser/pattern.rs index 5ce9fb077a32b1..600183758f99af 100644 --- a/crates/ruff_python_parser/src/parser/pattern.rs +++ b/crates/ruff_python_parser/src/parser/pattern.rs @@ -115,6 +115,7 @@ impl Parser<'_> { range: self.node_range(start), patterns, node_index: AtomicNodeIndex::NONE, + runtime_patterns: None, }); } @@ -262,6 +263,8 @@ impl Parser<'_> { patterns, rest, node_index: AtomicNodeIndex::NONE, + runtime_keys: None, + runtime_patterns: None, } } @@ -340,6 +343,7 @@ impl Parser<'_> { patterns: Vec::new(), range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_patterns: None, }); } @@ -395,6 +399,7 @@ impl Parser<'_> { range: self.node_range(start), patterns, node_index: AtomicNodeIndex::NONE, + runtime_patterns: None, } } @@ -794,6 +799,9 @@ impl Parser<'_> { }, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, } } } diff --git a/crates/ruff_python_parser/src/parser/recovery.rs b/crates/ruff_python_parser/src/parser/recovery.rs index 22b8e120b1b44e..0f9fc3edf03943 100644 --- a/crates/ruff_python_parser/src/parser/recovery.rs +++ b/crates/ruff_python_parser/src/parser/recovery.rs @@ -50,11 +50,13 @@ pub(super) fn pattern_to_expr(pattern: Pattern) -> Expr { range, node_index, patterns, + .. }) => Expr::List(ast::ExprList { elts: patterns.into_iter().map(pattern_to_expr).collect(), ctx: ExprContext::Store, range, node_index, + runtime_elts: None, }), Pattern::MatchMapping(ast::PatternMatchMapping { range, @@ -62,6 +64,7 @@ pub(super) fn pattern_to_expr(pattern: Pattern) -> Expr { keys, patterns, rest, + .. }) => { let mut items: Vec = keys .into_iter() @@ -86,6 +89,7 @@ pub(super) fn pattern_to_expr(pattern: Pattern) -> Expr { range, node_index, items, + runtime_values: None, }) } Pattern::MatchClass(ast::PatternMatchClass { @@ -93,6 +97,7 @@ pub(super) fn pattern_to_expr(pattern: Pattern) -> Expr { node_index, cls, arguments, + .. }) => { debug_assert_eq!(range.end(), arguments.end()); @@ -118,6 +123,8 @@ pub(super) fn pattern_to_expr(pattern: Pattern) -> Expr { value: pattern_to_expr(keyword_pattern.pattern), }) .collect(), + runtime_args: None, + runtime_bases: None, }, }) } diff --git a/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap b/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap index 7748dcc78f202f..903a0c5236bcc4 100644 --- a/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap +++ b/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap @@ -160,6 +160,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -193,12 +194,17 @@ Module( }, ), ], + runtime_comparators: None, }, ), ), }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), IpyEscapeCommand( @@ -265,6 +271,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -279,6 +287,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), Assign( @@ -303,6 +315,9 @@ Module( value: "pwd", }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), AnnAssign( @@ -336,6 +351,7 @@ Module( ), ), simple: true, + runtime_simple: None, }, ), Assign( @@ -360,6 +376,9 @@ Module( value: "foo bar", }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -384,6 +403,9 @@ Module( value: "foo?", }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -408,6 +430,9 @@ Module( value: "pwd?", }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), IpyEscapeCommand( @@ -440,6 +465,9 @@ Module( value: "foo # comment", }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), IpyEscapeCommand( @@ -499,5 +527,6 @@ Module( }, ), ], + runtime_body: None, }, ) diff --git a/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__unicode_aliases.snap b/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__unicode_aliases.snap index 08e3e1b4f3d6a1..5824cc5f4fcc18 100644 --- a/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__unicode_aliases.snap +++ b/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__unicode_aliases.snap @@ -38,6 +38,9 @@ expression: suite }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ] diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index cf2cdeb530b794..84a296b5eb09bb 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -439,6 +439,7 @@ impl<'src> Parser<'src> { targets, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_targets: None, } } @@ -764,6 +765,7 @@ impl<'src> Parser<'src> { is_lazy, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_level: None, } } @@ -1284,6 +1286,9 @@ impl<'src> Parser<'src> { value: Box::new(value.expr), range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, } } @@ -1364,6 +1369,7 @@ impl<'src> Parser<'src> { simple, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_simple: None, } } @@ -1478,6 +1484,7 @@ impl<'src> Parser<'src> { elif_else_clauses: self.elif_else_scratch.take(elif_else_snapshot), range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_body: None, } } @@ -1522,6 +1529,8 @@ impl<'src> Parser<'src> { body, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_body: None, + runtime_orelse: None, } } @@ -1678,6 +1687,10 @@ impl<'src> Parser<'src> { is_star, range: self.node_range(try_start), node_index: AtomicNodeIndex::NONE, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, } } @@ -1828,6 +1841,7 @@ impl<'src> Parser<'src> { body: except_body, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_body: None, }), block_kind, ) @@ -1940,6 +1954,10 @@ impl<'src> Parser<'src> { orelse, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, } } @@ -1988,6 +2006,8 @@ impl<'src> Parser<'src> { orelse, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_body: None, + runtime_orelse: None, } } @@ -2118,6 +2138,10 @@ impl<'src> Parser<'src> { returns, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, } } @@ -2193,6 +2217,8 @@ impl<'src> Parser<'src> { arguments, body, node_index: AtomicNodeIndex::NONE, + runtime_decorator_list: None, + runtime_body: None, } } @@ -2222,6 +2248,9 @@ impl<'src> Parser<'src> { is_async: false, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, } } @@ -2829,6 +2858,7 @@ impl<'src> Parser<'src> { body, range: self.node_range(start), node_index: AtomicNodeIndex::NONE, + runtime_body: None, } } @@ -3065,6 +3095,10 @@ impl<'src> Parser<'src> { }), returns: None, body: Suite::new(), + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, } .into() } @@ -3237,6 +3271,8 @@ impl<'src> Parser<'src> { name, annotation, node_index: AtomicNodeIndex::NONE, + runtime_type_comment: None, + runtime_type_comment_bytes: None, } } @@ -3626,6 +3662,7 @@ impl<'src> Parser<'src> { range: self.node_range(start), type_params, node_index: AtomicNodeIndex::NONE, + runtime_type_params: None, } } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__dont_panic_on_8_in_octal_escape.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__dont_panic_on_8_in_octal_escape.snap index 5e04b08423c132..3e4f0b217a649d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__dont_panic_on_8_in_octal_escape.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__dont_panic_on_8_in_octal_escape.snap @@ -38,6 +38,9 @@ expression: suite }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_constant_range.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_constant_range.snap index e8d011815da687..a0e76437cdc45b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_constant_range.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_constant_range.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -63,6 +66,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -82,6 +88,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_character.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_character.snap index 6565dfb30ddaea..922049ab6e1375 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_character.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_character.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_newline.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_newline.snap index a5a03e0aa5fb0e..e71015793a4d07 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_newline.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_newline.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_line_continuation.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_line_continuation.snap index 6d65b63424d4ae..f1721389a50645 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_line_continuation.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_line_continuation.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -53,6 +56,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base.snap index aa7fe8a01a4ef7..8b2dd962f2fcc7 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base.snap @@ -38,6 +38,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -50,6 +53,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base_more.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base_more.snap index 25ec23a9392eea..9d9d41c30ec0e0 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base_more.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base_more.snap @@ -45,6 +45,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -75,6 +78,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -87,6 +93,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_format.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_format.snap index 2d7c3879f1ec61..1bf215a9cb7a9b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_format.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_format.snap @@ -52,6 +52,9 @@ expression: suite ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -64,6 +67,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_unescaped_newline.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_unescaped_newline.snap index b0b7eb22c15ca4..0978f2931759d9 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_unescaped_newline.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_unescaped_newline.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_empty_fstring.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_empty_fstring.snap index c59e9bbfdbc84b..6dd2bec2a0e53b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_empty_fstring.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_empty_fstring.snap @@ -26,6 +26,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_empty_tstring.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_empty_tstring.snap index bfb2d6218a802d..a7917162060ec0 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_empty_tstring.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_empty_tstring.snap @@ -26,6 +26,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_1.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_1.snap index b5a212b25bcaeb..96f03262afac8c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_1.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_1.snap @@ -51,6 +51,8 @@ expression: suite ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_2.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_2.snap index b5a212b25bcaeb..96f03262afac8c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_2.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_2.snap @@ -51,6 +51,8 @@ expression: suite ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_3.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_3.snap index c0997152c43727..f0c4625a0d437e 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_3.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_3.snap @@ -67,6 +67,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -81,6 +84,8 @@ expression: suite ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_4.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_4.snap index e9634e20e36e48..2b1936fb46b022 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_4.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_4.snap @@ -67,6 +67,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -94,6 +97,8 @@ expression: suite ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring.snap index 1b374911e890e8..51c5bd1ec1e445 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring.snap @@ -32,6 +32,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Interpolation( @@ -49,6 +52,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -68,6 +74,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_equals.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_equals.snap index 0af535cb90dbdd..9f509cfcb1e52a 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_equals.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_equals.snap @@ -48,11 +48,15 @@ expression: suite }, ), ], + runtime_comparators: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -65,6 +69,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_concatenation_string_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_concatenation_string_spec.snap index 103ef76805589a..64bcd97bc8fb01 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_concatenation_string_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_concatenation_string_spec.snap @@ -80,11 +80,17 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -97,6 +103,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_spec.snap index 4520d86c0403f7..04d9059dddcbe0 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_spec.snap @@ -51,11 +51,17 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -68,6 +74,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_string_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_string_spec.snap index 20e17bfaf863f8..204e506619e5ba 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_string_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_string_spec.snap @@ -64,11 +64,17 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -81,6 +87,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_equals.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_equals.snap index 76296065201698..ac2bf6c186e524 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_equals.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_equals.snap @@ -48,11 +48,15 @@ expression: suite }, ), ], + runtime_comparators: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -65,6 +69,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_nested_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_nested_spec.snap index 24224cd435c695..52c5ead4363535 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_nested_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_nested_spec.snap @@ -46,6 +46,9 @@ expression: suite ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -58,6 +61,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_self_doc_prec_space.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_self_doc_prec_space.snap index 6483ef4457bf28..764c7e015300af 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_self_doc_prec_space.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_self_doc_prec_space.snap @@ -38,6 +38,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -50,6 +53,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_self_doc_trailing_space.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_self_doc_trailing_space.snap index b11e4c7d66e7cc..fb50e7a19a492a 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_self_doc_trailing_space.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_self_doc_trailing_space.snap @@ -38,6 +38,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -50,6 +53,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_yield_expr.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_yield_expr.snap index bd3b95ab311bd0..820aecec556a12 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_yield_expr.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_yield_expr.snap @@ -31,6 +31,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -43,6 +46,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring.snap index 67b4c413655bf5..37afbe0a605949 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring.snap @@ -32,6 +32,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Interpolation( @@ -49,6 +52,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -68,6 +74,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_equals.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_equals.snap index 69e6ded53294bd..1124d57cc08166 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_equals.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_equals.snap @@ -48,11 +48,15 @@ expression: suite }, ), ], + runtime_comparators: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -65,6 +69,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_concatenation_string_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_concatenation_string_spec.snap index 93cfa48dd1b63b..50203d0862fe1b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_concatenation_string_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_concatenation_string_spec.snap @@ -80,11 +80,17 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -97,6 +103,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_spec.snap index 70f42c31394d2e..4744dd172bbd4d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_spec.snap @@ -51,11 +51,17 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -68,6 +74,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_string_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_string_spec.snap index 38b4e902ba18c0..0925628ab1ce01 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_string_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_nested_string_spec.snap @@ -64,11 +64,17 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -81,6 +87,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_not_equals.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_not_equals.snap index 3b712d9ebee5c2..06deb34408e621 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_not_equals.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_not_equals.snap @@ -48,11 +48,15 @@ expression: suite }, ), ], + runtime_comparators: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -65,6 +69,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_not_nested_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_not_nested_spec.snap index 32d1997a5ace01..b8eecfca360e38 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_not_nested_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_not_nested_spec.snap @@ -46,6 +46,9 @@ expression: suite ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -58,6 +61,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_self_doc_prec_space.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_self_doc_prec_space.snap index 128940b1be93bc..15b2b4222a0623 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_self_doc_prec_space.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_self_doc_prec_space.snap @@ -38,6 +38,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -50,6 +53,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_self_doc_trailing_space.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_self_doc_trailing_space.snap index 704d367b6cc0e2..b1591af5fd31d5 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_self_doc_trailing_space.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_self_doc_trailing_space.snap @@ -38,6 +38,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -50,6 +53,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_yield_expr.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_yield_expr.snap index b16d33cefbb303..8196e9d5318cec 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_yield_expr.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_tstring_yield_expr.snap @@ -31,6 +31,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -43,6 +46,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_1.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_1.snap index ac951c28110916..a4c3363a0c4d17 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_1.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_1.snap @@ -51,6 +51,8 @@ expression: suite ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_2.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_2.snap index 21f69ed5ed3ebf..6492750da07017 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_2.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_2.snap @@ -64,6 +64,8 @@ expression: suite ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_fstring.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_fstring.snap index 0b4638f5cb7ff5..b83e2b7ef52abe 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_fstring.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_fstring.snap @@ -32,6 +32,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -46,6 +49,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_tstring.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_tstring.snap index b97792d742323a..fedb90aea312af 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_tstring.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_tstring.snap @@ -32,6 +32,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -46,6 +49,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__triple_quoted_raw_fstring.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__triple_quoted_raw_fstring.snap index 250cb005c32ff9..4e607c7a65d3eb 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__triple_quoted_raw_fstring.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__triple_quoted_raw_fstring.snap @@ -32,6 +32,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -46,6 +49,8 @@ expression: suite }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__triple_quoted_raw_tstring.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__triple_quoted_raw_tstring.snap index 4cf02baf483ed4..07931097aac2c1 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__triple_quoted_raw_tstring.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__triple_quoted_raw_tstring.snap @@ -32,6 +32,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -46,6 +49,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_constant_range.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_constant_range.snap index f8825a1412205b..416126ca54ddc8 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_constant_range.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_constant_range.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -63,6 +66,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -82,6 +88,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_escaped_character.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_escaped_character.snap index a10e0fc9967d22..665defa674aafb 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_escaped_character.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_escaped_character.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_escaped_newline.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_escaped_newline.snap index 071d5af2c4d5ae..50db1e54f38590 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_escaped_newline.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_escaped_newline.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_line_continuation.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_line_continuation.snap index ae7da0c069f82b..61e3bd112b37cb 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_line_continuation.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_line_continuation.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -53,6 +56,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_base.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_base.snap index 335cdf29d27349..8983d383432d6a 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_base.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_base.snap @@ -38,6 +38,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -50,6 +53,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_base_more.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_base_more.snap index 4f8ad69bb69656..8c0dd4e135ce37 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_base_more.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_base_more.snap @@ -45,6 +45,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -75,6 +78,9 @@ expression: suite ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -87,6 +93,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_format.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_format.snap index 3c18324acdc8c1..d906b82413d64c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_format.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_parse_self_documenting_format.snap @@ -52,6 +52,9 @@ expression: suite ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -64,6 +67,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_unescaped_newline.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_unescaped_newline.snap index 2c5a1b47c4372e..988c2f8ec66d1e 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_unescaped_newline.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__tstring_unescaped_newline.snap @@ -39,6 +39,9 @@ expression: suite debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ expression: suite }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap index 32da2cab8d10f7..7e0bffaec45795 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap @@ -49,6 +49,7 @@ Module( ), ), simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -91,6 +92,7 @@ Module( ), ), simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -131,6 +133,7 @@ Module( ), ), simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -155,6 +158,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), Assign( @@ -180,9 +184,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap index 12e797e8121680..31092c4e4d7a1a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap @@ -67,6 +67,7 @@ Module( ), ), simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -90,6 +91,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -125,6 +128,7 @@ Module( ), ), simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -181,10 +185,12 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -207,6 +213,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), annotation: Name( @@ -229,6 +236,7 @@ Module( ), ), simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -259,6 +267,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), annotation: Name( @@ -296,10 +305,12 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -330,6 +341,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), annotation: Name( @@ -367,10 +379,12 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -392,6 +406,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), annotation: Name( @@ -414,6 +429,7 @@ Module( ), ), simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -443,6 +459,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), annotation: Name( @@ -480,13 +497,16 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), simple: false, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_value.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_value.py.snap index 2123f14a29a38c..06460f9b667f66 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_value.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_value.py.snap @@ -58,6 +58,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -65,6 +66,7 @@ Module( ), ), simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -98,6 +100,7 @@ Module( ), ), simple: true, + runtime_simple: None, }, ), Expr( @@ -206,6 +209,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -213,13 +217,16 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ), simple: true, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_missing_rhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_missing_rhs.py.snap index db6d7e8c2d1c5a..fe6cc24a22d5f3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_missing_rhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_missing_rhs.py.snap @@ -32,9 +32,11 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_type_alias_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_type_alias_annotation.py.snap index 0b9892d0bff585..71d670e65a0e59 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_type_alias_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_type_alias_annotation.py.snap @@ -32,6 +32,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), Assign( @@ -56,6 +57,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -101,9 +105,13 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_unparenthesized_generator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_unparenthesized_generator.py.snap index 49270f2b3893e3..02a77c22f577ac 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_unparenthesized_generator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_unparenthesized_generator.py.snap @@ -81,11 +81,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -102,6 +106,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -196,11 +202,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -217,6 +227,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -293,11 +305,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -305,12 +321,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_msg.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_msg.py.snap index 2b647a18873d3e..4f6c6c2e3396e2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_msg.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_msg.py.snap @@ -26,6 +26,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_test.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_test.py.snap index 14a4dd1844f5a0..c19f27da4ad1a7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_test.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_test.py.snap @@ -26,6 +26,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap index b8edfb474b04f5..97293b6d4d3a7d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap @@ -139,6 +139,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap index 23311b018ff27f..d8b43159b8a0cd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap @@ -115,6 +115,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap index 1b06e85b42d5b9..7870b203c98ca0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap @@ -34,6 +34,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -68,6 +71,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -118,6 +124,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -174,6 +183,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], @@ -226,11 +236,16 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_value_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_value_expr.py.snap index 65b3b025729c7c..9f235c545a65d4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_value_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_value_expr.py.snap @@ -56,6 +56,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -64,8 +65,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -122,8 +127,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -178,8 +187,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -227,6 +240,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -234,6 +249,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -252,8 +268,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -278,6 +298,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -296,6 +319,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_keyword_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_keyword_target.py.snap index e59c71cea880d1..74e150b4b2b599 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_keyword_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_keyword_target.py.snap @@ -40,6 +40,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -109,6 +112,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -141,6 +147,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_missing_rhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_missing_rhs.py.snap index 8a1f0505336c55..1dfbced4fb626f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_missing_rhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_missing_rhs.py.snap @@ -32,6 +32,9 @@ Module( ctx: Invalid, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -95,6 +98,9 @@ Module( ctx: Invalid, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -158,6 +164,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -192,6 +201,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_starred_expr_value.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_starred_expr_value.py.snap index 186eb41f69fe43..648ca38efcb830 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_starred_expr_value.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_starred_expr_value.py.snap @@ -44,11 +44,15 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -84,11 +88,15 @@ Module( }, ), ], + runtime_elts: None, }, ), ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -126,12 +134,17 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -178,9 +191,13 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@async_unexpected_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@async_unexpected_token.py.snap index 5585cf00720284..b11d8a0157286f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@async_unexpected_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@async_unexpected_token.py.snap @@ -36,6 +36,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), While( @@ -65,6 +67,8 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), Assign( @@ -90,6 +94,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), FunctionDef( @@ -112,6 +119,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -128,6 +136,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Match( @@ -169,11 +181,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap index 4fd519628a094b..d84f95d27220ef 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap @@ -199,6 +199,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_value.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_value.py.snap index 02e8bdd44765f4..b2fefb390b9d7a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_value.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_value.py.snap @@ -50,6 +50,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -170,6 +171,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -177,6 +180,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -233,6 +237,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_missing_rhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_missing_rhs.py.snap index f367265ec79e8c..5df76ca8fec132 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_missing_rhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_missing_rhs.py.snap @@ -119,6 +119,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap index d32ea7bf469d1e..5bd5bb17aba6df 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap @@ -54,9 +54,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap index 5b757520e6503f..1596207cb4787c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap @@ -43,6 +43,7 @@ Module( ), guard: None, body: [], + runtime_body: None, }, MatchCase { range: 31..42, @@ -77,11 +78,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap index 7a88362450c6c0..cf5e90eb9a2544 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap @@ -23,6 +23,8 @@ Module( type_params: None, arguments: None, body: [], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -42,9 +44,13 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [], + runtime_decorator_list: None, + runtime_body: None, }, ), Assign( @@ -70,9 +76,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_missing_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_missing_name.py.snap index ffb66e8ee6a124..ff33234e31651f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_missing_name.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_missing_name.py.snap @@ -36,6 +36,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -55,6 +57,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -71,6 +75,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -110,6 +116,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -126,9 +134,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap index 515534ed26c793..4dc456924ebd84 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap @@ -51,6 +51,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -76,6 +77,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -86,6 +89,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), Assign( @@ -111,9 +116,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap index 6a5ebeb17cd603..5b2f3d6882144a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap @@ -60,6 +60,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -67,6 +69,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -83,9 +87,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_type_params_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_type_params_py311.py.snap index b24904e9ac128f..f6eade30006136 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_type_params_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_type_params_py311.py.snap @@ -59,6 +59,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -112,6 +113,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -129,6 +131,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -146,6 +150,7 @@ Module( range: 105..107, node_index: NodeIndex(None), type_params: [], + runtime_type_params: None, }, ), arguments: None, @@ -163,9 +168,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap index e38fc337b08939..10161b4220a0f2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap @@ -23,6 +23,7 @@ Module( ), body: [], elif_else_clauses: [], + runtime_body: None, }, ), Pass( @@ -44,9 +45,11 @@ Module( ), body: [], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_single_statement.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_single_statement.py.snap index fbcd78eef2c24b..c9934eb6ff119b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_single_statement.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_single_statement.py.snap @@ -23,6 +23,7 @@ Module( ), body: [], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -45,9 +46,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap index d5cb24b9ffb29e..aeeb4d643fda0e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap @@ -55,12 +55,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap index 69e493cafcbc27..8171e5fb5f0c17 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap @@ -48,11 +48,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_element_between_commas.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_element_between_commas.py.snap index 2c50e8d7c59f06..e7a6d1ee0a86af 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_element_between_commas.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_element_between_commas.py.snap @@ -48,11 +48,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_first_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_first_element.py.snap index 48bd834ed4e684..a3b6e67d189ef8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_first_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_first_element.py.snap @@ -41,12 +41,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_for_after_async.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_for_after_async.py.snap index dcdb5112f05563..8e619d2219e0a0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_for_after_async.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_for_after_async.py.snap @@ -62,6 +62,8 @@ Module( ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -70,6 +72,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_class.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_class.py.snap index b12ab21adc57df..a8fcb597e3823d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_class.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_class.py.snap @@ -36,6 +36,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -67,6 +69,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -84,9 +87,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_function.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_function.py.snap index 0b94a57f9d2200..122f174d2950b0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_function.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_function.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -46,6 +47,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -78,6 +83,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -88,6 +94,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -104,6 +111,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -135,6 +146,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -142,6 +155,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -158,6 +172,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -186,6 +204,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -193,6 +213,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -209,6 +230,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_import.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_import.py.snap index 870b0b879363aa..32084a17442136 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_import.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_import.py.snap @@ -79,6 +79,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -112,9 +113,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_match.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_match.py.snap index 6d47e009d455e9..a1051a5fef3c62 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_match.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_match.py.snap @@ -55,11 +55,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_try.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_try.py.snap index 827e2c62acb927..6851dccea0eff8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_try.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_try.py.snap @@ -64,15 +64,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_type_alias.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_type_alias.py.snap index e0d4739946ad58..f6f32478b9ed5e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_type_alias.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_type_alias.py.snap @@ -79,6 +79,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -92,6 +93,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_with.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_with.py.snap index c0e68ac262e1df..97b68835943137 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_with.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@debug_shadow_with.py.snap @@ -58,6 +58,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -87,9 +89,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_await_expression_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_await_expression_py38.py.snap index 7ca2868d311079..74504f1d8b22b8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_await_expression_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_await_expression_py38.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -72,6 +73,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -88,12 +90,21 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_dict_literal_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_dict_literal_py38.py.snap index 0dd32e14c7e49d..a9ef37e493b634 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_dict_literal_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_dict_literal_py38.py.snap @@ -47,6 +47,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -65,6 +66,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -81,9 +83,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_expression_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_expression_py38.py.snap index b277f5a73af3fd..e76d1393a9b58f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_expression_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_expression_py38.py.snap @@ -83,6 +83,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -99,9 +100,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_float_literal_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_float_literal_py38.py.snap index fe245de4477671..d58e143d03a041 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_float_literal_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_float_literal_py38.py.snap @@ -44,6 +44,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -60,9 +61,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap index b43a2254b9197e..e1ba4a8db24071 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap @@ -126,6 +126,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -142,9 +143,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_expression.py.snap index dca904baa9149c..61580d9ae4f7eb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_expression.py.snap @@ -43,6 +43,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -59,6 +60,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -94,6 +99,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -110,6 +116,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -160,6 +170,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -176,6 +187,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -216,9 +231,12 @@ Module( type_params: None, arguments: None, body: [], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_newline.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_newline.py.snap index 30cf842b3c50fb..5d38b5aa91d778 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_newline.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_newline.py.snap @@ -43,6 +43,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -59,6 +60,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -94,6 +99,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -110,6 +116,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -151,9 +161,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_named_expression_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_named_expression_py37.py.snap index b852c0911595ec..978e905a0feeb9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_named_expression_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_named_expression_py37.py.snap @@ -57,6 +57,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -64,6 +66,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -92,6 +95,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -111,6 +116,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -127,9 +133,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_non_toplevel_call_expression_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_non_toplevel_call_expression_py38.py.snap index 2429e4f3fd19e0..2facf25cdd5855 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_non_toplevel_call_expression_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_non_toplevel_call_expression_py38.py.snap @@ -44,6 +44,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -60,6 +62,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -79,6 +83,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -95,9 +100,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_unexpected_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_unexpected_token.py.snap index be98f7c3ada669..4ad6b22b50c68e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_unexpected_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_unexpected_token.py.snap @@ -43,9 +43,14 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -82,6 +87,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -117,9 +125,14 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Assign( @@ -145,9 +158,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_debug_py39.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_debug_py39.py.snap index dbb86fe82298f1..5260297d16e74c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_debug_py39.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_debug_py39.py.snap @@ -24,9 +24,11 @@ Module( }, ), ], + runtime_targets: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap index e8a391037c30bd..c0b2b380aa5553 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap @@ -44,6 +44,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Expr( @@ -116,9 +117,11 @@ Module( }, ), ], + runtime_targets: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_stmt_empty.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_stmt_empty.py.snap index 28619bfea25884..cc7e8d9b49945c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_stmt_empty.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_stmt_empty.py.snap @@ -15,9 +15,11 @@ Module( node_index: NodeIndex(None), range: 0..3, targets: [], + runtime_targets: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@different_match_pattern_bindings.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@different_match_pattern_bindings.py.snap index 9f689a303d11ff..0fd6a5d410fa4c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@different_match_pattern_bindings.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@different_match_pattern_bindings.py.snap @@ -51,6 +51,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -73,9 +74,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -93,6 +96,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 37..55, @@ -122,6 +126,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -129,9 +134,11 @@ Module( node_index: NodeIndex(None), range: 48..50, patterns: [], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -149,6 +156,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 60..83, @@ -192,6 +200,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -214,9 +223,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -234,6 +245,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 88..113, @@ -271,6 +283,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -307,9 +320,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -327,6 +342,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 118..140, @@ -384,9 +400,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -404,6 +422,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 145..170, @@ -433,6 +452,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -455,6 +475,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -477,9 +498,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -497,6 +520,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 175..193, @@ -511,6 +535,7 @@ Module( node_index: NodeIndex(None), range: 180..182, patterns: [], + runtime_patterns: None, }, ), MatchSequence( @@ -533,9 +558,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -553,6 +580,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 198..220, @@ -582,6 +610,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -622,12 +651,17 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -645,6 +679,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 225..246, @@ -679,6 +714,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -701,12 +737,15 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -724,6 +763,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 251..276, @@ -771,9 +811,13 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -814,12 +858,17 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -837,6 +886,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 281..312, @@ -900,14 +950,21 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -964,17 +1021,25 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -992,6 +1057,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 317..346, @@ -1040,9 +1106,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -1084,12 +1152,15 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -1107,11 +1178,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dotted_name_multiple_dots.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dotted_name_multiple_dots.py.snap index ebad60ec0ace0e..fec5589f5aa9a4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dotted_name_multiple_dots.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dotted_name_multiple_dots.py.snap @@ -75,6 +75,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_keyword_args.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_keyword_args.py.snap index b43bfde962ae2d..7ba0dbb4b9f4a1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_keyword_args.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_keyword_args.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -46,6 +48,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -62,6 +65,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -126,6 +133,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -160,6 +169,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -175,6 +186,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -190,6 +203,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -197,6 +212,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -213,6 +229,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -306,12 +326,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_match_class_attr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_match_class_attr.py.snap index 94f9ad317cc205..cb15319d42d7dd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_match_class_attr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_match_class_attr.py.snap @@ -93,6 +93,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -110,6 +113,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 43..70, @@ -186,9 +190,13 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -206,6 +214,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 75..113, @@ -340,10 +349,15 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -361,6 +375,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 118..162, @@ -377,6 +392,8 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchMapping( @@ -509,13 +526,19 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -533,6 +556,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 167..230, @@ -667,6 +691,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), }, @@ -745,11 +771,17 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -767,11 +799,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_match_key.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_match_key.py.snap index e1eca42184f6c4..0dd10252fa9688 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_match_key.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_match_key.py.snap @@ -107,6 +107,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -124,6 +126,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 44..72, @@ -213,6 +216,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -230,6 +235,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 77..99, @@ -291,6 +297,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -308,6 +316,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 104..130, @@ -369,6 +378,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -386,6 +397,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 135..171, @@ -481,6 +493,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -498,6 +512,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 176..204, @@ -555,6 +570,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -572,6 +589,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 209..237, @@ -627,6 +645,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -644,6 +664,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 242..268, @@ -703,6 +724,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -720,6 +743,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 273..300, @@ -779,6 +803,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -796,6 +822,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 305..332, @@ -862,6 +889,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -879,6 +908,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 337..367, @@ -955,6 +985,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -972,6 +1004,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 372..449, @@ -1057,6 +1090,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -1074,6 +1109,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 454..488, @@ -1195,6 +1231,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -1212,6 +1250,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 493..531, @@ -1345,6 +1384,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -1362,6 +1403,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 536..564, @@ -1452,9 +1494,12 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -1472,6 +1517,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 569..607, @@ -1606,11 +1652,16 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -1628,6 +1679,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 612..662, @@ -1680,6 +1732,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), MatchClass( @@ -1812,14 +1867,20 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -1837,6 +1898,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 667..691, @@ -1898,6 +1960,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -1915,6 +1979,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 696..753, @@ -1993,6 +2058,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -2010,11 +2077,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_type_parameter_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_type_parameter_names.py.snap index ffbe7baa874fc4..04674a7ad4e7ef 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_type_parameter_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@duplicate_type_parameter_names.py.snap @@ -54,6 +54,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: EllipsisLiteral( @@ -107,6 +108,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -135,6 +137,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -142,6 +146,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -158,6 +163,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -202,6 +211,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -219,6 +229,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), TypeAlias( @@ -307,6 +319,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -360,6 +373,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: EllipsisLiteral( @@ -426,6 +440,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -436,6 +451,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -452,6 +468,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -496,6 +516,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -506,6 +527,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -522,6 +544,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -566,6 +592,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -576,6 +603,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -592,9 +620,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_star_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_star_py310.py.snap index 56a1931678e7db..f3d98a565eefb6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_star_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_star_py310.py.snap @@ -58,6 +58,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -89,6 +90,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -120,15 +122,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap index 475b5a7e2caed0..a6bfe57bb47eef 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap @@ -54,12 +54,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -105,15 +110,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_as_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_as_name.py.snap index bdc389bfcd5e4a..8b7ce868b76f2f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_as_name.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_as_name.py.snap @@ -46,6 +46,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -71,15 +72,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception.py.snap index e3f602dd2463e4..21f7b322ed3bbe 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception.py.snap @@ -43,12 +43,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -78,6 +83,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -94,6 +100,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -116,15 +123,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception_and_as_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception_and_as_name.py.snap index fe8b15dd88aeaf..2d54c4846f2364 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception_and_as_name.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception_and_as_name.py.snap @@ -37,15 +37,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap index 153f50e02ed8e8..1d284e28ec6ff6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap @@ -52,6 +52,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -70,12 +71,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -120,6 +126,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -138,15 +145,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_no_as_py313.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_no_as_py313.py.snap index 671eed373c07df..27b43a43eb2ffd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_no_as_py313.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_no_as_py313.py.snap @@ -52,6 +52,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -64,12 +65,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -114,6 +120,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -126,15 +133,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap index 58d3cd2c1c9d42..d6cfc32f6184b4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap @@ -53,6 +53,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -100,6 +102,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -147,6 +151,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -197,12 +203,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__duplicate_keyword_arguments.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__duplicate_keyword_arguments.py.snap index 182ca169e029c3..6b4ec1ea9c5142 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__duplicate_keyword_arguments.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__duplicate_keyword_arguments.py.snap @@ -132,12 +132,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap index b444c4d79d7918..dac3238ebb7669 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap @@ -52,6 +52,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -99,6 +101,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -142,6 +146,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -183,12 +189,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap index 551521976d0d85..28f4690d345188 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap @@ -59,6 +59,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -111,6 +113,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -164,6 +168,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -217,12 +223,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap index 9ccc48a63065ec..a669334924f7f7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap @@ -54,6 +54,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -110,6 +112,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -179,6 +183,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -235,6 +241,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -291,12 +299,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_argument.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_argument.py.snap index 9525b67f768d18..633e02742087bc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_argument.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_argument.py.snap @@ -48,12 +48,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap index 9f115bdf9c8c2f..fbd746dfb827ad 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap @@ -48,12 +48,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap index 83e062828f7864..e7f64870ed7d99 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap @@ -41,6 +41,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -87,6 +89,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -137,6 +141,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -157,6 +163,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__starred.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__starred.py.snap index f74d95974caf90..81b1487c68f2e1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__starred.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__starred.py.snap @@ -71,6 +71,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -78,6 +80,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -128,6 +132,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -176,12 +182,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap index cc6fba138b7688..6ae17dd5ae5423 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap @@ -31,6 +31,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -56,6 +58,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -66,9 +69,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap index cdb11a8ebcddd1..7e6c53e1fe1ff5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap @@ -40,6 +40,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -65,6 +67,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -75,9 +78,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap index e28cecdd9f058a..356e2a3f16223d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap @@ -40,6 +40,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -65,6 +67,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -75,9 +78,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__invalid_member.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__invalid_member.py.snap index 40b4cb4fe17761..3355b7300f7723 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__invalid_member.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__invalid_member.py.snap @@ -126,6 +126,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__multiple_dots.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__multiple_dots.py.snap index ee5946cf597b18..74451a7731c447 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__multiple_dots.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__multiple_dots.py.snap @@ -137,6 +137,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap index f23c09e43450bb..6c28085cdb8123 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap @@ -77,6 +77,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap index f9683c9fe628d3..c7a05ce70a601d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap @@ -60,6 +60,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap index 10da259bcc75b3..7ff63f861dd3f4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap @@ -50,6 +50,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -60,9 +61,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap index e3f5cb4807966b..739751c4288f1d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap @@ -148,6 +148,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -155,6 +157,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -280,6 +283,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap index 2d828a4ea59176..637ceb217ea14c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap @@ -49,6 +49,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -56,6 +58,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -110,6 +113,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap index 1ba50a5e827f16..9840e01b6096dd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap @@ -56,6 +56,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap index baf12f21369399..036b4e805d4b49 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap @@ -72,6 +72,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap index 1b39f2bac0dba6..599a62211545ac 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap @@ -104,6 +104,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__multiple_ops.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__multiple_ops.py.snap index cf81983e851c77..a335ad0bf8a27a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__multiple_ops.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__multiple_ops.py.snap @@ -145,6 +145,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap index 47e26dcc60e23c..06988f7f14aaac 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap @@ -69,6 +69,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -118,6 +119,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap index 2e97b80a96d49c..27d711fd5585d7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap @@ -83,6 +83,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap index 151ded376121c2..91f94d09f2607e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap @@ -50,6 +50,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -57,6 +59,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -70,6 +73,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -109,11 +113,13 @@ Module( }, ), ], + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_lhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_lhs.py.snap index 1a9fd282135fc4..56091fe1c53b32 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_lhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_lhs.py.snap @@ -25,6 +25,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap index d40859437fe924..20ee8ce3f03805 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap @@ -37,6 +37,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -73,6 +74,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap index 4b0e330e7f1eb3..f3a6c5100d04f7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap @@ -37,6 +37,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -82,6 +83,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -101,6 +103,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap index c9ef42bbbdcf1e..569714154c834f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap @@ -44,6 +44,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -82,11 +83,13 @@ Module( }, ), ], + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap index 58e8757e8cf3c4..bfa0ff5d66856d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap @@ -46,6 +46,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -89,8 +90,12 @@ Module( }, ), ], + runtime_comparators: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -143,6 +148,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap index d687b210344ab6..b1fcf591dda47b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap @@ -52,6 +52,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -59,6 +61,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -72,6 +75,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -113,11 +117,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap index 4ca152d200eef0..f58a622b75ba88 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap @@ -56,6 +56,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap index 353a0c214581ad..ea26ff00ac040b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap @@ -39,6 +39,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -75,6 +76,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap index d51319b5b9d2a8..81f95ea93424e2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap @@ -77,6 +77,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap index b59ac37b731616..a2c9f8ded5b950 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap @@ -39,6 +39,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -75,6 +76,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap index 6fbe8f5fe7ad8c..9029679c6435b6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], @@ -51,6 +52,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -83,6 +87,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], @@ -94,9 +99,13 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap index a7827b67081494..4767fbba48bb52 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap @@ -39,6 +39,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -73,6 +74,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -106,6 +108,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -126,6 +129,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap index e54efb6c8d9c7d..d8572908ec31f9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap @@ -46,6 +46,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -86,6 +87,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -123,6 +125,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ctx: Load, @@ -163,6 +166,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ctx: Load, @@ -171,6 +175,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap index 2bec92c3f3bf16..8552da90cc2724 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap @@ -59,6 +59,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -126,6 +128,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -179,6 +183,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -192,6 +198,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -250,6 +258,7 @@ Module( }, ), ], + runtime_elts: None, }, ), iter: Name( @@ -262,6 +271,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -323,6 +334,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -385,6 +398,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -445,6 +460,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -511,6 +528,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -518,6 +537,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -532,6 +552,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -602,6 +624,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -673,6 +697,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -742,6 +768,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -817,6 +845,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -824,6 +854,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -838,6 +869,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -845,6 +878,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap index 5056b4c6911489..31a214169bb469 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap @@ -52,6 +52,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -119,6 +120,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -156,6 +158,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -163,6 +167,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -198,6 +203,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -257,10 +263,12 @@ Module( }, ), ], + runtime_values: None, }, ), }, ], + runtime_values: None, }, ), }, @@ -299,6 +307,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -324,6 +333,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -398,6 +408,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -438,10 +449,12 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, ], + runtime_values: None, }, ), }, @@ -482,10 +495,12 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, ], + runtime_values: None, }, ), }, @@ -526,15 +541,18 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, ], + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap index 0bed84d9347312..00fb1cccf5edec 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap @@ -64,6 +64,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -76,6 +77,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -83,6 +86,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap index dcc7317c17e975..a9a551bb24b318 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap @@ -58,6 +58,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -72,11 +74,13 @@ Module( ), }, ], + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap index 3fda1e1433bc8e..8f3e3fa390f4ef 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap @@ -57,11 +57,13 @@ Module( ), }, ], + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap index a54264becd34b6..7db2a6203d51e0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap @@ -41,6 +41,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -65,6 +66,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -75,9 +77,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap index 824f3261f754d2..bbae05b830d894 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap @@ -96,6 +96,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -130,6 +131,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap index ccf8ead1b9b910..b30ab101a6126c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap @@ -102,6 +102,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -136,6 +137,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap index c26c1b247d592a..09d87681a1ba6a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap @@ -28,6 +28,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -86,6 +87,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -122,6 +124,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -180,6 +183,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -215,6 +219,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -240,6 +245,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -305,6 +311,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -393,6 +400,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -461,11 +469,13 @@ Module( ), }, ], + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap index 52729b5c7a0bf6..4c5393effbee69 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap @@ -32,6 +32,9 @@ Module( ctx: Invalid, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -56,6 +59,9 @@ Module( ctx: Invalid, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -80,6 +86,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap index 6b0e5ccbb99c51..b798ab9885a8c6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap @@ -10,6 +10,7 @@ Module( node_index: NodeIndex(None), range: 0..5, body: [], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap index 766ec9bebc2578..ab55b69092d41c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap @@ -66,6 +66,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -76,9 +77,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap index 20584cc80bbae9..8262008c39f050 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap @@ -78,6 +78,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap index 38246f51553da6..eed6f0fba20579 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap @@ -66,6 +66,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -76,9 +77,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap index 9ea573657dae33..da6fdb72a6ddb0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap @@ -78,6 +78,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap index 8e25a9ff448b4a..084c2168e6a8cb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap @@ -83,6 +83,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -90,6 +92,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -338,6 +341,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_default_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_default_parameters.py.snap index 73de71b4d091ee..be2996d8ace0ca 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_default_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_default_parameters.py.snap @@ -36,6 +36,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -51,6 +53,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -76,6 +80,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -83,6 +89,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -99,6 +106,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap index b81032db425c6b..f44abf6dff0d40 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap @@ -36,6 +36,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -51,6 +53,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -58,6 +62,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -99,6 +104,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -117,11 +124,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -163,6 +173,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -178,6 +190,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -195,6 +209,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -236,6 +251,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -250,10 +267,13 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -295,6 +315,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -311,8 +333,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, ), body: NumberLiteral( @@ -329,6 +354,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap index 63a9049b312fda..53f578e796f934 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap @@ -49,6 +49,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -106,6 +108,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -149,6 +153,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -162,6 +168,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -210,6 +218,7 @@ Module( }, ), ], + runtime_elts: None, }, ), iter: Name( @@ -222,6 +231,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -273,6 +284,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -325,6 +338,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -375,6 +390,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -431,6 +448,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -438,6 +457,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -452,6 +472,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -534,14 +556,18 @@ Module( ), }, ], + runtime_values: None, }, ), ], ctx: Load, + runtime_elts: None, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -574,6 +600,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -601,6 +628,10 @@ Module( ), body: [], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), Expr( @@ -644,6 +675,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -671,6 +703,10 @@ Module( ), body: [], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), Expr( @@ -727,6 +763,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -788,6 +826,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -847,6 +887,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -912,6 +954,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -919,6 +963,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -933,6 +978,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1006,6 +1053,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1079,6 +1128,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1086,6 +1137,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap index 1129c6f661cbff..f5a0011be6862f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap @@ -29,11 +29,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap index 8ac3aa77ce3e34..8ed3312ef99cb5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap @@ -44,11 +44,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap index 347768333c58ef..5011545c94ebc3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap @@ -53,11 +53,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap index 1870af8aa0ab17..0ed2e8acf52595 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap @@ -39,6 +39,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -63,6 +64,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -73,9 +75,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap index 818809026883f5..574fa9d8e117a4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap @@ -29,6 +29,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -62,6 +63,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -86,6 +88,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -119,6 +122,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -152,6 +156,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -199,6 +204,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -232,6 +238,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -262,11 +269,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap index 6c0ebc0aa6b1cf..2b600b89809e9d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap @@ -44,6 +44,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -86,6 +87,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ctx: Load, @@ -101,6 +103,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -146,6 +149,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -186,6 +190,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -201,6 +206,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -241,6 +247,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -256,6 +263,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -315,6 +323,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -354,6 +363,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -361,6 +372,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -386,6 +398,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -439,11 +452,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap index a7ba61211f8afb..1dc3c831421f58 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap @@ -162,6 +162,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), value: List( @@ -189,6 +190,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -196,6 +198,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap index 80360bc64321d2..763170445a70e7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap @@ -25,6 +25,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap index 6adc7cf73868bb..40da172faddd9b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap @@ -39,6 +39,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap index 5a0d5690a69b3f..a47f5ea3956e6e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap @@ -59,6 +59,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -72,9 +74,11 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap index 56494fe2b3913c..04396d360723c8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap @@ -54,6 +54,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap index ee4effd12c812c..9e350aa0142086 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap @@ -68,6 +68,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap index 10b1f719faeb9a..f22d9e8250f3b8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap @@ -45,6 +45,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -72,9 +73,14 @@ Module( ), body: [], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap index be74ea3c8ab90e..e27cf853188ae7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap @@ -25,6 +25,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap index 53ae176db37118..89c867e25f2acc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap index 05c0bb17752e73..53daeeecb05fd9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap @@ -54,11 +54,13 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap index 24ae8dd4bb9e0f..38b6a70c0dc30b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap @@ -40,6 +40,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -64,6 +65,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -74,9 +76,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap index 9f0372217cb2ac..4ad25409ab9f42 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap @@ -61,6 +61,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap index 9aa45988b6c183..e81959f1c97b49 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap @@ -30,6 +30,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -64,6 +65,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -89,6 +91,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -147,6 +150,7 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), Expr( @@ -193,6 +197,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -272,11 +277,13 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap index 74b884afd02467..ffcab4dce9c382 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap @@ -48,6 +48,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ctx: Load, @@ -90,6 +91,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ctx: Load, @@ -98,6 +100,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -166,6 +169,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -206,6 +210,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -246,6 +251,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -254,6 +260,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -294,6 +301,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -334,6 +342,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -342,6 +351,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -438,6 +448,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -477,6 +488,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -484,6 +497,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -533,6 +547,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -540,6 +556,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -558,6 +575,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -642,6 +660,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -684,6 +703,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ctx: Load, @@ -726,6 +746,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ctx: Load, @@ -734,6 +755,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -802,6 +824,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -842,6 +865,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -882,6 +906,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -890,6 +915,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -930,6 +956,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -970,6 +997,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -978,6 +1006,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -1074,6 +1103,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -1113,6 +1143,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1120,6 +1152,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -1169,6 +1202,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1176,6 +1211,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -1194,6 +1230,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -1272,11 +1309,13 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap index fe53312824c591..7ecf8227e5af53 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap @@ -49,6 +49,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -106,6 +108,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -149,6 +153,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -162,6 +168,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -210,6 +218,7 @@ Module( }, ), ], + runtime_elts: None, }, ), iter: Name( @@ -222,6 +231,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -273,6 +284,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -325,6 +338,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -375,6 +390,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -431,6 +448,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -438,6 +457,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -452,6 +472,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -512,6 +534,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -573,6 +597,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -632,6 +658,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -697,6 +725,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -704,6 +734,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -718,6 +749,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -725,6 +758,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap index b520e3eea91dd9..c3f04d00c5eb60 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap @@ -28,11 +28,13 @@ Module( }, ), ], + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap index b746257d0b8017..bff106292258dd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap @@ -43,11 +43,13 @@ Module( }, ), ], + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap index ef03e861b0ad6d..fcf5a11bdeed9e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap @@ -52,11 +52,13 @@ Module( }, ), ], + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap index 0be8d06138c618..9cd61f1d9eaf0a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap @@ -38,6 +38,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -62,6 +63,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -72,9 +74,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap index 8954c554faa965..97fbfdad6a23ff 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap @@ -28,6 +28,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -60,6 +61,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -83,6 +85,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -115,6 +118,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -151,6 +155,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -197,6 +202,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -229,6 +235,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -259,11 +266,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap index 1c55b692ca9878..f64182c196fda5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap @@ -43,6 +43,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -85,6 +86,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ctx: Load, @@ -99,6 +101,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -143,6 +146,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -183,6 +187,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -197,6 +202,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -237,6 +243,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -251,6 +258,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -309,6 +317,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -348,6 +357,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -355,6 +366,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -379,6 +391,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -431,11 +444,13 @@ Module( }, ), ], + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap index 91295b506fd1b2..4b6bc2038c6de5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap @@ -283,6 +283,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap index bb210f7665b36a..0364937d6a21dd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap @@ -65,6 +65,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap index d3abfa92b13f31..ce7e92061d8bc3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap @@ -70,6 +70,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -83,9 +85,11 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap index 3510eb8a3cabca..2a953ead2a4a8a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap @@ -47,6 +47,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap index a410a5cb73abdd..b1d9de55a86912 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap @@ -83,6 +83,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap index b11ca386f946be..fa342a515a33bf 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap @@ -61,6 +61,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap index 48f2e1e00ffd45..db7b51e2a37842 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap @@ -61,6 +61,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap index c637ec5f6bdb62..04cd075c4e3a8a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap @@ -99,6 +99,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -107,6 +108,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap index 88317ef0ada798..7aec4c2dc78251 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap @@ -80,6 +80,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -96,6 +97,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -104,6 +106,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap index b8f1723b79245d..5cfa734325bd66 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap @@ -76,6 +76,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -83,6 +84,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap index 4ce09310632541..df2c7d670639a7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap @@ -77,6 +77,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -131,6 +132,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -139,6 +141,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -146,6 +149,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_conversion_follows_exclamation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_conversion_follows_exclamation.py.snap index cfc0f71585c3c5..8be51c4f0d1836 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_conversion_follows_exclamation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_conversion_follows_exclamation.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: Str, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -84,6 +89,9 @@ Module( debug_text: None, conversion: Str, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -96,6 +104,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -129,6 +139,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -141,11 +154,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap index ca7627f41653d1..da0a683b4796f4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -84,6 +89,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -96,11 +104,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_name_tok.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_name_tok.py.snap index c3947085864acc..57da1ff90707e3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_name_tok.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_name_tok.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,11 +54,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_other_tok.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_other_tok.py.snap index 7f84c5741142bd..735a4643b21830 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_other_tok.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_other_tok.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -84,6 +89,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -96,11 +104,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap index 7e39677f01b41e..1fa4777ce22beb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap @@ -46,6 +46,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -58,6 +61,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -107,6 +112,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -115,6 +121,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -127,6 +136,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -175,6 +186,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -187,11 +201,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap index fb719cc3b61acc..b39d15654ec359 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap @@ -50,6 +50,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -57,6 +59,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -72,6 +75,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -91,11 +97,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap index 841ef38fda3119..d7b8640bfcda9e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -84,6 +89,9 @@ Module( debug_text: None, conversion: Repr, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -96,6 +104,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -135,6 +145,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -147,6 +160,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -180,6 +195,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -192,6 +210,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -225,6 +245,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -237,11 +260,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap index a3fd18120935d4..90620942db665c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap @@ -52,6 +52,9 @@ Module( elements: [], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -64,6 +67,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -118,6 +123,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -130,11 +138,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_iter_unpack_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_iter_unpack_py38.py.snap index 01aa0c3e56e3fa..e682e6f34c80ff 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_iter_unpack_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_iter_unpack_py38.py.snap @@ -54,6 +54,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), body: [ @@ -71,6 +72,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -117,6 +122,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), body: [ @@ -134,6 +140,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -187,6 +197,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), body: [ @@ -204,9 +215,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_iter_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_iter_expr.py.snap index 3479a2f1cdfa87..36ccdbcd4f4b90 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_iter_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_iter_expr.py.snap @@ -50,6 +50,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -70,6 +71,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -116,6 +121,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -141,6 +150,10 @@ Module( ), body: [], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), AnnAssign( @@ -164,9 +177,11 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap index 8721f93a6d924c..6de3dd3656ed12 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap @@ -47,6 +47,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -98,6 +102,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -132,6 +140,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Store, @@ -160,6 +169,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -220,6 +233,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -264,6 +281,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -301,6 +322,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ), @@ -329,6 +351,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -398,6 +424,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ctx: Store, @@ -405,6 +432,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), iter: Name( @@ -430,9 +458,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap index 7205b06f038c9a..f14a69a4156281 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), iter: Name( @@ -65,6 +66,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -97,6 +102,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), iter: Name( @@ -122,6 +128,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -152,6 +162,7 @@ Module( }, ), ], + runtime_values: None, }, ), iter: Name( @@ -177,6 +188,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -222,6 +237,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -267,6 +286,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -320,9 +343,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap index b2ea34abc3584f..730d35f2e5843e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap @@ -56,10 +56,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -86,6 +89,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -122,6 +129,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), arguments: Arguments { @@ -129,6 +137,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -155,6 +165,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -187,6 +201,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), iter: Name( @@ -212,6 +227,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -249,6 +268,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), Name( @@ -262,6 +282,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), iter: Name( @@ -287,6 +308,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -324,6 +349,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), Name( @@ -336,6 +362,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), iter: Name( @@ -361,6 +388,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -398,6 +429,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), Name( @@ -409,6 +441,7 @@ Module( }, ), ], + runtime_elts: None, }, ), iter: Name( @@ -434,9 +467,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_in_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_in_keyword.py.snap index f7245cf40ddf45..db26cf72a549c2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_in_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_in_keyword.py.snap @@ -46,6 +46,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -84,9 +88,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_iter.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_iter.py.snap index f9640e450af6f9..32b2afb5276838 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_iter.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_iter.py.snap @@ -55,13 +55,21 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_target.py.snap index 184d01f31ca381..b0f9aa79376a78 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_target.py.snap @@ -46,9 +46,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_dotted_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_dotted_names.py.snap index e64b251ac4127d..789c0799239e0b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_dotted_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_dotted_names.py.snap @@ -35,6 +35,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -72,6 +73,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -159,9 +161,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_empty_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_empty_names.py.snap index 39401788860ca5..0cd4161ff65cd6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_empty_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_empty_names.py.snap @@ -24,6 +24,7 @@ Module( names: [], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -40,6 +41,7 @@ Module( names: [], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -56,9 +58,11 @@ Module( names: [], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_module.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_module.py.snap index 6dcd1dcea06644..5f34bd941cbc62 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_module.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_module.py.snap @@ -18,6 +18,7 @@ Module( names: [], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -39,9 +40,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_rpar.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_rpar.py.snap index eb355d62d856f7..b751f55e738d98 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_rpar.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_rpar.py.snap @@ -45,6 +45,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), Expr( @@ -113,6 +114,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), Expr( @@ -147,6 +149,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_parenthesized_star.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_parenthesized_star.py.snap index 4b7d807a7f9371..1f172cbb8b9b10 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_parenthesized_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_parenthesized_star.py.snap @@ -35,9 +35,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_star_with_other_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_star_with_other_names.py.snap index 57dc8ea3c4fc0d..ea9337bdaa1a2b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_star_with_other_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_star_with_other_names.py.snap @@ -45,6 +45,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -92,6 +93,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -135,6 +137,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -182,9 +185,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_unparenthesized_trailing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_unparenthesized_trailing_comma.py.snap index 996f94b7d1fb23..f96de9c325a5b8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_unparenthesized_trailing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_unparenthesized_trailing_comma.py.snap @@ -35,6 +35,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -68,6 +69,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -105,9 +107,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap index 151d9f4b392022..616fe16ffd626a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap @@ -30,9 +30,14 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -55,6 +60,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Name( @@ -67,6 +73,10 @@ Module( ), ), body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Assign( @@ -92,9 +102,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap index a807f4cf4fec4a..86c78504253d0b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Starred( @@ -62,6 +63,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -84,6 +89,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Starred( @@ -116,6 +122,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -138,6 +148,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Yield( @@ -171,9 +182,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_identifier.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_identifier.py.snap index 51228a1638111a..65fa7c58e6048a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_identifier.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_identifier.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -46,6 +47,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -68,6 +73,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Name( @@ -93,9 +99,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_return_type.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_return_type.py.snap index acfd61b9242fd8..4b282afab457af 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_return_type.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_return_type.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -46,9 +47,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap index 3cc076c88d1d6c..8de9aa7b5dc6fb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap @@ -48,6 +48,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -63,6 +65,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -70,9 +74,14 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -95,6 +104,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -116,6 +126,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -156,6 +170,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -180,6 +196,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -195,6 +213,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -212,12 +232,18 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap index dd2412c32a051a..27102d9e05c2f7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap @@ -52,6 +52,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -71,6 +72,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -86,6 +89,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -93,6 +98,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -128,6 +134,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Assign( @@ -153,9 +163,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unparenthesized_return_types.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unparenthesized_return_types.py.snap index e943085fc1dda5..67cd9df098b22d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unparenthesized_return_types.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unparenthesized_return_types.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Tuple( @@ -48,6 +49,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -65,6 +67,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -87,6 +93,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Tuple( @@ -113,6 +120,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -130,9 +138,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_type_params_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_type_params_py311.py.snap index 020e464de8cc24..769799bdd0c158 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_type_params_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_type_params_py311.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -50,6 +51,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -66,6 +68,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -84,6 +90,7 @@ Module( range: 69..71, node_index: NodeIndex(None), type_params: [], + runtime_type_params: None, }, ), parameters: Parameters { @@ -94,6 +101,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -110,9 +118,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_empty.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_empty.py.snap index 92375a3dfba725..bf9a95a1130a3e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_empty.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_empty.py.snap @@ -18,6 +18,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_expression.py.snap index 018d9049ee9b8d..708cc0eb9f0527 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_expression.py.snap @@ -46,6 +46,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_trailing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_trailing_comma.py.snap index 22cbfb00161e6e..4c57d4ab886ec2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_trailing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_trailing_comma.py.snap @@ -49,6 +49,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_missing_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_missing_colon.py.snap index 4238e23e7a21c9..a3553f96574921 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_missing_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_missing_colon.py.snap @@ -52,6 +52,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ElifElseClause { range: 31..45, @@ -65,11 +67,15 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap index ad3fe7c4ca1236..0df7acba7d3559 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap @@ -23,6 +23,7 @@ Module( ), body: [], elif_else_clauses: [], + runtime_body: None, }, ), Expr( @@ -57,6 +58,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap index 356e404b045861..cbf69b260cd7ac 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap @@ -59,6 +59,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ElifElseClause { range: 33..55, @@ -89,11 +91,15 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap index 1840201849a752..dd0865ba44bb95 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap @@ -44,6 +44,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -81,6 +82,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -116,9 +118,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap index 5dc30d6ce6f8e8..3f20fe86301d16 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap @@ -24,6 +24,7 @@ Module( ), body: [], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -47,6 +48,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Assign( @@ -72,9 +74,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_test.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_test.py.snap index f0f87f8a4fa3e4..00631867e2abf7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_test.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_test.py.snap @@ -37,9 +37,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` 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 3a360a80665dd5..8af41bdaf979dd 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 @@ -30,6 +30,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), AnnAssign( @@ -54,6 +55,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), Pass( @@ -69,6 +71,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap index 7dd649dafd015d..f7a8949678bc65 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap @@ -135,6 +135,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -149,6 +152,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -185,6 +190,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap index 6d6ae6f83c4c40..dc1fd69e155731 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap @@ -61,6 +61,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -75,6 +78,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -171,6 +176,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -207,6 +214,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_missing_asname.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_missing_asname.py.snap index 47f3fd931108c3..e0b748fdf0200f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_missing_asname.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_missing_asname.py.snap @@ -30,6 +30,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_from_star.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_from_star.py.snap index c2e12781c9a3dc..e2e3063cc89537 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_from_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_from_star.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -58,9 +59,14 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -101,9 +107,12 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), FunctionDef( @@ -126,6 +135,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -154,9 +164,14 @@ Module( ], level: 2, is_lazy: false, + runtime_level: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -179,6 +194,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -217,12 +233,18 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_empty.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_empty.py.snap index 6f254cafc4e38f..a2986b03b85202 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_empty.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_empty.py.snap @@ -19,6 +19,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap index e4acf74b900261..d3512f493acb9f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap @@ -68,11 +68,13 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_star_import.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_star_import.py.snap index 78b584adc6b7b9..449b7354d91f15 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_star_import.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_star_import.py.snap @@ -93,11 +93,13 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_trailing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_trailing_comma.py.snap index 37a98420278ade..98464ff72d7cde 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_trailing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_trailing_comma.py.snap @@ -48,6 +48,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@incomplete_attribute_before_for_in_delimiter.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@incomplete_attribute_before_for_in_delimiter.py.snap index b59353d9aec69a..6525227c6105fc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@incomplete_attribute_before_for_in_delimiter.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@incomplete_attribute_before_for_in_delimiter.py.snap @@ -60,6 +60,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -116,6 +118,8 @@ Module( ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -172,6 +176,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -228,6 +234,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -285,6 +293,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -339,9 +349,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_class.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_class.py.snap index 9876d8216bd7ab..c83bd1e180f0a6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_class.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_class.py.snap @@ -39,6 +39,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -70,6 +71,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -86,6 +89,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -117,6 +122,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -143,6 +149,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -159,6 +167,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -190,6 +200,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -214,6 +225,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -230,6 +243,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -279,6 +294,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -296,6 +312,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -351,6 +369,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -368,6 +387,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -399,6 +420,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -423,6 +445,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -439,6 +463,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -486,6 +512,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -503,9 +530,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_function.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_function.py.snap index 9ca7f7bbefb41f..a795982388895c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_function.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_function.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -50,6 +51,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Await( @@ -82,6 +84,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -114,6 +120,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -149,6 +156,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -156,6 +165,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -172,6 +182,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -204,6 +218,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -214,6 +229,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Named( @@ -254,6 +270,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -286,6 +306,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -329,6 +350,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -336,6 +359,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -352,6 +376,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -384,6 +412,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -421,6 +450,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -428,6 +459,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -444,6 +476,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -476,6 +512,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -486,6 +523,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Yield( @@ -520,6 +558,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -552,6 +594,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -587,6 +630,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -594,6 +639,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -610,6 +656,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -642,6 +692,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -652,6 +703,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( YieldFrom( @@ -684,6 +736,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -734,6 +790,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -744,6 +801,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -760,6 +818,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -810,6 +872,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -820,6 +883,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -836,6 +900,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -885,6 +953,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -895,6 +964,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -911,6 +981,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -960,6 +1034,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -970,6 +1045,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -986,6 +1062,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1042,6 +1122,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -1052,6 +1133,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1068,6 +1150,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1124,6 +1210,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -1134,6 +1221,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1150,6 +1238,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1205,6 +1297,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -1215,6 +1308,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1231,6 +1325,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1286,6 +1384,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -1296,6 +1395,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1312,6 +1412,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1360,6 +1464,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -1370,6 +1475,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1386,6 +1492,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1434,6 +1544,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -1444,6 +1555,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1460,6 +1572,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1507,6 +1623,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -1517,6 +1634,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1533,6 +1651,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1580,6 +1702,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -1590,6 +1713,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1606,9 +1730,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_function_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_function_py314.py.snap index ddf812502d5e3e..0a8f73c502893f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_function_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_function_py314.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Named( @@ -70,6 +71,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -125,6 +130,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -132,6 +139,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -148,6 +156,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -170,6 +182,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -220,6 +233,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -227,6 +242,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -243,6 +259,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -265,6 +285,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Yield( @@ -299,6 +320,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -346,6 +371,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -353,6 +380,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -369,6 +397,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -391,6 +423,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( YieldFrom( @@ -423,9 +456,17 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -448,6 +489,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -471,6 +513,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Await( @@ -503,6 +546,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -550,6 +597,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -557,6 +606,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -573,12 +623,21 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_py314.py.snap index 80f657c1339471..99d0352f991d20 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_py314.py.snap @@ -47,6 +47,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), FunctionDef( @@ -69,6 +70,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -103,6 +105,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -134,9 +137,14 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -159,6 +167,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -191,12 +200,18 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_type_alias.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_type_alias.py.snap index a0174091277bdc..e1ec90612d01ad 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_type_alias.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_annotation_type_alias.py.snap @@ -59,6 +59,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -120,6 +121,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -180,6 +182,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -240,6 +243,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -369,6 +373,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -412,6 +417,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_byte_literal.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_byte_literal.py.snap index 0de2a88389a014..e070f35d212154 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_byte_literal.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_byte_literal.py.snap @@ -94,6 +94,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap index cc7fbd303af659..37661615d93b8e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Delete( @@ -87,9 +88,11 @@ Module( ), }, ], + runtime_values: None, }, ), ], + runtime_targets: None, }, ), Delete( @@ -145,9 +148,11 @@ Module( }, ), ], + runtime_elts: None, }, ), ], + runtime_targets: None, }, ), Delete( @@ -215,9 +220,11 @@ Module( }, ), ], + runtime_targets: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap index 694d74acb2c1c6..1169358a32b9ba 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap @@ -41,6 +41,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -76,11 +78,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_future_feature.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_future_feature.py.snap index 121735f806bc5e..ab97d139f6aaf8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_future_feature.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_future_feature.py.snap @@ -35,6 +35,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -72,6 +73,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -109,9 +111,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_match_pattern_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_match_pattern_target.py.snap index 9d06603076c33b..a23c2cda3e836f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_match_pattern_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_match_pattern_target.py.snap @@ -71,6 +71,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 38..53, @@ -88,6 +89,8 @@ Module( node_index: NodeIndex(None), }, ), + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -105,6 +108,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -132,9 +136,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap index 4d20a344387111..7dadbed0e24cd7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap @@ -65,6 +65,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap index 6f812719739d07..8bbfab3a506cb3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap @@ -44,6 +44,9 @@ Module( }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), IpyEscapeCommand( @@ -55,6 +58,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap index 4f1baa69a7c8d8..a0af89f0ce14f9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap @@ -43,15 +43,20 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap index 33079dbc605f33..f29cf1cb4b7f4e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap @@ -44,6 +44,9 @@ Module( }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), IpyEscapeCommand( @@ -77,9 +80,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@irrefutable_case_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@irrefutable_case_pattern.py.snap index e92cdb2db1729d..b89ac0be8e0dc4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@irrefutable_case_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@irrefutable_case_pattern.py.snap @@ -55,6 +55,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 50..61, @@ -89,6 +90,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -132,6 +134,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 91..102, @@ -166,6 +169,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -230,6 +234,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 211..222, @@ -264,6 +269,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -330,6 +336,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -347,6 +354,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 305..316, @@ -381,11 +389,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_return_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_return_py37.py.snap index 34d46e2a2bb657..e520c2776ce8a0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_return_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_return_py37.py.snap @@ -59,8 +59,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), FunctionDef( @@ -83,6 +87,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -141,15 +146,21 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_yield_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_yield_py37.py.snap index 4110c28f156e94..2d2bc7bf1078b9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_yield_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_yield_py37.py.snap @@ -59,8 +59,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), FunctionDef( @@ -83,6 +87,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -145,6 +150,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -153,6 +159,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -175,6 +185,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -238,6 +249,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -255,6 +267,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -263,9 +276,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap index c06d9a8abc2b76..d2ae6b53889d23 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap @@ -36,6 +36,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -43,6 +45,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Starred( @@ -95,6 +98,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -102,6 +107,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Starred( @@ -124,6 +130,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -159,6 +166,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -166,6 +175,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Starred( @@ -196,6 +206,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -226,6 +237,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -233,6 +246,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Starred( @@ -262,6 +276,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -272,6 +287,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_yield_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_yield_expr.py.snap index d21b80f6d6c890..6b3908dd8e925c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_yield_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_yield_expr.py.snap @@ -36,6 +36,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -43,6 +45,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Yield( @@ -91,6 +94,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -98,6 +103,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: YieldFrom( @@ -119,6 +125,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_invalid_context_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_invalid_context_py315.py.snap index 67abc8a22c3629..e8ea737af40fc2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_invalid_context_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_invalid_context_py315.py.snap @@ -50,12 +50,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -115,12 +120,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), FunctionDef( @@ -143,6 +153,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -166,6 +177,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -188,6 +203,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -216,9 +232,14 @@ Module( ], level: 0, is_lazy: true, + runtime_level: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -254,6 +275,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), FunctionDef( @@ -276,6 +299,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -312,12 +336,19 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_invalid_from_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_invalid_from_py315.py.snap index 3e7266d9186338..b9d98919a8839d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_invalid_from_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_invalid_from_py315.py.snap @@ -35,6 +35,7 @@ Module( ], level: 0, is_lazy: true, + runtime_level: None, }, ), ImportFrom( @@ -62,6 +63,7 @@ Module( ], level: 0, is_lazy: true, + runtime_level: None, }, ), FunctionDef( @@ -84,6 +86,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -112,12 +115,18 @@ Module( ], level: 0, is_lazy: true, + runtime_level: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_stmt_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_stmt_py314.py.snap index 14f80ce4ad9a01..19f0052bca8cd3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_stmt_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_stmt_py314.py.snap @@ -54,9 +54,11 @@ Module( ], level: 0, is_lazy: true, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_before_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_before_py310.py.snap index 391c87863e4618..5b99c1ef55771e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_before_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_before_py310.py.snap @@ -51,11 +51,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword.py.snap index 47f410992c2b64..4d6cc7a2164066 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword.py.snap @@ -57,11 +57,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap index 4696b90ac23f7e..19cfcc59502d34 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap @@ -56,11 +56,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_expected_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_expected_colon.py.snap index da778df7a108e7..a5de0429cd3b10 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_expected_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_expected_colon.py.snap @@ -39,6 +39,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), cases: [ @@ -68,11 +69,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap index f8ff37f51a06f7..224a2f0eb0422e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap @@ -49,11 +49,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` 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 561ee48a269582..b703e2a0e47139 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 @@ -48,6 +48,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Match( @@ -104,11 +107,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap index 5ae960f29c5bed..4c95faa939993f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap @@ -71,6 +71,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -136,6 +137,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -202,11 +204,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap index 537bf08d6bdbce..4bcf6b2ae0f521 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap @@ -56,6 +56,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -96,6 +97,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -112,6 +114,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), cases: [ @@ -141,6 +144,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -192,11 +196,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_guard_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_guard_expr.py.snap index 880d99610c296e..1811e4ac029f3c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_guard_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_guard_expr.py.snap @@ -55,11 +55,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_pattern.py.snap index 17247bca62985f..21ad0c756fccba 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_pattern.py.snap @@ -55,11 +55,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap index 7d49a7f558ec69..351ea8f58f296f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap @@ -49,11 +49,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap index 67fa5c7067ca32..77e685967e0de9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap @@ -56,11 +56,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_bytes_and_non_bytes_literals.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_bytes_and_non_bytes_literals.py.snap index 829f518bed2971..684f44de2adb07 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_bytes_and_non_bytes_literals.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_bytes_and_non_bytes_literals.py.snap @@ -101,6 +101,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -166,11 +168,14 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_tstring_and_bytes_literals.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_tstring_and_bytes_literals.py.snap index 517a7974527d2c..75cc2961841fa0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_tstring_and_bytes_literals.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_tstring_and_bytes_literals.py.snap @@ -50,6 +50,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -94,6 +96,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -138,6 +142,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -195,6 +201,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -252,6 +260,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -322,6 +332,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -387,11 +399,14 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_assignment_in_case_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_assignment_in_case_pattern.py.snap index 234f5001e0f5f4..8b68ba496672ba 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_assignment_in_case_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_assignment_in_case_pattern.py.snap @@ -75,6 +75,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -92,6 +93,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 54..74, @@ -143,6 +145,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -160,6 +163,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 96..115, @@ -212,6 +216,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -229,6 +234,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 146..168, @@ -288,6 +294,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -305,6 +313,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 207..228, @@ -347,6 +356,8 @@ Module( node_index: NodeIndex(None), }, ), + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -364,6 +375,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 269..290, @@ -415,6 +427,9 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -432,6 +447,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 320..345, @@ -501,6 +517,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -518,6 +537,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 372..412, @@ -547,6 +567,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchMapping( @@ -581,6 +602,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchClass( @@ -648,9 +671,13 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -668,6 +695,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 428..444, @@ -716,11 +744,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_clauses_on_same_line.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_clauses_on_same_line.py.snap index cd8e98be1cee8c..cfbcd7ca1904ed 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_clauses_on_same_line.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_clauses_on_same_line.py.snap @@ -50,6 +50,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ElifElseClause { range: 31..41, @@ -63,8 +65,11 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), If( @@ -107,6 +112,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ElifElseClause { range: 75..85, @@ -120,8 +127,11 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), For( @@ -161,6 +171,10 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -200,6 +214,10 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), Try( @@ -238,6 +256,7 @@ Module( }, ), ], + runtime_body: None, }, ), ], @@ -258,6 +277,10 @@ Module( ), ], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -296,6 +319,7 @@ Module( }, ), ], + runtime_body: None, }, ), ], @@ -316,9 +340,14 @@ Module( ), ], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_starred_assignment_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_starred_assignment_target.py.snap index fe2d8393ce51ab..15ec9ccafcf479 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_starred_assignment_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_starred_assignment_target.py.snap @@ -53,6 +53,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -82,8 +83,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -128,6 +133,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], @@ -157,8 +163,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -212,6 +222,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -250,8 +261,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -304,6 +319,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], @@ -342,8 +358,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -424,11 +444,13 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -458,11 +480,16 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_starred_names_in_sequence_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_starred_names_in_sequence_pattern.py.snap index c289a7895a5713..9587ad07c777db 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_starred_names_in_sequence_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_starred_names_in_sequence_pattern.py.snap @@ -71,6 +71,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -88,11 +89,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap index 961dcf36e150ce..857c1506f2a379 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap @@ -220,6 +220,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice_parse_error.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice_parse_error.py.snap index 34c884074894ad..ee314ad800c151 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice_parse_error.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice_parse_error.py.snap @@ -82,6 +82,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_async_comprehension_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_async_comprehension_py310.py.snap index ff285092c21185..50752b47593aed 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_async_comprehension_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_async_comprehension_py310.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -92,11 +93,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -140,11 +145,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -153,6 +162,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -175,6 +188,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -248,11 +262,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -296,11 +314,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -309,6 +331,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -331,6 +357,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -393,11 +420,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -441,11 +472,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -454,6 +489,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -476,6 +515,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -544,11 +584,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -604,11 +648,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -616,6 +664,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), generators: [ @@ -657,11 +706,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -670,6 +723,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -692,6 +749,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -760,11 +818,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -820,11 +882,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -832,6 +898,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), generators: [ @@ -873,11 +940,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -886,9 +957,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap index 187240a204f323..10a79a047d5b7b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap @@ -48,6 +48,9 @@ Module( elements: [], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -75,11 +78,14 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap index a71728ff9d61cf..2b0126feb98d0b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap @@ -30,9 +30,14 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -55,6 +60,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -71,6 +77,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -93,12 +103,18 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_declaration_at_module_level.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_declaration_at_module_level.py.snap index 5f81d3505db579..6fe3afa4481e5e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_declaration_at_module_level.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_declaration_at_module_level.py.snap @@ -42,6 +42,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_empty.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_empty.py.snap index cba504e096f0e1..e84c7c699b9e7a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_empty.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_empty.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -41,9 +42,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_expression.py.snap index ae92fb5c2b1f60..f86a3f496439bc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_expression.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -69,9 +70,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_trailing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_trailing_comma.py.snap index 5060d24003b38c..5c1d8eb4ee1c66 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_trailing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_trailing_comma.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -72,9 +73,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_annotation.py.snap index 97f376531396e5..aac0e2c33b0463 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_annotation.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -46,6 +48,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -62,6 +65,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -93,6 +100,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -100,6 +109,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -116,9 +126,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap index 677e725f3ad368..9d9f1f2f783ed6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -46,6 +48,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -62,6 +65,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -102,6 +109,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -109,6 +118,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -125,9 +135,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap index b81e6a9903bed5..ecb74d5dd83b7d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap @@ -55,6 +55,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -62,6 +64,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -78,6 +81,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -126,6 +133,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -133,6 +142,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -149,6 +159,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -189,6 +203,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -204,6 +220,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -211,6 +229,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -227,9 +246,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap index 461ef54faab205..d75d2635ba3eb0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( Starred( @@ -62,6 +64,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -78,6 +81,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -109,6 +116,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( Starred( @@ -132,6 +141,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -148,6 +158,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -179,6 +193,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( Yield( @@ -203,6 +219,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -219,9 +236,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap index c8ace07b1fba3f..5f936bc6da220e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap @@ -53,10 +53,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -73,6 +76,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -133,10 +140,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -153,6 +163,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -209,16 +223,20 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -235,6 +253,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -288,10 +310,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -308,9 +333,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_star_annotation_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_star_annotation_py310.py.snap index 20e6c382e4c928..353def8ade66ab 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_star_annotation_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_star_annotation_py310.py.snap @@ -53,10 +53,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -73,9 +76,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_duplicate_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_duplicate_names.py.snap index cf8ca302d41f0c..763683219303b3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_duplicate_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_duplicate_names.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -54,6 +56,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -78,6 +82,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -93,6 +99,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -117,6 +125,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -131,8 +141,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -149,9 +162,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap index 3a61d03ad026e4..8d801462efec94 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -46,6 +47,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -68,6 +73,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -84,6 +90,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -115,6 +125,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -122,6 +134,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -138,6 +151,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -169,6 +186,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -176,6 +195,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -192,6 +212,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -223,8 +247,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -241,9 +268,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_follows_var_keyword_param.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_follows_var_keyword_param.py.snap index f643b398d07345..b3e3d9cea03afc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_follows_var_keyword_param.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_follows_var_keyword_param.py.snap @@ -38,6 +38,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -55,6 +57,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -79,6 +83,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], @@ -92,8 +98,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -110,9 +119,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap index 3c76f98da42b55..5f34b03a915a10 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap @@ -39,8 +39,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -57,9 +60,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_kwargs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_kwargs.py.snap index b5c0c9d0aacad2..dade5a383d2377 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_kwargs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_kwargs.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -55,8 +57,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -73,9 +78,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_slash_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_slash_separator.py.snap index 8fe7404b2345a2..b9f8edb1f52574 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_slash_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_slash_separator.py.snap @@ -38,6 +38,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -55,6 +57,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -62,6 +66,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -78,6 +83,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -108,6 +117,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -125,6 +136,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -140,6 +153,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -147,6 +162,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -163,9 +179,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap index 642996446c7b59..82329a8d652109 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -57,11 +59,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -78,6 +83,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -109,6 +118,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -127,6 +138,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -142,11 +155,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -163,9 +179,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap index a60de5d69e42ed..900fd154b06a78 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -53,6 +55,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -68,11 +72,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -89,6 +96,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -120,6 +131,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -134,6 +147,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -149,11 +164,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -170,6 +188,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -201,6 +223,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -215,6 +239,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -230,6 +256,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -245,11 +273,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -266,9 +297,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_no_arg_before_slash.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_no_arg_before_slash.py.snap index f3fc1117e0011d..a0f59c4fd8ca9c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_no_arg_before_slash.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_no_arg_before_slash.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -46,6 +47,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -77,6 +82,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -84,6 +91,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -100,9 +108,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_non_default_after_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_non_default_after_default.py.snap index 6dfcec4878927c..78d1c46a7121ec 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_non_default_after_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_non_default_after_default.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -64,6 +66,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -88,6 +92,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -95,6 +101,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -111,9 +118,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash.py.snap index 485d7d49babb5b..44244c86bd7043 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash.py.snap @@ -37,10 +37,13 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -57,6 +60,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -87,6 +94,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -102,6 +111,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -117,11 +128,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -138,6 +152,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -168,6 +186,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -187,11 +207,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -208,6 +231,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -238,6 +265,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -257,6 +286,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -272,6 +303,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -287,11 +320,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -308,9 +344,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap index 6a75f864f722b3..0785b1d74cb745 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -53,6 +55,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -68,11 +72,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -89,6 +96,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -120,6 +131,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -134,6 +147,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -149,6 +164,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -164,11 +181,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -185,9 +205,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap index 6a172bd47cb8c6..6b3a911b9f407e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -55,8 +57,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -138,11 +143,16 @@ Module( ), }, ], + runtime_values: None, }, ), }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -158,6 +168,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap index 076fbfe23bf1e6..fb48e19b0faa52 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -53,10 +55,13 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -90,11 +95,16 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -110,6 +120,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_context_manager_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_context_manager_py38.py.snap index 3185cb6e3246f3..8dd3613320e5be 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_context_manager_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_context_manager_py38.py.snap @@ -75,6 +75,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -133,6 +136,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -191,9 +197,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap index 6a2b1560fd23e5..ee66a16af15c1d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap @@ -52,6 +52,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -99,6 +101,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -146,12 +150,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_f_string_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_f_string_py311.py.snap index c148b9af9aa28c..46fd9495bab6d6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_f_string_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_f_string_py311.py.snap @@ -74,6 +74,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -86,6 +89,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -159,12 +164,17 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -177,6 +187,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -245,6 +257,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -257,6 +272,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -377,6 +394,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -389,11 +409,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -406,11 +431,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -423,11 +453,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -440,11 +475,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -457,11 +497,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -474,6 +519,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -534,6 +581,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -553,11 +603,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -577,6 +632,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -611,6 +668,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -623,6 +683,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -663,6 +725,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -682,6 +747,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -729,6 +796,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -741,11 +811,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -758,6 +833,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -891,16 +968,22 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -913,11 +996,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_nested_interpolation_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_nested_interpolation_py311.py.snap index f1fb788308f605..a76779f70588c7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_nested_interpolation_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_nested_interpolation_py311.py.snap @@ -79,6 +79,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -91,6 +94,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -103,6 +109,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -176,6 +184,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -188,6 +199,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -200,11 +214,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap index cf6a44043bf19b..bb9346329d8bf4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap @@ -71,6 +71,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -83,6 +84,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -150,6 +153,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -162,6 +166,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -222,6 +228,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -234,6 +241,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -294,6 +303,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -306,6 +316,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -313,6 +325,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_unpacking_comprehensions_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_unpacking_comprehensions_py314.py.snap index 86297c504ceae2..685b5d10c7fddf 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_unpacking_comprehensions_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_unpacking_comprehensions_py314.py.snap @@ -55,6 +55,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -106,6 +108,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -151,6 +155,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -202,6 +208,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -270,6 +278,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -277,12 +287,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pos_only_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pos_only_py37.py.snap index 5a0accedf73167..bcd4fdc4ac4a9e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pos_only_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pos_only_py37.py.snap @@ -38,6 +38,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -46,6 +48,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -62,6 +65,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -92,6 +99,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -109,6 +118,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -116,6 +127,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -132,6 +144,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -162,6 +178,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -177,6 +195,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -192,11 +212,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -213,6 +236,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -244,6 +271,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -251,6 +280,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -267,9 +297,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_from_without_exc.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_from_without_exc.py.snap index a26ddcf6ec9286..25dbed536eb8f5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_from_without_exc.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_from_without_exc.py.snap @@ -43,6 +43,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap index 5554450d32949d..0004e204f3df51 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap @@ -119,6 +119,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap index 02dab5618e6f20..c8bd421fae5eb4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap @@ -92,6 +92,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_cause.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_cause.py.snap index 8920563325fa72..4b6c7c78664a9f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_cause.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_cause.py.snap @@ -41,6 +41,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -85,12 +86,14 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_exc.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_exc.py.snap index 249774dde9e13c..0a0e28b80d6e5a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_exc.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_exc.py.snap @@ -31,6 +31,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -66,6 +67,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -101,6 +103,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -117,6 +120,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap index 7b40d0956e6244..867b19667e5671 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap @@ -40,11 +40,14 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), body: [], elif_else_clauses: [], + runtime_body: None, }, ), FunctionDef( @@ -67,6 +70,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -77,6 +81,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), If( @@ -109,6 +117,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -133,6 +143,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -143,10 +154,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -179,6 +195,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -203,6 +221,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -213,10 +232,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -249,6 +273,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -273,6 +299,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -283,10 +310,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -340,10 +372,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -368,6 +403,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -378,10 +414,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -435,10 +476,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -463,6 +507,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -473,10 +518,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -530,10 +580,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -558,6 +611,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -568,10 +622,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -626,6 +685,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -638,10 +700,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -666,6 +732,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -676,10 +743,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -729,15 +801,20 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), body: [], elif_else_clauses: [], + runtime_body: None, }, ), FunctionDef( @@ -760,6 +837,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -770,9 +848,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap index 11e80e4bd94e61..f36dc38c283c4e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap @@ -61,10 +61,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -89,6 +92,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -99,13 +103,19 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` 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 692755d4e89bc8..7c76ad9460d286 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 @@ -61,10 +61,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -89,6 +92,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -99,13 +103,19 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` 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 cbe3c0bda19f9b..20aee3537321f9 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 @@ -73,6 +73,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -85,6 +88,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -207,6 +212,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -219,6 +227,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -313,6 +323,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -325,6 +338,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -385,6 +400,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap index 21f4465c4e8d5e..6a79b668c85b17 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap @@ -48,6 +48,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -73,6 +75,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -83,9 +86,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` 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 cde70bca42cd0d..0c3a297dc330d7 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 @@ -48,6 +48,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -73,6 +75,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -83,9 +86,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap index 26717caf11fc60..9d4c2018c57d7f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap @@ -46,6 +46,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -58,11 +61,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap index aa513e839628ee..ac68f7b38e14f4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap @@ -53,6 +53,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -65,11 +68,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap index afc38b5b29537a..8cd206b47205ee 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap @@ -69,6 +69,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -81,10 +84,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -97,9 +104,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap index 0b514de1ea2ae9..8445afab405776 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap @@ -80,6 +80,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -92,6 +95,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), slice: Slice( @@ -132,19 +137,24 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), simple: false, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@rebound_comprehension_variable.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@rebound_comprehension_variable.py.snap index 932b4f7ac26bfe..e5b0ee22608102 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@rebound_comprehension_variable.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@rebound_comprehension_variable.py.snap @@ -80,11 +80,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -161,11 +165,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -252,11 +260,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -343,11 +355,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -424,11 +440,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -474,6 +494,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), generators: [ @@ -515,11 +536,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -596,11 +621,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 215..232, @@ -640,11 +669,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -721,11 +754,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 263..280, @@ -765,11 +802,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -838,6 +879,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), generators: [ @@ -879,11 +921,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 323..340, @@ -923,11 +969,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -935,6 +985,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@return_stmt_invalid_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@return_stmt_invalid_expr.py.snap index d00b8aadbf4c99..21b18794d6d674 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@return_stmt_invalid_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@return_stmt_invalid_expr.py.snap @@ -142,6 +142,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -151,6 +152,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@signed_pattern_non_literal_operand.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@signed_pattern_non_literal_operand.py.snap index b438b89b463336..e28ab89d2ec62b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@signed_pattern_non_literal_operand.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@signed_pattern_non_literal_operand.py.snap @@ -79,6 +79,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 81..99, @@ -132,6 +133,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 104..119, @@ -189,6 +191,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 124..138, @@ -220,6 +223,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -242,6 +247,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 143..163, @@ -295,6 +301,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -312,11 +320,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line.py.snap index c7203ece654ae4..ebcc879bdb24e2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line.py.snap @@ -59,9 +59,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line_in_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line_in_block.py.snap index 8ca5568f51cfc7..6b363da4909e4c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line_in_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line_in_block.py.snap @@ -30,6 +30,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -52,6 +53,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -74,6 +76,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -96,9 +99,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line.py.snap index 4a6746ba538bac..81ed3b3b79d332 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line.py.snap @@ -127,6 +127,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line_in_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line_in_block.py.snap index 9f757bf464c5b2..dc6ac8fdac2dfc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line_in_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line_in_block.py.snap @@ -54,9 +54,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_for.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_for.py.snap index f1a7ec5d751985..e73ed970d69284 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_for.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_for.py.snap @@ -53,6 +53,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -98,9 +102,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_return.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_return.py.snap index 46af64432464cd..0ecf706fe7477f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_return.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_return.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -57,9 +58,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_yield.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_yield.py.snap index e95f6482b7998a..d961302d804e33 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_yield.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_yield.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -63,9 +64,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_starred_assignment_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_starred_assignment_target.py.snap index 93661f3f07564c..1dff2ae692775f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_starred_assignment_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_starred_assignment_target.py.snap @@ -48,11 +48,16 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_index_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_index_py310.py.snap index c10eb737d2e3c1..cbc20af3501c7d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_index_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_index_py310.py.snap @@ -49,6 +49,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -115,6 +116,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -122,6 +124,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -138,6 +142,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), Expr( @@ -195,6 +201,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -257,6 +264,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -318,6 +326,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -393,6 +402,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -401,6 +411,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap index 48d71c4c722c98..bca9fc105705e4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap @@ -73,6 +73,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_comprehension_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_comprehension_target.py.snap index bf5f2b33ebe434..761bbd7784a24c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_comprehension_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_comprehension_target.py.snap @@ -55,6 +55,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -62,6 +64,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_list_comp_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_list_comp_py314.py.snap index e567871623993b..c790e4ca93584e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_list_comp_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_list_comp_py314.py.snap @@ -55,6 +55,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -62,6 +64,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap index 5e7b922cfabd74..19ceddd7b52e1c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap @@ -44,6 +44,7 @@ Module( range: 9..11, elts: [], ctx: Load, + runtime_elts: None, }, ), ctx: Load, @@ -54,6 +55,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -93,6 +96,7 @@ Module( range: 22..24, elts: [], ctx: Load, + runtime_elts: None, }, ), ctx: Load, @@ -103,12 +107,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap index 0b2e6cb57b5377..ae49cdad1e0c8e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap @@ -53,6 +53,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -63,6 +64,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -79,6 +81,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -124,6 +130,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -134,6 +141,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -150,6 +158,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -195,6 +207,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -205,6 +218,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -221,6 +235,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -253,6 +271,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -263,6 +282,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -279,6 +299,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -311,6 +335,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -321,6 +346,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -340,6 +366,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), AnnAssign( @@ -353,6 +383,7 @@ Module( elts: [], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), annotation: EllipsisLiteral( @@ -363,9 +394,11 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap index a7555f2ebf6625..bb6b49885b8bb4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap @@ -23,6 +23,7 @@ Module( ), body: [], elif_else_clauses: [], + runtime_body: None, }, ), Pass( @@ -32,6 +33,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` 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 b469e7418a1c73..fc62c64abc4d62 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 @@ -65,6 +65,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Assign( @@ -90,6 +91,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), If( @@ -162,6 +166,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Expr( @@ -233,6 +238,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Expr( @@ -265,6 +271,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Expr( @@ -365,6 +372,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Expr( @@ -428,6 +436,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -449,6 +459,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Expr( @@ -507,9 +518,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap index e0f68d802b44c5..37feba6153ab1d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap @@ -34,6 +34,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), AugAssign( @@ -94,6 +97,7 @@ Module( ), ), simple: false, + runtime_simple: None, }, ), Assign( @@ -124,6 +128,7 @@ Module( }, ), ], + runtime_values: None, }, ), ], @@ -136,6 +141,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -176,6 +184,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -216,6 +227,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -248,6 +262,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -277,6 +294,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -284,6 +303,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -307,6 +327,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -354,6 +377,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -401,6 +427,7 @@ Module( ), }, ], + runtime_values: None, }, ), ], @@ -413,6 +440,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -434,6 +464,7 @@ Module( }, ), ], + runtime_elts: None, }, ), ], @@ -446,6 +477,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -487,6 +521,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -501,6 +537,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -542,6 +581,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -556,6 +597,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -623,6 +667,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -637,6 +683,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -678,6 +727,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -693,6 +744,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -724,6 +778,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -757,6 +814,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -788,6 +848,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -829,6 +892,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], @@ -841,6 +905,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -865,6 +932,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -878,6 +947,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -910,6 +982,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -922,6 +997,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ], @@ -934,6 +1011,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -966,6 +1046,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -990,6 +1073,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1002,6 +1088,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ], @@ -1014,6 +1102,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1052,6 +1143,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1094,6 +1188,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1120,6 +1217,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1144,6 +1244,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1167,6 +1270,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1190,6 +1296,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1218,6 +1327,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1234,6 +1345,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1271,6 +1385,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1284,6 +1400,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], @@ -1321,8 +1438,12 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1358,6 +1479,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), List( @@ -1381,10 +1503,12 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], ctx: Store, + runtime_elts: None, }, ), Name( @@ -1397,6 +1521,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], @@ -1430,6 +1555,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), List( @@ -1453,10 +1579,12 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], ctx: Load, + runtime_elts: None, }, ), NumberLiteral( @@ -1470,8 +1598,12 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1509,6 +1641,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1523,6 +1657,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -1561,11 +1696,16 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap index bee95541adc69a..4e29acdc0ff81c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap @@ -37,6 +37,7 @@ Module( }, ), ], + runtime_values: None, }, ), op: Add, @@ -186,6 +187,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -193,6 +196,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -308,6 +312,7 @@ Module( ), }, ], + runtime_values: None, }, ), op: Add, @@ -340,6 +345,7 @@ Module( }, ), ], + runtime_elts: None, }, ), op: Add, @@ -392,6 +398,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -446,6 +454,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -526,6 +536,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -580,6 +592,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -727,6 +741,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), op: Add, @@ -762,6 +777,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -806,6 +823,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -818,6 +838,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), op: Add, @@ -861,6 +883,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -885,6 +910,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -897,6 +925,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), op: Add, @@ -1106,6 +1136,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1158,6 +1190,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1171,6 +1205,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), op: Add, @@ -1208,6 +1243,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -1244,6 +1280,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), List( @@ -1267,10 +1304,12 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], ctx: Store, + runtime_elts: None, }, ), Name( @@ -1283,6 +1322,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), op: Add, @@ -1316,6 +1356,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), List( @@ -1339,10 +1380,12 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], ctx: Load, + runtime_elts: None, }, ), NumberLiteral( @@ -1356,6 +1399,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -1394,6 +1438,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1408,6 +1454,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), op: Add, @@ -1446,11 +1493,13 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_0.py.snap index d03bfe08c894e4..619fc9ac27d832 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_0.py.snap @@ -73,6 +73,9 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -84,11 +87,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_1.py.snap index 34809d25604f1e..db17c3b6bb29c3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_1.py.snap @@ -66,11 +66,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap index f02af5a34e1ae6..615d4cacb75130 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap @@ -88,9 +88,11 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), ], + runtime_body: None, }, ], }, @@ -102,6 +104,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap index eb00a56bdde69f..2a663ffb3cce66 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap @@ -35,6 +35,7 @@ Module( node_index: NodeIndex(None), range: 108..109, items: [], + runtime_values: None, }, ), arguments: PatternArguments { @@ -73,6 +74,9 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -93,6 +97,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -104,6 +109,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_4.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_4.py.snap index 68267d056ca966..cd5a8cb61267b9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_4.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_4.py.snap @@ -80,6 +80,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -91,11 +93,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap index 67b1874089e539..900b37114fe59d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap @@ -69,6 +69,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -80,6 +83,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 102..135, @@ -127,6 +131,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -138,6 +145,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 140..174, @@ -185,6 +193,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -196,6 +207,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 179..217, @@ -243,6 +255,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -254,6 +269,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 222..249, @@ -301,6 +317,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -312,6 +331,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 254..285, @@ -359,6 +379,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -370,11 +393,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_lhs_or_rhs_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_lhs_or_rhs_pattern.py.snap index 4f3a4512a1d659..ba01fabf0a05e1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_lhs_or_rhs_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_lhs_or_rhs_pattern.py.snap @@ -51,6 +51,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -78,6 +80,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 65..90, @@ -122,6 +125,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 95..120, @@ -166,6 +170,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 125..156, @@ -227,6 +232,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 161..191, @@ -264,6 +270,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), op: Add, @@ -290,6 +297,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 196..229, @@ -328,6 +336,7 @@ Module( ), }, ], + runtime_values: None, }, ), op: Add, @@ -354,6 +363,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 234..260, @@ -400,6 +410,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 265..292, @@ -453,6 +464,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 297..332, @@ -491,6 +503,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -518,6 +532,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -573,6 +588,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -589,6 +606,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 398..422, @@ -632,6 +650,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 427..451, @@ -675,6 +694,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 456..486, @@ -735,6 +755,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 491..520, @@ -782,6 +803,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), }, @@ -797,6 +819,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 525..557, @@ -845,6 +868,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -860,6 +884,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 562..586, @@ -904,6 +929,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 591..625, @@ -952,6 +978,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -968,6 +996,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -1013,6 +1042,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1034,6 +1065,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1050,11 +1083,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap index 45178034fd49f8..7ba9ec9072c488 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap @@ -64,6 +64,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -75,6 +77,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 110..138, @@ -118,6 +121,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -129,6 +134,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 143..170, @@ -172,6 +178,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -183,6 +191,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 175..209, @@ -246,6 +255,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -257,6 +268,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -313,6 +325,8 @@ Module( node_index: NodeIndex(None), }, ), + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -324,6 +338,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 365..411, @@ -364,6 +379,8 @@ Module( node_index: NodeIndex(None), }, ), + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -375,6 +392,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 416..462, @@ -415,6 +433,8 @@ Module( node_index: NodeIndex(None), }, ), + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -426,6 +446,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -477,6 +498,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -499,6 +522,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -516,11 +541,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap index f5388675aafdb0..0854b2275ed79a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap @@ -42,6 +42,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 102..128, @@ -77,6 +78,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 133..156, @@ -103,6 +105,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 161..188, @@ -141,6 +144,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -152,6 +156,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 193..220, @@ -190,6 +195,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -201,6 +207,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 225..251, @@ -231,6 +238,9 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -242,6 +252,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 256..284, @@ -281,6 +292,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -292,6 +306,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 289..312, @@ -334,6 +349,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -345,6 +362,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 317..343, @@ -388,6 +406,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -399,6 +419,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 348..377, @@ -425,6 +446,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -436,6 +459,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 382..407, @@ -486,6 +510,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -552,6 +577,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -563,11 +589,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__unary_add_usage.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__unary_add_usage.py.snap index e79911e767f8e3..297c045622e79b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__unary_add_usage.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__unary_add_usage.py.snap @@ -57,6 +57,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 96..126, @@ -126,6 +127,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -137,6 +139,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 131..161, @@ -206,6 +209,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -217,6 +221,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 166..200, @@ -302,6 +307,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -313,6 +321,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 205..245, @@ -384,6 +393,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -395,11 +406,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap index 441cae77b76f05..849ef085449a7d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap @@ -43,6 +43,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -62,6 +63,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -97,6 +101,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -129,6 +134,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -164,6 +172,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -196,6 +205,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -239,6 +251,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -291,6 +306,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -351,6 +369,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -424,6 +445,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -486,11 +510,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -526,6 +554,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -561,12 +592,16 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), For( @@ -609,11 +644,17 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), body: [], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), Expr( @@ -669,6 +710,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -721,6 +765,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -756,6 +802,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -798,12 +847,16 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), For( @@ -843,10 +896,15 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), body: [], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), Expr( @@ -924,6 +982,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -989,6 +1050,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1032,6 +1096,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -1051,6 +1116,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1104,6 +1172,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -1112,6 +1181,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -1131,6 +1201,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1172,6 +1245,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -1191,6 +1265,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1236,6 +1313,9 @@ Module( }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), AnnAssign( @@ -1258,6 +1338,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), With( @@ -1303,6 +1384,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -1334,6 +1417,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1366,6 +1452,9 @@ Module( }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -1410,6 +1499,9 @@ Module( }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), AnnAssign( @@ -1432,6 +1524,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), With( @@ -1464,6 +1557,9 @@ Module( }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), AnnAssign( @@ -1486,6 +1582,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), With( @@ -1559,9 +1656,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap index 6b0b38c2e329c8..90788327da591d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap @@ -30,6 +30,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -62,6 +65,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap index b1fee5d797b331..c682d058a43010 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap @@ -61,9 +61,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap index 6724cfec7005de..d660854359bbc6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap @@ -31,9 +31,13 @@ Module( }, ], body: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap index 9f31d95dd880f6..eb6936881a9c4b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap @@ -38,6 +38,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -77,6 +80,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -114,6 +120,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -160,6 +169,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -219,6 +231,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -278,6 +293,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -331,9 +349,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap index 7133e8b63fcabc..b138de089a545d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -84,6 +89,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -96,11 +104,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_name_tok.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_name_tok.py.snap index 55f34a110b1da3..4f21af3fdf1761 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_name_tok.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_name_tok.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,11 +54,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_other_tok.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_other_tok.py.snap index 0c729b6c50f0d3..a8bf46bf3510f6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_other_tok.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_other_tok.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -84,6 +89,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -96,11 +104,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap index 29393932932ac2..f3c92736014517 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap @@ -46,6 +46,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -58,6 +61,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -107,6 +112,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -115,6 +121,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -127,6 +136,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -175,6 +186,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -187,11 +201,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap index b26d9cf4db8a2f..58295a06342f33 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap @@ -50,6 +50,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -57,6 +59,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -72,6 +75,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -91,11 +97,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap index e755d104ba5fa6..537d55c71ce186 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap @@ -1,5 +1,6 @@ --- source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/t_string_unclosed_lbrace.py --- ## AST @@ -38,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -50,6 +54,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -83,6 +89,9 @@ Module( debug_text: None, conversion: Repr, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -95,6 +104,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -134,6 +145,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -146,6 +160,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -179,6 +195,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -191,6 +210,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -224,6 +245,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -236,11 +260,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap index 5efaaaebe15423..e03d8fd7a80fc3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap @@ -52,6 +52,9 @@ Module( elements: [], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -64,6 +67,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -118,6 +123,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -130,11 +138,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@template_strings_py313.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@template_strings_py313.py.snap index aaa2aed20ff70d..71a16208b62b55 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@template_strings_py313.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@template_strings_py313.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -84,6 +89,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -96,6 +104,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -131,11 +141,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap index 193c1c82696670..29a0b9d0424c84 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap @@ -33,6 +33,10 @@ Module( ), ], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Pass( @@ -42,6 +46,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap index 6368dc0cd18226..796dc5b05160e0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap @@ -26,6 +26,10 @@ Module( orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -51,9 +55,14 @@ Module( ], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` 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 e65db427d0db0e..e47df6f48a6b2f 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 @@ -26,6 +26,10 @@ Module( orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), AnnAssign( @@ -50,6 +54,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), Pass( @@ -87,6 +92,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Try( @@ -116,12 +124,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), AnnAssign( @@ -146,6 +159,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), Pass( @@ -177,9 +191,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap index 62db5271c7b964..7b4ed7c1d41cee 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap @@ -37,6 +37,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -62,12 +63,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -106,6 +112,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -122,12 +129,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -157,6 +169,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -173,6 +186,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -198,6 +212,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -223,15 +238,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@tuple_context_manager_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@tuple_context_manager_py38.py.snap index 059a866b5dd31f..1789f423bc3177 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@tuple_context_manager_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@tuple_context_manager_py38.py.snap @@ -57,6 +57,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -119,6 +122,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -155,9 +161,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_incomplete_stmt.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_incomplete_stmt.py.snap index eb26aa58f7f835..5cf9ea4c23dc70 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_incomplete_stmt.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_incomplete_stmt.py.snap @@ -76,6 +76,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap index 9e9d4f715353e2..302d83f26ab43d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap @@ -139,6 +139,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_default_py312.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_default_py312.py.snap index d20f30583a1437..8e630eef9a60ff 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_default_py312.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_default_py312.py.snap @@ -50,6 +50,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -101,6 +102,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -111,6 +113,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -127,6 +130,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -167,6 +174,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -175,6 +183,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -191,6 +201,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -266,6 +278,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -274,6 +287,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -290,9 +305,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap index 56404f81d85a74..7ec11225128792 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap @@ -57,6 +57,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -117,6 +118,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -175,6 +177,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -240,6 +243,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -253,6 +257,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_missing_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_missing_bound.py.snap index 4a12a66c5d60e7..3bd6e7b34d27ac 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_missing_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_missing_bound.py.snap @@ -41,6 +41,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -97,6 +98,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -110,6 +112,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap index 0a0d030f520342..670dbc560125cb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -81,6 +82,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap index 6e215c846a687b..fea0747299472e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap @@ -56,6 +56,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -115,6 +116,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -172,6 +174,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -236,6 +239,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -294,6 +298,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -307,6 +312,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_missing_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_missing_default.py.snap index 180df8a3edbf4c..a98c4db657d70f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_missing_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_missing_default.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -95,6 +96,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -108,6 +110,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap index cc7032b9c67a6c..f091bb8470c599 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap @@ -57,6 +57,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -117,6 +118,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -177,6 +179,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -235,6 +238,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -300,6 +304,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -368,6 +373,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -381,6 +387,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_missing_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_missing_default.py.snap index 0b4f3f21836c5e..b8955671641f8b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_missing_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_missing_default.py.snap @@ -41,6 +41,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -93,6 +94,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -149,6 +151,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -162,6 +165,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap index edeed69d21dec6..fc3e1910bc06ff 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -81,6 +82,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_invalid_default_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_invalid_default_expr.py.snap index f5fd209fbec592..27b9a9e9be2794 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_invalid_default_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_invalid_default_expr.py.snap @@ -56,6 +56,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -122,6 +123,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -131,6 +133,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -190,6 +193,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -247,6 +251,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -311,6 +316,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -324,6 +330,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_missing_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_missing_default.py.snap index f31c1fae6416de..5154228ced2b90 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_missing_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_missing_default.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -95,6 +96,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -108,6 +110,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_parameter_default_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_parameter_default_order.py.snap index 6d6b2fe73e9984..1701e91ad67b5e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_parameter_default_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_parameter_default_order.py.snap @@ -61,6 +61,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -78,6 +79,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -157,6 +160,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -174,6 +178,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), FunctionDef( @@ -228,6 +234,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -238,6 +245,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -254,6 +262,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), TypeAlias( @@ -309,6 +321,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: EllipsisLiteral( @@ -320,6 +333,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_params_empty.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_params_empty.py.snap index d28237e35fd8a7..3d025fc8e7d72b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_params_empty.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_params_empty.py.snap @@ -26,6 +26,7 @@ Module( range: 7..9, node_index: NodeIndex(None), type_params: [], + runtime_type_params: None, }, ), parameters: Parameters { @@ -36,6 +37,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -46,6 +48,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), TypeAlias( @@ -65,6 +71,7 @@ Module( range: 36..38, node_index: NodeIndex(None), type_params: [], + runtime_type_params: None, }, ), value: BinOp( @@ -93,6 +100,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_stmt_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_stmt_py311.py.snap index 227ca0f7fe4115..254f5836b8055c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_stmt_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_stmt_py311.py.snap @@ -34,6 +34,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unary_plus_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unary_plus_py314.py.snap index ebb1a720305465..3f068733eddc1e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unary_plus_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unary_plus_py314.py.snap @@ -63,6 +63,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 76..93, @@ -107,6 +108,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -124,11 +127,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_index_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_index_py38.py.snap index c144ff3d3a4412..4dcf2f8ae09694 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_index_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_index_py38.py.snap @@ -55,6 +55,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_comp_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_comp_py38.py.snap index ecc5a6040e5978..050eb729b95435 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_comp_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_comp_py38.py.snap @@ -79,11 +79,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -91,6 +95,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_literal_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_literal_py38.py.snap index 3d999f8721c7ab..b64439fa5aaceb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_literal_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_literal_py38.py.snap @@ -61,6 +61,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -116,6 +117,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -171,11 +173,13 @@ Module( }, ), ], + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap index d6e7d281ba0ef7..dded102f0065f8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap @@ -41,6 +41,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -112,6 +114,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -124,6 +129,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -201,6 +208,9 @@ Module( elements: [], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -213,6 +223,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -284,6 +296,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -296,6 +311,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -332,6 +349,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@walrus_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@walrus_py37.py.snap index e712c5694089d4..fe893f88a023b0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@walrus_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@walrus_py37.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap index e6637b1f496d55..910fe8fa7b20df 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap @@ -44,6 +44,8 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), While( @@ -81,6 +83,8 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), While( @@ -97,6 +101,8 @@ Module( ), body: [], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), AnnAssign( @@ -119,6 +125,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), While( @@ -150,6 +157,8 @@ Module( ), body: [], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), AnnAssign( @@ -172,9 +181,11 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_colon.py.snap index 988d4172d99e5b..8b72ed23ee2b46 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_colon.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), body: [ @@ -51,9 +52,12 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_test.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_test.py.snap index be86004a045d10..817161e3b1c743 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_test.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_test.py.snap @@ -37,6 +37,8 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), While( @@ -75,13 +77,19 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_colon.py.snap index 817368aa22c72e..cf300bb6502b6e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_colon.py.snap @@ -51,9 +51,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap index 0fe1787db6ebda..7510942975f0bd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap @@ -57,6 +57,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -115,6 +118,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -190,6 +196,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -274,6 +283,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -309,6 +321,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -328,9 +341,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@write_to_debug_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@write_to_debug_expr.py.snap index b23970c545bc8d..e2a46864571580 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@write_to_debug_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@write_to_debug_expr.py.snap @@ -24,6 +24,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Delete( @@ -64,6 +65,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Assign( @@ -89,6 +91,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -136,6 +141,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), ], @@ -183,11 +189,16 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_after_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_after_comma.py.snap index 78d8a6437b3ee1..e7db000f7fc0f2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_after_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_after_comma.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -71,14 +72,20 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_from_in_async_function.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_from_in_async_function.py.snap index f040e673c2a8d7..979ca5cb5aa4c3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_from_in_async_function.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_from_in_async_function.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -54,9 +55,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@all_async_comprehension_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@all_async_comprehension_py310.py.snap index 7982e188e27ee1..b8d909df3999f1 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@all_async_comprehension_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@all_async_comprehension_py310.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -92,11 +93,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -140,11 +145,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -153,9 +162,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@ambiguous_lpar_with_items_binary_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@ambiguous_lpar_with_items_binary_expr.py.snap index fd5b660b963581..4536ae980eccfe 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@ambiguous_lpar_with_items_binary_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@ambiguous_lpar_with_items_binary_expr.py.snap @@ -42,6 +42,7 @@ Module( }, ), ], + runtime_values: None, }, ), optional_vars: None, @@ -61,6 +62,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -97,6 +101,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), optional_vars: None, @@ -116,6 +121,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -164,9 +172,11 @@ Module( }, ), ], + runtime_values: None, }, ), ], + runtime_values: None, }, ), optional_vars: None, @@ -186,6 +196,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -226,6 +239,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -237,6 +251,7 @@ Module( }, ), ], + runtime_values: None, }, ), optional_vars: None, @@ -256,6 +271,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -337,6 +355,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -419,9 +440,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@ambiguous_lpar_with_items_if_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@ambiguous_lpar_with_items_if_expr.py.snap index d035e3bff61ca6..392db6ab6b0ac6 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@ambiguous_lpar_with_items_if_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@ambiguous_lpar_with_items_if_expr.py.snap @@ -65,6 +65,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -121,6 +124,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -153,6 +158,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -209,6 +217,8 @@ Module( ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -241,6 +251,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -314,9 +327,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@ann_assign_stmt_simple_target.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@ann_assign_stmt_simple_target.py.snap index 36a68093706154..489ac97c513efd 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@ann_assign_stmt_simple_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@ann_assign_stmt_simple_target.py.snap @@ -32,6 +32,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -56,6 +57,7 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -92,6 +94,7 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -132,9 +135,11 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@args_unparenthesized_generator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@args_unparenthesized_generator.py.snap index 495601cfa5ed34..d642cc4385c97b 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@args_unparenthesized_generator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@args_unparenthesized_generator.py.snap @@ -81,11 +81,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -142,11 +146,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -154,6 +162,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -230,11 +240,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -242,6 +256,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -318,11 +334,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -330,12 +350,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@assign_stmt_starred_expr_value.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@assign_stmt_starred_expr_value.py.snap index 1fe9bc4e9c1e22..765ee3c0413ffb 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@assign_stmt_starred_expr_value.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@assign_stmt_starred_expr_value.py.snap @@ -33,6 +33,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -65,8 +68,12 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -108,6 +115,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ctx: Load, @@ -116,8 +124,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -159,6 +171,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ctx: Load, @@ -167,11 +180,16 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@assign_targets_terminator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@assign_targets_terminator.py.snap index 5d1a27f814f9e7..b1b6ed81a90713 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@assign_targets_terminator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@assign_targets_terminator.py.snap @@ -49,6 +49,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -79,6 +82,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -122,6 +126,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -152,11 +159,13 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_for_statement.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_for_statement.py.snap index 5443d07ff3e14d..dddb2497a77bb5 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_for_statement.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_for_statement.py.snap @@ -46,9 +46,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_function_definition.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_function_definition.py.snap index d3fe2817d28741..241ee75102052d 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_function_definition.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_function_definition.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -46,9 +47,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_with_statement.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_with_statement.py.snap index d653933f323f2e..d5a984a0808138 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_with_statement.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@async_with_statement.py.snap @@ -44,9 +44,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@backslash_continuation_indentation.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@backslash_continuation_indentation.py.snap index d38904b2c4b152..dff398280850f3 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@backslash_continuation_indentation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@backslash_continuation_indentation.py.snap @@ -75,11 +75,15 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_def_arguments.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_def_arguments.py.snap index 6a275e46d095b9..48e73cf25d91a2 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_def_arguments.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_def_arguments.py.snap @@ -36,6 +36,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -55,6 +57,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -71,6 +75,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -123,6 +129,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -130,6 +138,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -146,6 +156,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -202,6 +214,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -212,6 +226,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -228,9 +244,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_keyword_in_case_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_keyword_in_case_pattern.py.snap index a732e866b3b818..8eeefbb0d94616 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_keyword_in_case_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_keyword_in_case_pattern.py.snap @@ -69,6 +69,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -86,11 +89,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_type_params_py312.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_type_params_py312.py.snap index 85a9bc9f7898f3..53d495ec47a4c8 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_type_params_py312.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@class_type_params_py312.py.snap @@ -59,6 +59,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -112,6 +113,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -129,9 +131,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@comma_separated_regular_list_terminator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@comma_separated_regular_list_terminator.py.snap index c755a0542b10fc..d6821b6a66c08c 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@comma_separated_regular_list_terminator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@comma_separated_regular_list_terminator.py.snap @@ -30,6 +30,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -63,6 +64,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -96,6 +98,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -138,6 +141,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -180,11 +184,13 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@debug_rename_import.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@debug_rename_import.py.snap index b96eb28938ea4f..99585988218807 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@debug_rename_import.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@debug_rename_import.py.snap @@ -60,6 +60,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -93,9 +94,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_async_function.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_async_function.py.snap index 7d009ac3d44c15..6f9920b1a8b49c 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_async_function.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_async_function.py.snap @@ -43,6 +43,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -59,9 +60,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_await_expression_py39.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_await_expression_py39.py.snap index 957a81dd4fb4a3..dbccc2cd459aca 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_await_expression_py39.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_await_expression_py39.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -72,6 +73,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -88,12 +90,21 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_dotted_ident_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_dotted_ident_py38.py.snap index 578a528c1d7616..9fc89e09f80f7b 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_dotted_ident_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_dotted_ident_py38.py.snap @@ -67,6 +67,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -83,9 +84,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_eval_hack_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_eval_hack_py38.py.snap index fb3322b7a7daa7..144d0714d5ed53 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_eval_hack_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_eval_hack_py38.py.snap @@ -58,6 +58,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -77,6 +79,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -93,9 +96,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_identity_hack_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_identity_hack_py38.py.snap index 3250a9ad0fd2cb..d1258b1e9ff404 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_identity_hack_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_identity_hack_py38.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -46,6 +48,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -66,6 +69,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -143,6 +150,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -162,6 +171,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -178,9 +188,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_py39.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_py39.py.snap index dca975e0e98023..2af32084e26e45 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_py39.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@decorator_expression_py39.py.snap @@ -83,6 +83,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -99,6 +100,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -148,6 +153,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -155,6 +162,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -183,6 +191,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -202,6 +212,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -218,9 +229,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@del_debug_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@del_debug_py38.py.snap index e3595cb15786aa..7b998968a6956a 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@del_debug_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@del_debug_py38.py.snap @@ -24,9 +24,11 @@ Module( }, ), ], + runtime_targets: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@del_targets_terminator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@del_targets_terminator.py.snap index 2c6467849cf96a..9ffff67db0513d 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@del_targets_terminator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@del_targets_terminator.py.snap @@ -32,6 +32,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Expr( @@ -62,6 +63,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -88,6 +90,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Expr( @@ -118,11 +121,13 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@different_match_pattern_bindings.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@different_match_pattern_bindings.py.snap index 27052180223f1f..e6e35bef1457ae 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@different_match_pattern_bindings.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@different_match_pattern_bindings.py.snap @@ -51,6 +51,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -73,9 +74,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -93,6 +96,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 37..62, @@ -136,6 +140,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -172,9 +177,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -192,6 +199,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 67..89, @@ -249,9 +257,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -269,6 +279,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 94..119, @@ -306,6 +317,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -336,9 +348,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -356,6 +370,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 124..146, @@ -385,6 +400,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -425,12 +441,17 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -448,11 +469,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@dotted_name_normalized_spaces.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@dotted_name_normalized_spaces.py.snap index 6bb8c42dcb079e..a84349cbc01b93 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@dotted_name_normalized_spaces.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@dotted_name_normalized_spaces.py.snap @@ -49,6 +49,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@duplicate_match_key_attr.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@duplicate_match_key_attr.py.snap index e090cde33989f8..469d718161c92e 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@duplicate_match_key_attr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@duplicate_match_key_attr.py.snap @@ -105,6 +105,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -122,11 +124,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_star_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_star_py311.py.snap index f4f83b064f9038..19a0d8612ba8d9 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_star_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_star_py311.py.snap @@ -58,15 +58,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_stmt_as_name_soft_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_stmt_as_name_soft_keyword.py.snap index d6f25ac1cc6ff4..fb2e39f86e47a6 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_stmt_as_name_soft_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_stmt_as_name_soft_keyword.py.snap @@ -64,6 +64,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -101,6 +102,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -138,15 +140,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_stmt_unparenthesized_tuple_no_as_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_stmt_unparenthesized_tuple_no_as_py314.py.snap index 2d4a97a3961485..b4c3d0150e0cc2 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_stmt_unparenthesized_tuple_no_as_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@except_stmt_unparenthesized_tuple_no_as_py314.py.snap @@ -52,6 +52,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -64,12 +65,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -114,6 +120,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -126,15 +133,21 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__arguments.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__arguments.py.snap index 05f893a42cd160..4793d3eb05c8d9 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__arguments.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__arguments.py.snap @@ -31,6 +31,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -74,6 +76,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -117,6 +121,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -184,6 +190,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -226,6 +234,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -266,6 +276,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -322,6 +334,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -372,6 +386,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -421,6 +437,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -484,6 +502,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -544,6 +564,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -600,6 +622,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -658,6 +682,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -738,6 +764,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -822,6 +850,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -902,6 +932,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -971,6 +1003,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1023,6 +1057,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1081,6 +1117,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1088,6 +1126,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -1102,6 +1141,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1163,6 +1204,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1206,6 +1249,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1247,6 +1292,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1297,6 +1344,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1371,6 +1420,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -1378,6 +1429,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1430,6 +1483,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -1437,6 +1491,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1494,6 +1550,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1542,6 +1600,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1593,6 +1653,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1600,6 +1662,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -1617,6 +1680,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1680,6 +1745,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1720,6 +1787,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1773,10 +1842,13 @@ Module( }, ), ], + runtime_values: None, }, ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1823,6 +1895,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1884,6 +1958,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1932,6 +2008,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1984,6 +2062,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1991,6 +2071,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -2005,12 +2086,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__attribute.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__attribute.py.snap index baa336d282c40d..eabdf4f526038f 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__attribute.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__attribute.py.snap @@ -69,6 +69,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -99,6 +101,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -145,6 +149,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -161,6 +167,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -249,6 +257,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -263,6 +273,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__await.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__await.py.snap index 4eb4a3e525cf44..19e1b46c00aebf 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__await.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__await.py.snap @@ -99,6 +99,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -128,6 +129,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -168,6 +171,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -206,6 +210,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -247,6 +252,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -289,6 +295,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -327,6 +334,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -370,6 +378,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -444,6 +453,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -480,6 +490,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -487,6 +499,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -587,6 +600,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__bin_op.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__bin_op.py.snap index 3b4a7feb7b101c..16ae5839abc60e 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__bin_op.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__bin_op.py.snap @@ -1193,6 +1193,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__bool_op.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__bool_op.py.snap index 90362fa9dd0f14..c244320f939eed 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__bool_op.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__bool_op.py.snap @@ -37,6 +37,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -76,6 +77,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -107,6 +109,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -146,6 +149,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -183,6 +187,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -194,6 +199,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -239,6 +245,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -272,6 +279,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -283,6 +291,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -327,6 +336,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -338,6 +348,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -380,6 +391,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -391,6 +403,7 @@ Module( }, ), ], + runtime_values: None, }, ), ), @@ -438,6 +451,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -449,11 +463,13 @@ Module( }, ), ], + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__call.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__call.py.snap index 5f931e1947ac5e..26219b4e8e2931 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__call.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__call.py.snap @@ -31,6 +31,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -69,6 +71,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -120,6 +124,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -130,6 +135,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -182,6 +189,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -229,6 +238,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), arguments: Arguments { @@ -236,6 +246,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -284,6 +296,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), arguments: Arguments { @@ -291,6 +304,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -338,6 +353,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -348,6 +365,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -394,6 +413,7 @@ Module( }, ), ], + runtime_elts: None, }, ), arguments: Arguments { @@ -401,6 +421,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -464,6 +486,7 @@ Module( ), }, ], + runtime_values: None, }, ), arguments: Arguments { @@ -471,6 +494,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -505,6 +530,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -530,6 +557,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -555,6 +584,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -579,6 +610,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -618,6 +651,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -645,6 +680,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -672,12 +709,15 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__compare.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__compare.py.snap index 5b6e37e7c9ba60..07f9abaf840912 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__compare.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__compare.py.snap @@ -39,6 +39,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -72,6 +73,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -105,6 +107,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -138,6 +141,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -171,6 +175,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -204,6 +209,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -237,6 +243,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -270,6 +277,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -303,6 +311,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -336,6 +345,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -405,6 +415,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -492,6 +503,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -530,6 +542,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -585,6 +598,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), Name( @@ -596,9 +610,11 @@ Module( }, ), ], + runtime_values: None, }, ), ], + runtime_values: None, }, ), }, @@ -638,6 +654,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -677,6 +694,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -782,11 +800,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__dictionary.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__dictionary.py.snap index 34a2ba29b61fa4..7e89b43d9bb5c9 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__dictionary.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__dictionary.py.snap @@ -19,6 +19,7 @@ Module( node_index: NodeIndex(None), range: 9..11, items: [], + runtime_values: None, }, ), }, @@ -55,6 +56,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -145,6 +147,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -158,6 +161,7 @@ Module( node_index: NodeIndex(None), range: 66..69, items: [], + runtime_values: None, }, ), }, @@ -216,6 +220,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -259,6 +264,7 @@ Module( ), }, ], + runtime_values: None, }, ), ), @@ -307,14 +313,17 @@ Module( ), }, ], + runtime_values: None, }, ), }, ], + runtime_values: None, }, ), }, ], + runtime_values: None, }, ), }, @@ -352,6 +361,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -359,6 +370,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -383,6 +395,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -442,6 +455,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -449,6 +464,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NoneLiteral( @@ -494,6 +510,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -543,6 +560,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -607,6 +625,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -632,6 +651,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -677,6 +697,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -713,6 +734,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -830,6 +852,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -919,10 +942,12 @@ Module( ), }, ], + runtime_values: None, }, ), }, ], + runtime_values: None, }, ), }, @@ -1007,11 +1032,14 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ], + runtime_values: None, }, ), }, @@ -1044,6 +1072,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -1100,6 +1129,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -1190,11 +1220,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 556..574, @@ -1234,11 +1268,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1280,6 +1318,7 @@ Module( }, ), ], + runtime_elts: None, }, ), ), @@ -1332,10 +1371,12 @@ Module( ), }, ], + runtime_values: None, }, ), }, ], + runtime_values: None, }, ), }, @@ -1390,11 +1431,13 @@ Module( ), }, ], + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__dictionary_comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__dictionary_comprehension.py.snap index c9ae90c6ac6b42..f03060c58b1080 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__dictionary_comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__dictionary_comprehension.py.snap @@ -73,10 +73,13 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -131,6 +134,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -231,11 +236,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -330,6 +339,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), BoolOp( @@ -355,6 +365,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -367,6 +378,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -459,10 +472,13 @@ Module( }, ), ], + runtime_values: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 156..175, @@ -509,10 +525,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -589,10 +608,13 @@ Module( }, ), ], + runtime_values: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 205..230, @@ -639,10 +661,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -703,6 +728,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -715,6 +741,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -777,6 +805,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -837,6 +867,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -903,6 +935,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -910,6 +944,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -924,6 +959,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -995,6 +1032,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1064,6 +1103,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1139,6 +1180,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1146,6 +1189,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -1160,6 +1204,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1167,6 +1213,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__f_string.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__f_string.py.snap index 497bd02d9408d6..8087b7f7cee7c7 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__f_string.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__f_string.py.snap @@ -33,6 +33,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -60,6 +62,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -87,6 +91,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -114,6 +120,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -141,6 +149,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -187,6 +197,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -199,6 +212,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -232,6 +247,9 @@ Module( debug_text: None, conversion: Str, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -244,6 +262,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -283,11 +303,15 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -300,6 +324,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -349,6 +375,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), debug_text: None, @@ -360,6 +387,9 @@ Module( elements: [], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -372,6 +402,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -438,6 +470,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -450,6 +485,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -462,6 +500,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -528,6 +568,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -540,6 +583,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -552,6 +598,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -591,6 +639,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -603,6 +654,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -656,6 +709,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -668,6 +724,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -707,6 +765,9 @@ Module( ), conversion: Str, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -719,6 +780,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -767,6 +830,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), debug_text: Some( @@ -778,6 +842,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -790,6 +857,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -858,6 +927,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -870,6 +942,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, @@ -889,6 +963,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -901,6 +978,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -978,6 +1057,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1012,6 +1094,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ), @@ -1026,6 +1110,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -1082,6 +1167,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 298..345, @@ -1138,6 +1224,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -1178,6 +1265,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1216,6 +1306,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1228,6 +1321,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1263,6 +1358,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1310,6 +1407,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1322,6 +1422,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1361,6 +1463,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1373,6 +1478,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1413,6 +1520,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1437,6 +1547,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1461,6 +1574,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1480,6 +1596,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1520,6 +1638,9 @@ Module( debug_text: None, conversion: Ascii, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1544,6 +1665,9 @@ Module( debug_text: None, conversion: Str, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1568,6 +1692,9 @@ Module( debug_text: None, conversion: Repr, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1592,6 +1719,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1604,6 +1734,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1658,6 +1790,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1670,6 +1805,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1734,6 +1871,7 @@ Module( }, ), ], + runtime_elts: None, }, ), attr: Identifier { @@ -1749,17 +1887,25 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1772,6 +1918,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1816,6 +1964,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1823,6 +1973,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Set( @@ -1839,6 +1990,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -1846,6 +1998,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1858,6 +2013,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1897,6 +2054,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1909,6 +2069,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1948,6 +2110,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1960,6 +2125,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -1999,6 +2166,9 @@ Module( ), conversion: Ascii, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2011,6 +2181,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2058,6 +2230,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2070,6 +2245,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2123,6 +2300,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2135,6 +2315,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2182,6 +2364,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2194,6 +2379,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2242,6 +2429,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2256,6 +2446,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2291,6 +2483,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2322,6 +2517,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2336,6 +2534,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2371,6 +2571,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2398,6 +2601,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2458,11 +2663,15 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2475,6 +2684,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2523,6 +2734,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2550,6 +2764,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2669,6 +2885,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2717,6 +2935,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2757,6 +2978,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2805,6 +3028,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2845,6 +3071,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2893,6 +3121,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2933,6 +3164,8 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -2988,6 +3221,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -3035,11 +3271,14 @@ Module( ], ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__generator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__generator.py.snap index 2871d852f2885e..cc3d891782cf28 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__generator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__generator.py.snap @@ -48,6 +48,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -93,6 +95,8 @@ Module( ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -162,6 +166,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), BoolOp( @@ -187,6 +192,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -199,6 +205,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -266,10 +274,13 @@ Module( }, ), ], + runtime_values: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 136..165, @@ -316,10 +327,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -387,10 +401,13 @@ Module( }, ), ], + runtime_values: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 202..237, @@ -437,10 +454,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -516,6 +536,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -583,6 +605,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -779,10 +803,13 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -790,12 +817,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__if.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__if.py.snap index 077fc693a72441..56dce277c536a0 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__if.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__if.py.snap @@ -78,6 +78,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -184,6 +186,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), body: BinOp( @@ -269,6 +272,7 @@ Module( }, ), ], + runtime_values: None, }, ), orelse: BooleanLiteral( @@ -323,6 +327,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), orelse: Name( @@ -368,6 +373,7 @@ Module( }, ), ], + runtime_values: None, }, ), body: BooleanLiteral( @@ -440,6 +446,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -489,6 +496,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -496,6 +505,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -628,6 +638,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -635,6 +647,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -704,6 +717,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__lambda.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__lambda.py.snap index 29db11b9421190..99c40b404d66ca 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__lambda.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__lambda.py.snap @@ -79,6 +79,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -86,6 +88,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -127,6 +130,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -142,6 +147,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -149,6 +156,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: EllipsisLiteral( @@ -187,6 +195,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -202,6 +212,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -217,6 +229,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -224,6 +238,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -265,6 +280,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -280,6 +297,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -305,6 +324,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -322,6 +343,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -363,6 +385,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -378,6 +402,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -385,6 +411,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: BinOp( @@ -440,6 +467,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -455,6 +484,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -472,6 +503,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: BinOp( @@ -525,10 +557,13 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -567,6 +602,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -582,6 +619,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -597,6 +636,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -612,6 +653,7 @@ Module( }, ], kwarg: None, + runtime_defaults: None, }, ), body: EllipsisLiteral( @@ -652,6 +694,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -667,6 +711,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -682,11 +728,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -730,6 +779,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -745,6 +796,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -770,6 +823,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -785,6 +840,7 @@ Module( }, ], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -826,6 +882,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -841,6 +899,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -856,6 +916,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -874,6 +936,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -889,11 +953,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -935,8 +1002,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, ), body: Call( @@ -956,6 +1026,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -987,6 +1059,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], @@ -1000,8 +1074,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, ), body: BinOp( @@ -1025,6 +1102,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1068,6 +1147,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -1083,6 +1164,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1098,6 +1181,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1122,8 +1207,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, ), body: BinOp( @@ -1147,6 +1235,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1191,6 +1281,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1199,6 +1291,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: EllipsisLiteral( @@ -1236,6 +1329,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1253,6 +1348,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1260,6 +1357,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: EllipsisLiteral( @@ -1297,6 +1395,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1315,6 +1415,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: EllipsisLiteral( @@ -1352,6 +1453,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1367,6 +1470,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1386,11 +1491,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, ), body: EllipsisLiteral( @@ -1429,6 +1537,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1457,11 +1567,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, ), body: EllipsisLiteral( @@ -1499,6 +1612,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1514,6 +1629,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1541,6 +1658,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1558,6 +1677,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -1598,6 +1718,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1613,6 +1735,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1630,6 +1754,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1648,6 +1774,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1663,11 +1791,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, ), body: NumberLiteral( @@ -1708,6 +1839,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1723,6 +1856,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1740,6 +1875,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1754,6 +1891,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -1769,6 +1908,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1783,8 +1924,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, ), body: NumberLiteral( @@ -1801,6 +1945,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__list.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__list.py.snap index b93fd0db8609eb..c5cfd468d9cc9e 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__list.py.snap @@ -20,6 +20,7 @@ Module( range: 15..17, elts: [], ctx: Load, + runtime_elts: None, }, ), }, @@ -44,6 +45,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -68,6 +70,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -110,6 +113,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -152,6 +156,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -166,6 +171,7 @@ Module( range: 75..78, elts: [], ctx: Load, + runtime_elts: None, }, ), }, @@ -190,6 +196,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -223,6 +230,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -257,14 +265,17 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], ctx: Load, + runtime_elts: None, }, ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -303,6 +314,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), List( @@ -330,10 +342,12 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -372,6 +386,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -410,6 +425,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -466,6 +482,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -514,6 +531,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -577,6 +595,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -658,6 +677,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), Tuple( @@ -707,6 +727,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), Set( @@ -739,6 +760,7 @@ Module( }, ), ], + runtime_elts: None, }, ), Dict( @@ -768,6 +790,7 @@ Module( ), }, ], + runtime_values: None, }, ), Named( @@ -795,6 +818,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -873,11 +897,15 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -903,6 +931,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -910,11 +940,14 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -953,15 +986,18 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], ctx: Load, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__list_comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__list_comprehension.py.snap index 0d98fe23224b3c..76795420b19a16 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__list_comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__list_comprehension.py.snap @@ -83,14 +83,20 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -148,11 +154,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -221,6 +231,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), BoolOp( @@ -246,6 +257,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -258,6 +270,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -324,10 +338,13 @@ Module( }, ), ], + runtime_values: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 117..136, @@ -374,10 +391,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -444,10 +464,13 @@ Module( }, ), ], + runtime_values: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 163..188, @@ -494,10 +517,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -558,10 +584,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -612,6 +641,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -624,6 +654,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -680,6 +712,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -692,6 +725,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -764,10 +799,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -842,6 +880,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -922,6 +962,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1002,6 +1044,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1077,17 +1121,22 @@ Module( range: 453..455, elts: [], ctx: Load, + runtime_elts: None, }, ), }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1140,6 +1189,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1190,6 +1241,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1246,6 +1299,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1253,6 +1308,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -1267,6 +1323,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1328,6 +1386,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1387,6 +1447,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1452,6 +1514,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1459,6 +1523,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -1473,6 +1538,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -1480,6 +1547,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__name.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__name.py.snap index b32e08dff6b063..f2dbce25e75967 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__name.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__name.py.snap @@ -137,6 +137,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__named.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__named.py.snap index 199a11eab69b71..0509afecdea22b 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__named.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__named.py.snap @@ -174,6 +174,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -267,6 +268,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -274,6 +277,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -361,6 +365,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__number_literal.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__number_literal.py.snap index ad313fbab1b752..da2a15e2adfdd7 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__number_literal.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__number_literal.py.snap @@ -33,6 +33,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -58,6 +61,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -83,6 +89,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -108,6 +117,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -133,6 +145,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -158,6 +173,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -183,6 +201,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -208,6 +229,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -233,6 +257,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -258,6 +285,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -284,6 +314,9 @@ Module( }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -310,6 +343,9 @@ Module( }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -335,6 +371,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -360,6 +399,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -385,6 +427,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -410,6 +455,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -435,6 +483,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -460,6 +511,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -497,6 +551,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -534,6 +591,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -571,6 +631,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -617,9 +680,14 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -657,6 +725,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -703,9 +774,14 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -744,6 +820,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -820,14 +899,21 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -874,9 +960,14 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -923,9 +1014,14 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -963,6 +1059,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1009,9 +1108,14 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1045,6 +1149,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), If( @@ -1087,6 +1194,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Assign( @@ -1127,6 +1235,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1170,12 +1281,18 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__parenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__parenthesized.py.snap index 9854d74ac153b7..5bbfe64283081e 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__parenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__parenthesized.py.snap @@ -45,6 +45,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -79,6 +81,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -87,6 +91,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -95,6 +101,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -133,6 +141,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -144,6 +153,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -174,6 +184,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -181,6 +193,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -267,6 +280,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__set.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__set.py.snap index e65e97a2b8fb2f..567ff798259176 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__set.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__set.py.snap @@ -19,6 +19,7 @@ Module( node_index: NodeIndex(None), range: 14..16, items: [], + runtime_values: None, }, ), }, @@ -42,6 +43,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -65,6 +67,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -106,6 +109,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -147,6 +151,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -160,6 +165,7 @@ Module( node_index: NodeIndex(None), range: 74..77, items: [], + runtime_values: None, }, ), }, @@ -183,6 +189,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -215,6 +222,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -243,9 +251,11 @@ Module( }, ), ], + runtime_elts: None, }, ), ], + runtime_elts: None, }, ), }, @@ -283,6 +293,7 @@ Module( }, ), ], + runtime_elts: None, }, ), Set( @@ -309,9 +320,11 @@ Module( }, ), ], + runtime_elts: None, }, ), ], + runtime_elts: None, }, ), }, @@ -349,6 +362,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -404,6 +418,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -450,6 +465,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -497,6 +513,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -559,6 +576,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -621,6 +639,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), Set( @@ -656,6 +675,7 @@ Module( }, ), ], + runtime_elts: None, }, ), Dict( @@ -695,14 +715,17 @@ Module( ), }, ], + runtime_values: None, }, ), ], + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__set_comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__set_comprehension.py.snap index 2eda56c849adeb..ebdb32ab6d078f 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__set_comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__set_comprehension.py.snap @@ -48,6 +48,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -116,6 +118,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), BoolOp( @@ -141,6 +144,7 @@ Module( }, ), ], + runtime_values: None, }, ), Name( @@ -153,6 +157,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -219,10 +225,13 @@ Module( }, ), ], + runtime_values: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 83..102, @@ -269,10 +278,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -339,10 +351,13 @@ Module( }, ), ], + runtime_values: None, }, ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, Comprehension { range: 129..154, @@ -389,10 +404,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), ], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -443,6 +461,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -455,6 +474,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -507,6 +528,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -557,6 +580,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -613,6 +638,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -620,6 +647,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -634,6 +662,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -695,6 +725,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -754,6 +786,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -819,6 +853,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -826,6 +862,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -840,6 +877,8 @@ Module( ), ], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -847,6 +886,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__slice.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__slice.py.snap index d19e76dab3bec2..3af9b25d5d3aa6 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__slice.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__slice.py.snap @@ -675,6 +675,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -734,6 +735,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -742,6 +744,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__starred.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__starred.py.snap index be5cfdc577d600..6d7e6d259c8f7f 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__starred.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__starred.py.snap @@ -175,11 +175,15 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -247,6 +251,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Store, @@ -261,6 +266,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -317,6 +325,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -392,6 +401,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -400,6 +410,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__string.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__string.py.snap index 0f376fd49033f9..7b449d85f0c538 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__string.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__string.py.snap @@ -357,6 +357,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__subscript.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__subscript.py.snap index 8407b7a8d8c560..f862202fac3e65 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__subscript.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__subscript.py.snap @@ -98,6 +98,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -148,6 +149,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -207,6 +209,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -276,6 +279,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -398,6 +402,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -500,6 +505,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -558,6 +564,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -757,6 +764,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -812,6 +820,7 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, @@ -820,6 +829,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -880,6 +890,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -888,6 +899,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__t_string.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__t_string.py.snap index 422c6584606f85..6a137192a70fa9 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__t_string.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__t_string.py.snap @@ -33,6 +33,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -60,6 +62,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -87,6 +91,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -114,6 +120,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -141,6 +149,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -187,6 +197,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -199,6 +212,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -232,6 +247,9 @@ Module( debug_text: None, conversion: Str, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -244,6 +262,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -283,11 +303,15 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -300,6 +324,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -349,6 +375,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), debug_text: None, @@ -360,6 +387,9 @@ Module( elements: [], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -372,6 +402,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -438,6 +470,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -450,6 +485,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -462,6 +500,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -528,6 +568,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -540,6 +583,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -552,6 +598,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -591,6 +639,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -603,6 +654,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -656,6 +709,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -668,6 +724,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -707,6 +765,9 @@ Module( ), conversion: Str, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -719,6 +780,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -767,6 +830,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), debug_text: Some( @@ -778,6 +842,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -790,6 +857,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -858,6 +927,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -870,6 +942,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), debug_text: None, @@ -889,6 +963,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -901,6 +978,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -983,6 +1062,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1022,6 +1104,8 @@ Module( ], ), }, + runtime_template_str: None, + runtime_values: None, }, ), ), @@ -1036,6 +1120,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -1092,6 +1177,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 300..347, @@ -1148,6 +1234,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -1188,6 +1275,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1226,6 +1316,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1238,6 +1331,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1273,6 +1368,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1320,6 +1417,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1332,6 +1432,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1371,6 +1473,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1383,6 +1488,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1423,6 +1530,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1447,6 +1557,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1471,6 +1584,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1490,6 +1606,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1530,6 +1648,9 @@ Module( debug_text: None, conversion: Ascii, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1554,6 +1675,9 @@ Module( debug_text: None, conversion: Str, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1578,6 +1702,9 @@ Module( debug_text: None, conversion: Repr, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1602,6 +1729,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1614,6 +1744,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1668,6 +1800,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1680,6 +1815,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1744,6 +1881,7 @@ Module( }, ), ], + runtime_elts: None, }, ), attr: Identifier { @@ -1759,17 +1897,25 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1782,6 +1928,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1826,6 +1974,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1833,6 +1983,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Set( @@ -1849,6 +2000,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -1856,6 +2008,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1868,6 +2023,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1907,6 +2064,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1919,6 +2079,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -1958,6 +2120,9 @@ Module( ), conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1970,6 +2135,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2009,6 +2176,9 @@ Module( ), conversion: Ascii, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2021,6 +2191,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2068,6 +2240,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2080,6 +2255,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2133,6 +2310,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2145,6 +2325,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2192,6 +2374,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2204,6 +2389,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2257,6 +2444,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2270,6 +2460,8 @@ Module( ], ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2304,6 +2496,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2333,6 +2528,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2346,6 +2544,8 @@ Module( ], ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2380,6 +2580,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2412,6 +2615,8 @@ Module( ], ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2472,11 +2677,15 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2489,6 +2698,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2542,6 +2753,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2574,6 +2788,8 @@ Module( ], ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2691,6 +2907,8 @@ Module( ], ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -2752,6 +2970,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2764,11 +2985,16 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2781,11 +3007,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -2798,11 +3029,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__tuple.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__tuple.py.snap index 85d7b0c3f69aa4..b0d006f363b0f5 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__tuple.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__tuple.py.snap @@ -21,6 +21,7 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -36,6 +37,7 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -56,6 +58,7 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), Tuple( @@ -65,11 +68,13 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -94,6 +99,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -126,6 +132,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -158,6 +165,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -190,6 +198,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -214,6 +223,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -246,6 +256,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -278,6 +289,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -309,6 +321,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -348,6 +361,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -419,6 +433,7 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), Starred( @@ -432,6 +447,7 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ctx: Load, @@ -440,6 +456,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -471,6 +488,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -510,6 +528,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -581,6 +600,7 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), Starred( @@ -594,6 +614,7 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ctx: Load, @@ -602,6 +623,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -641,6 +663,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -688,6 +711,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -743,6 +767,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -798,11 +823,13 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__unary_op.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__unary_op.py.snap index 5098bc60446b0b..a58fde291d79f4 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__unary_op.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__unary_op.py.snap @@ -354,6 +354,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -438,6 +439,7 @@ Module( }, ), ], + runtime_values: None, }, ), BoolOp( @@ -492,9 +494,11 @@ Module( }, ), ], + runtime_values: None, }, ), ], + runtime_values: None, }, ), }, @@ -579,6 +583,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__yield.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__yield.py.snap index 2a3291790bcf4d..7e425188e2959d 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__yield.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__yield.py.snap @@ -115,6 +115,7 @@ Module( }, ), ], + runtime_values: None, }, ), ), @@ -148,6 +149,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -190,6 +193,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ), @@ -230,6 +234,7 @@ Module( }, ), ], + runtime_elts: None, }, ), ), @@ -273,6 +278,7 @@ Module( ), }, ], + runtime_values: None, }, ), ), @@ -313,6 +319,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -353,6 +360,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -394,6 +402,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ), @@ -478,6 +487,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -517,6 +527,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -525,6 +536,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__yield_from.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__yield_from.py.snap index 7030c8e5a75401..e03094ee7f4312 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__yield_from.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@expressions__yield_from.py.snap @@ -97,6 +97,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -128,6 +129,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -168,6 +171,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -206,6 +210,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -247,6 +252,7 @@ Module( ), }, ], + runtime_values: None, }, ), }, @@ -285,6 +291,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -324,6 +331,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -419,6 +427,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -426,6 +435,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_in_target_valid_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_in_target_valid_expr.py.snap index 14e2695f428db7..c791c7d74f44b8 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_in_target_valid_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_in_target_valid_expr.py.snap @@ -52,6 +52,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ctx: Store, @@ -80,6 +81,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -116,6 +121,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), slice: NumberLiteral( @@ -153,6 +159,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -189,6 +199,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), attr: Identifier { @@ -222,9 +233,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_iter_unpack_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_iter_unpack_py38.py.snap index bebfeca6cb8d61..1f7aea79c0047c 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_iter_unpack_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_iter_unpack_py38.py.snap @@ -54,6 +54,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), body: [ @@ -71,6 +72,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -117,6 +122,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), body: [ @@ -134,6 +140,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -187,6 +197,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), body: [ @@ -204,9 +215,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_iter_unpack_py39.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_iter_unpack_py39.py.snap index 57ae9806a24a1c..b43f4e9ec106b8 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_iter_unpack_py39.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@for_iter_unpack_py39.py.snap @@ -54,6 +54,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), body: [ @@ -71,6 +72,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -117,6 +122,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), body: [ @@ -134,6 +140,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -187,6 +197,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), body: [ @@ -204,9 +215,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_no_space.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_no_space.py.snap index a47797f4e8d6b2..0315c3b29721fc 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_no_space.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_no_space.py.snap @@ -29,6 +29,7 @@ Module( ], level: 1, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -50,9 +51,11 @@ Module( ], level: 3, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_soft_keyword_module_name.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_soft_keyword_module_name.py.snap index caa760037150b9..26c451702e8b33 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_soft_keyword_module_name.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_soft_keyword_module_name.py.snap @@ -35,6 +35,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -62,6 +63,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -89,6 +91,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -116,6 +119,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -143,9 +147,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_stmt_terminator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_stmt_terminator.py.snap index a517cf6019c38e..ee29fdeae46aee 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_stmt_terminator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@from_import_stmt_terminator.py.snap @@ -45,6 +45,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -82,6 +83,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), Expr( @@ -112,6 +114,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -151,6 +154,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), Expr( @@ -181,6 +185,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -220,6 +225,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), Expr( @@ -250,11 +256,13 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@fstring_format_spec_terminator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@fstring_format_spec_terminator.py.snap index 094d6147dfbe60..5763666d369fe0 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@fstring_format_spec_terminator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@fstring_format_spec_terminator.py.snap @@ -52,6 +52,9 @@ Module( elements: [], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -71,6 +74,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -125,6 +130,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -144,11 +152,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_parameter_range.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_parameter_range.py.snap index 900be0a8829884..f5a140414738d1 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_parameter_range.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_parameter_range.py.snap @@ -48,6 +48,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -72,6 +74,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -79,6 +83,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Name( @@ -104,9 +109,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_parenthesized_return_types.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_parenthesized_return_types.py.snap index 207800f85ee6f4..b77cc6b3cfa6a9 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_parenthesized_return_types.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_parenthesized_return_types.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Tuple( @@ -48,6 +49,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -65,6 +67,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -87,6 +93,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Tuple( @@ -113,6 +120,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -130,9 +138,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_valid_return_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_valid_return_expr.py.snap index 5415e94eee9fd3..27677b5f895f31 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_valid_return_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_def_valid_return_expr.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( BinOp( @@ -70,6 +71,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -92,6 +97,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Lambda( @@ -116,6 +122,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -123,6 +131,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -150,6 +159,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -172,6 +185,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( If( @@ -218,9 +232,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_type_params_py312.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_type_params_py312.py.snap index c60829f2b7b503..f81eb41fc14605 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_type_params_py312.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@function_type_params_py312.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -50,6 +51,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -66,9 +68,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@global_stmt.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@global_stmt.py.snap index 2282955763fe7d..bde83c87d3e174 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@global_stmt.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@global_stmt.py.snap @@ -47,6 +47,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_as_name_soft_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_as_name_soft_keyword.py.snap index 0b9b20b8ce859e..3fd67206588f3a 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_as_name_soft_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_as_name_soft_keyword.py.snap @@ -111,6 +111,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_from_star.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_from_star.py.snap index 61744c2a710e16..261b3c3dba05e1 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_from_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_from_star.py.snap @@ -35,9 +35,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_stmt_terminator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_stmt_terminator.py.snap index ee630a8fb65a78..fa0257f39ba4fa 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_stmt_terminator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@import_stmt_terminator.py.snap @@ -125,11 +125,13 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@irrefutable_case_pattern_at_end.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@irrefutable_case_pattern_at_end.py.snap index ee291df1336f8d..ae940a79098dbb 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@irrefutable_case_pattern_at_end.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@irrefutable_case_pattern_at_end.py.snap @@ -56,6 +56,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 29..42, @@ -89,6 +90,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -139,6 +141,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 72..83, @@ -166,6 +169,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -223,6 +227,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 164..175, @@ -257,11 +262,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_return_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_return_py37.py.snap index f98e1ddaa38181..e3dc19d7298ef2 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_return_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_return_py37.py.snap @@ -59,8 +59,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), FunctionDef( @@ -83,6 +87,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -141,15 +146,21 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_return_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_return_py38.py.snap index 4b66019a93412b..6ffb6a68594b1a 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_return_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_return_py38.py.snap @@ -59,8 +59,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), FunctionDef( @@ -83,6 +87,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -141,15 +146,21 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_yield_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_yield_py37.py.snap index 6738798560aac8..cc00a3f456b458 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_yield_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_yield_py37.py.snap @@ -59,8 +59,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), FunctionDef( @@ -83,6 +87,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -145,6 +150,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -153,9 +159,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_yield_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_yield_py38.py.snap index 9f1c150b3d61f4..440884eff30033 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_yield_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@iter_unpack_yield_py38.py.snap @@ -59,8 +59,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), FunctionDef( @@ -83,6 +87,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -145,6 +150,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -153,6 +159,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -175,6 +185,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -238,6 +249,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -255,6 +267,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -263,9 +276,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lambda_with_no_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lambda_with_no_parameters.py.snap index 597604369514cc..ed1cd6e5adcc42 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lambda_with_no_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lambda_with_no_parameters.py.snap @@ -33,6 +33,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lambda_with_valid_body.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lambda_with_valid_body.py.snap index 30d038eb10c91f..dd0da3db5ee9a5 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lambda_with_valid_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lambda_with_valid_body.py.snap @@ -36,6 +36,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -43,6 +45,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -83,6 +86,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -90,6 +95,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: If( @@ -151,6 +157,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -158,6 +166,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Await( @@ -204,6 +213,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -211,6 +222,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Lambda( @@ -235,6 +247,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -242,6 +256,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: BinOp( @@ -299,6 +314,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -306,6 +323,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Yield( @@ -359,6 +377,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -366,6 +386,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -396,11 +417,13 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_relative_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_relative_py315.py.snap index 6ca53f54c01642..7fe6560e32a4dc 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_relative_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_relative_py315.py.snap @@ -29,6 +29,7 @@ Module( ], level: 1, is_lazy: true, + runtime_level: None, }, ), ImportFrom( @@ -66,6 +67,7 @@ Module( ], level: 1, is_lazy: true, + runtime_level: None, }, ), ImportFrom( @@ -97,9 +99,11 @@ Module( ], level: 1, is_lazy: true, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_semantic_ok_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_semantic_ok_py315.py.snap index 26121089bed904..03fd8b70c48a8a 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_semantic_ok_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_semantic_ok_py315.py.snap @@ -67,6 +67,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -94,6 +96,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -134,6 +139,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -166,12 +173,17 @@ Module( ], level: 0, is_lazy: true, + runtime_level: None, }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_soft_keyword_split_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_soft_keyword_split_py315.py.snap index 4e9741934571c5..48549b90ac3b98 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_soft_keyword_split_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_soft_keyword_split_py315.py.snap @@ -82,9 +82,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_stmt_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_stmt_py315.py.snap index 448199ce6be0e6..85078322c8ef14 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_stmt_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@lazy_import_stmt_py315.py.snap @@ -79,6 +79,7 @@ Module( ], level: 0, is_lazy: true, + runtime_level: None, }, ), ImportFrom( @@ -112,6 +113,7 @@ Module( ], level: 0, is_lazy: true, + runtime_level: None, }, ), Assign( @@ -137,6 +139,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Import( @@ -189,9 +194,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_after_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_after_py310.py.snap index 8169fc8654b3b2..25e743b9839082 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_after_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_after_py310.py.snap @@ -51,11 +51,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_annotated_assignment.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_annotated_assignment.py.snap index a36c35515429f4..5350bbeb552125 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_annotated_assignment.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_annotated_assignment.py.snap @@ -48,6 +48,7 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -98,6 +99,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Store, @@ -113,9 +115,11 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_as_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_as_pattern.py.snap index 2ae3ea1e819b29..7e8c29a4dfa706 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_as_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_as_pattern.py.snap @@ -55,6 +55,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -98,11 +99,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_as_pattern_soft_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_as_pattern_soft_keyword.py.snap index 1d3283279780f1..862f9d0b74473a 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_as_pattern_soft_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_as_pattern_soft_keyword.py.snap @@ -55,6 +55,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -104,6 +105,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -153,11 +155,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_attr_pattern_soft_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_attr_pattern_soft_keyword.py.snap index 5050a08ea58e9c..e31cc9e8ed22fc 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_attr_pattern_soft_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_attr_pattern_soft_keyword.py.snap @@ -67,6 +67,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 39..57, @@ -112,6 +113,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 62..80, @@ -157,6 +159,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 85..130, @@ -262,11 +265,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_identifier_1.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_identifier_1.py.snap index 5d7d15d1327866..2858ea4047e0f2 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_identifier_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_identifier_1.py.snap @@ -39,11 +39,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_identifier_2.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_identifier_2.py.snap index f011147aae7f01..6ca718ffdb8422 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_identifier_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_identifier_2.py.snap @@ -53,6 +53,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, @@ -85,6 +86,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -116,6 +118,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), }, @@ -146,6 +149,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -186,6 +190,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), Expr( @@ -208,6 +213,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -323,6 +329,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -356,11 +363,13 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_1.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_1.py.snap index 651c2463f44c29..0e7c15a9faea29 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_1.py.snap @@ -49,6 +49,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -93,6 +94,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -137,6 +139,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -182,6 +185,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -238,6 +242,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -278,6 +283,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -290,6 +298,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), cases: [ @@ -319,6 +329,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -351,6 +362,7 @@ Module( }, ), ], + runtime_elts: None, }, ), cases: [ @@ -380,6 +392,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -430,6 +443,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -471,6 +485,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -521,6 +536,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -550,6 +566,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -582,6 +600,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -612,6 +631,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -619,6 +640,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -658,11 +680,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_2.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_2.py.snap index 84a0f8c7473d52..fd11c3fdbbfb59 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_2.py.snap @@ -49,6 +49,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -92,6 +93,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -135,6 +137,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -176,6 +179,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -218,6 +222,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -260,11 +265,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_or_identifier.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_or_identifier.py.snap index 40eb8aafef94e8..217481b552eab0 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_or_identifier.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_classify_as_keyword_or_identifier.py.snap @@ -50,6 +50,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -85,6 +87,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), cases: [ @@ -114,6 +117,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -187,6 +191,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), cases: [ @@ -216,6 +221,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -324,11 +330,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_sequence_pattern_parentheses_terminator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_sequence_pattern_parentheses_terminator.py.snap index 4cc16363d295fe..7931e1644a99f3 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_sequence_pattern_parentheses_terminator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_sequence_pattern_parentheses_terminator.py.snap @@ -60,6 +60,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -77,6 +78,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 40..56, @@ -115,6 +117,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -132,11 +135,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_sequence_pattern_terminator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_sequence_pattern_terminator.py.snap index 361c36bae44d0a..5187c4f2eb7906 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_sequence_pattern_terminator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_sequence_pattern_terminator.py.snap @@ -64,6 +64,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 40..54, @@ -102,6 +103,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -119,6 +121,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 59..78, @@ -157,6 +160,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: Some( @@ -183,6 +187,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 83..94, @@ -216,11 +221,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_stmt_subject_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_stmt_subject_expr.py.snap index de49fc65c0f761..a93e5a842b83b7 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_stmt_subject_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_stmt_subject_expr.py.snap @@ -64,6 +64,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -122,6 +123,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -176,6 +178,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), cases: [ @@ -205,6 +208,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -254,11 +258,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_stmt_valid_guard_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_stmt_valid_guard_expr.py.snap index 643a0bac5bb0bd..ed434629866e83 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_stmt_valid_guard_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@match_stmt_valid_guard_expr.py.snap @@ -79,6 +79,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -158,6 +159,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -215,6 +217,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -222,6 +226,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -249,6 +254,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -315,11 +321,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@multiple_assignment_in_case_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@multiple_assignment_in_case_pattern.py.snap index a37747203d7a09..a45b1c574c6c18 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@multiple_assignment_in_case_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@multiple_assignment_in_case_pattern.py.snap @@ -65,6 +65,9 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), MatchSequence( @@ -87,6 +90,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchAs( @@ -104,6 +108,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -121,11 +126,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@multiple_starred_assignment_target.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@multiple_starred_assignment_target.py.snap index ee5dde4187d277..4aa2682878edd7 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@multiple_starred_assignment_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@multiple_starred_assignment_target.py.snap @@ -46,6 +46,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -75,8 +76,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -120,6 +125,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), Starred( @@ -140,6 +146,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), ], @@ -165,6 +172,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), NumberLiteral( @@ -178,11 +186,16 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_alternative_patterns.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_alternative_patterns.py.snap index b685a0656d268b..233dc40eed6ded 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_alternative_patterns.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_alternative_patterns.py.snap @@ -108,6 +108,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchMapping( @@ -154,13 +156,18 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchMapping( @@ -207,9 +214,12 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -227,6 +237,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -283,6 +294,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -305,12 +317,15 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), MatchAs( @@ -328,6 +343,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -345,6 +361,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -420,9 +437,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -445,12 +464,15 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), MatchAs( @@ -468,6 +490,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -485,6 +508,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -588,6 +612,9 @@ Module( patterns: [], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), MatchClass( @@ -620,14 +647,21 @@ Module( patterns: [], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), MatchClass( @@ -675,9 +709,13 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -695,11 +733,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_async_comprehension_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_async_comprehension_py310.py.snap index 9c269d6c6997a6..2ff1f461ad12b4 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_async_comprehension_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_async_comprehension_py310.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -88,11 +89,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -154,11 +159,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -166,6 +175,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -188,6 +201,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -211,6 +225,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -227,6 +242,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -284,11 +303,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -296,9 +319,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_async_comprehension_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_async_comprehension_py311.py.snap index e1b30a4094c89c..86eafcccbd4e66 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_async_comprehension_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nested_async_comprehension_py311.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -92,11 +93,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -140,11 +145,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -153,6 +162,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -175,6 +188,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -248,11 +262,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -296,11 +314,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -309,6 +331,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -331,6 +357,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -393,11 +420,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -441,11 +472,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -454,9 +489,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_duplicate_keyword_args.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_duplicate_keyword_args.py.snap index 244f8063cbcb89..5823fd3f336d42 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_duplicate_keyword_args.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_duplicate_keyword_args.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -46,6 +48,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -62,6 +65,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -106,6 +113,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -140,6 +149,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -155,6 +166,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -170,6 +183,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -177,6 +192,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -193,6 +209,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), Expr( @@ -287,12 +307,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_duplicate_type_parameter_names.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_duplicate_type_parameter_names.py.snap index 91e9cabf5594a6..637e8de75743e6 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_duplicate_type_parameter_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_duplicate_type_parameter_names.py.snap @@ -41,6 +41,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Subscript( @@ -98,6 +99,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -126,6 +128,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -133,6 +137,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -149,6 +154,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -180,6 +189,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -197,6 +207,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -254,6 +266,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: None, @@ -271,6 +284,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), TypeAlias( @@ -359,6 +374,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -412,6 +428,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: EllipsisLiteral( @@ -423,6 +440,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_nested_quote_in_format_spec_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_nested_quote_in_format_spec_py311.py.snap index 747113b161c313..72381d18f9a350 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_nested_quote_in_format_spec_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_nested_quote_in_format_spec_py311.py.snap @@ -54,6 +54,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -66,11 +69,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_rebound_comprehension_variable.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_rebound_comprehension_variable.py.snap index 32f31b1690e9db..bc2e33a9a24a95 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_rebound_comprehension_variable.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@non_rebound_comprehension_variable.py.snap @@ -80,11 +80,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -92,6 +96,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nonlocal_declaration_at_module_level.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nonlocal_declaration_at_module_level.py.snap index f8015717e31d88..e6a85424c28daa 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nonlocal_declaration_at_module_level.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nonlocal_declaration_at_module_level.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -47,9 +48,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nonlocal_stmt.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nonlocal_stmt.py.snap index da1fa3289ecccf..78849e47495e38 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@nonlocal_stmt.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@nonlocal_stmt.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -70,9 +71,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@other__atom.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@other__atom.py.snap index 07f19ba72a9576..7ce5bf79f1fd30 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@other__atom.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@other__atom.py.snap @@ -61,6 +61,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@other__decorator.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@other__decorator.py.snap index f90d87e8c7e01b..79c3253b875091 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@other__decorator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@other__decorator.py.snap @@ -43,6 +43,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -53,6 +54,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -88,6 +93,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), FunctionDef( @@ -123,6 +130,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -139,6 +147,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -198,6 +210,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -214,6 +227,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -285,6 +302,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -301,6 +319,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -407,6 +429,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), FunctionDef( @@ -500,6 +524,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -507,6 +533,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -546,6 +573,7 @@ Module( }, ), ], + runtime_values: None, }, ), }, @@ -610,6 +638,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -628,6 +657,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -644,6 +674,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -694,6 +728,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -710,6 +745,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -757,6 +796,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -773,9 +813,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_annotation.py.snap index 03b7fab965ca2e..983b08b4e4938b 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_annotation.py.snap @@ -48,6 +48,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -55,6 +57,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -71,6 +74,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -124,6 +131,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -131,6 +140,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -144,6 +154,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -151,6 +163,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -167,9 +180,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_default.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_default.py.snap index 97ade218634149..2c896a71605807 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_default.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( Lambda( @@ -63,6 +65,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -70,6 +74,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -88,6 +93,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -104,6 +110,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -135,6 +145,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( If( @@ -174,6 +186,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -190,6 +203,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -221,6 +238,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( Await( @@ -243,6 +262,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -259,6 +279,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -290,6 +314,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( Yield( @@ -314,6 +340,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -330,9 +357,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation.py.snap index 6a3c7ccc9c98e2..df934c99d4c4e9 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation.py.snap @@ -68,10 +68,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -88,6 +91,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -144,16 +151,20 @@ Module( }, ), ], + runtime_values: None, }, ), ctx: Load, }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -170,9 +181,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation_py310.py.snap index 077d25796bcc5e..23d849135dd21d 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation_py310.py.snap @@ -45,6 +45,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), FunctionDef( @@ -83,10 +84,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -103,6 +107,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -169,10 +177,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -189,6 +200,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -267,16 +282,20 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -293,6 +312,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -331,6 +354,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], @@ -353,8 +378,11 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -371,6 +399,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -424,10 +456,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -444,9 +479,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation_py311.py.snap index 0853afb16c6b09..bbb0d31bca897c 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@param_with_star_annotation_py311.py.snap @@ -53,10 +53,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -73,9 +76,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@params_non_default_after_star.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@params_non_default_after_star.py.snap index fba5d8d3ecdbe9..c3213bdda9a7c6 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@params_non_default_after_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@params_non_default_after_star.py.snap @@ -39,6 +39,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -67,6 +69,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -82,6 +86,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -107,11 +113,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -128,6 +137,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -159,6 +172,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -183,6 +198,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -198,6 +215,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -213,6 +232,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -238,11 +259,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -259,9 +283,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@params_seen_keyword_only_param_after_star.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@params_seen_keyword_only_param_after_star.py.snap index 755948038868a4..f88551bf776a96 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@params_seen_keyword_only_param_after_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@params_seen_keyword_only_param_after_star.py.snap @@ -41,6 +41,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -55,8 +57,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -73,6 +78,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -106,6 +115,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -130,8 +141,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -148,9 +162,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_context_manager_py39.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_context_manager_py39.py.snap index 9d627ba68f530f..4ffb547bbb9d1c 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_context_manager_py39.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_context_manager_py39.py.snap @@ -75,6 +75,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -133,6 +136,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -191,9 +197,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_kwarg_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_kwarg_py37.py.snap index 91e6d3ec220e87..e2075af26fba70 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_kwarg_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_kwarg_py37.py.snap @@ -52,12 +52,15 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_named_expr_index_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_named_expr_index_py38.py.snap index a422908b73639b..c16c04411c72ad 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_named_expr_index_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_named_expr_index_py38.py.snap @@ -55,6 +55,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_named_expr_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_named_expr_py38.py.snap index 1f14d31def9b35..af44edcde324f1 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_named_expr_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_named_expr_py38.py.snap @@ -61,6 +61,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -134,11 +135,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -146,6 +151,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_star_index_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_star_index_py310.py.snap index cfae3dd052d1ff..0fac3250d3084b 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_star_index_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@parenthesized_star_index_py310.py.snap @@ -64,6 +64,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -106,11 +108,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -137,6 +143,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ctx: Store, @@ -152,9 +159,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep701_f_string_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep701_f_string_py311.py.snap index c910744aa47b0f..b7a622677ee8e6 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep701_f_string_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep701_f_string_py311.py.snap @@ -59,6 +59,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -71,6 +74,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -143,6 +148,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -155,6 +163,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -167,6 +178,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -241,6 +254,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -253,11 +269,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -270,11 +291,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -287,6 +313,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -400,6 +428,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -419,11 +450,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -443,11 +479,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -460,11 +501,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -484,6 +530,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -518,6 +566,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -530,6 +581,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -570,6 +623,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -589,6 +645,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -624,6 +682,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -672,6 +732,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -684,6 +747,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -732,6 +797,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -744,11 +812,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep701_f_string_py312.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep701_f_string_py312.py.snap index 18d2a0eeffb7f8..01ab7806853dbf 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep701_f_string_py312.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep701_f_string_py312.py.snap @@ -74,6 +74,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -86,6 +89,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -159,12 +164,17 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -177,6 +187,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -245,6 +257,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -257,6 +272,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -377,6 +394,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -389,11 +409,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -406,11 +431,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -423,11 +453,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -440,11 +475,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -457,11 +497,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -474,6 +519,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -534,6 +581,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -553,11 +603,16 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -577,6 +632,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -611,6 +668,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -623,6 +683,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -663,6 +725,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -682,11 +747,14 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep750_t_string_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep750_t_string_py314.py.snap index 0d5db2d14d437d..4c1f6bd03cd424 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep750_t_string_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep750_t_string_py314.py.snap @@ -74,6 +74,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -86,6 +89,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -159,12 +164,17 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -177,6 +187,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -245,6 +257,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -257,6 +272,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -377,6 +394,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -389,11 +409,16 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -406,11 +431,16 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -423,11 +453,16 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -440,11 +475,16 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -457,11 +497,16 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -474,6 +519,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -534,6 +581,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -553,11 +603,16 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -577,6 +632,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -617,6 +674,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -636,11 +696,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep_798_unpacking_comprehensions_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep_798_unpacking_comprehensions_py315.py.snap index 7ed54cd39f48a5..a761da49682a48 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep_798_unpacking_comprehensions_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pep_798_unpacking_comprehensions_py315.py.snap @@ -55,6 +55,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -106,6 +108,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -151,6 +155,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -202,6 +208,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -270,6 +278,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: false, @@ -277,6 +287,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -327,6 +339,8 @@ Module( ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -378,6 +392,8 @@ Module( ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -423,6 +439,8 @@ Module( ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -474,6 +492,8 @@ Module( ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -482,6 +502,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pos_only_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pos_only_py38.py.snap index fbf17fc8613eb1..71c2aa705d6f6d 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@pos_only_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@pos_only_py38.py.snap @@ -38,6 +38,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -46,6 +48,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -62,9 +65,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@read_from_debug.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@read_from_debug.py.snap index 993a3512aacca6..3473e8088041f1 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@read_from_debug.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@read_from_debug.py.snap @@ -37,6 +37,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Assign( @@ -61,9 +62,13 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@simple_stmts_in_block.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@simple_stmts_in_block.py.snap index 6dbd6b9fbffe8e..1bd1ec2f014519 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@simple_stmts_in_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@simple_stmts_in_block.py.snap @@ -30,6 +30,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -52,6 +53,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -80,6 +82,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -108,6 +111,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Assign( @@ -133,9 +137,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@simple_stmts_with_semicolons.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@simple_stmts_with_semicolons.py.snap index d86dd6c0a6e4e6..3b4fb026505f04 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@simple_stmts_with_semicolons.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@simple_stmts_with_semicolons.py.snap @@ -61,6 +61,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), Expr( @@ -101,6 +102,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_parenthesized_item_context_manager_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_parenthesized_item_context_manager_py38.py.snap index 09e2f6d782eaa5..8be6e6c68a9b38 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_parenthesized_item_context_manager_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_parenthesized_item_context_manager_py38.py.snap @@ -58,6 +58,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -87,6 +89,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -137,6 +142,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -157,9 +164,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_star_in_tuple.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_star_in_tuple.py.snap index ca0b875086d1b6..949488d3c152d5 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_star_in_tuple.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_star_in_tuple.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -65,6 +66,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -73,6 +75,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -95,6 +101,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -126,12 +133,17 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), For( @@ -170,6 +182,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), body: [ @@ -187,6 +200,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -217,6 +234,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), iter: Name( @@ -242,9 +260,14 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_starred_assignment_target.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_starred_assignment_target.py.snap index 05dfde51fa531e..08113224b4da6e 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_starred_assignment_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@single_starred_assignment_target.py.snap @@ -38,6 +38,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -58,8 +59,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -90,6 +95,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), ], @@ -110,8 +116,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -141,6 +151,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], @@ -161,11 +172,16 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@star_index_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@star_index_py311.py.snap index 562a74ae6de00a..f1399d369a4d61 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@star_index_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@star_index_py311.py.snap @@ -49,6 +49,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -115,6 +116,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -122,6 +124,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -138,6 +142,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), Expr( @@ -195,6 +201,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -257,6 +264,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -318,6 +326,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -393,6 +402,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -401,6 +411,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@starred_comprehension_target.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@starred_comprehension_target.py.snap index 12e7c1d476f209..045e63c2d7095b 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@starred_comprehension_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@starred_comprehension_target.py.snap @@ -53,6 +53,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), iter: Name( @@ -65,6 +66,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -72,6 +75,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@starred_list_comp_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@starred_list_comp_py315.py.snap index 650604e3be2180..613eefdb113190 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@starred_list_comp_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@starred_list_comp_py315.py.snap @@ -55,6 +55,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -118,6 +120,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -125,6 +129,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__ambiguous_lpar_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__ambiguous_lpar_with_items.py.snap index 306cefa984448c..a4ab7ed2e3bfba 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__ambiguous_lpar_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__ambiguous_lpar_with_items.py.snap @@ -44,6 +44,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -80,6 +83,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -116,6 +122,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -165,6 +174,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -214,6 +226,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -298,6 +313,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -333,6 +351,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -365,6 +384,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -400,6 +422,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -428,6 +451,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -495,6 +521,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -562,6 +591,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -599,6 +631,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), optional_vars: None, @@ -618,6 +651,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -669,6 +705,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -711,6 +750,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -730,6 +770,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -764,6 +807,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -783,6 +827,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -847,6 +894,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -920,6 +970,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -948,6 +1001,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -968,6 +1023,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -996,6 +1054,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1016,6 +1076,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1044,6 +1107,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1073,6 +1138,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1123,6 +1191,9 @@ Module( ], }, ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1135,6 +1206,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), optional_vars: None, @@ -1154,6 +1227,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1205,6 +1281,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1217,6 +1296,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), optional_vars: None, @@ -1236,6 +1317,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1298,11 +1382,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -1338,6 +1426,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1413,11 +1504,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -1440,6 +1535,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1515,11 +1613,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -1555,6 +1657,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1627,6 +1732,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1708,6 +1816,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1753,6 +1864,8 @@ Module( ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -1784,6 +1897,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1829,6 +1945,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1880,6 +1999,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1940,6 +2062,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -1991,6 +2116,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2055,6 +2183,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2110,6 +2241,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2130,6 +2263,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2185,6 +2321,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2214,6 +2352,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2242,6 +2383,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2262,6 +2405,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2290,6 +2436,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2319,6 +2467,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2347,6 +2498,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2376,6 +2529,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2457,6 +2613,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2507,6 +2666,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), slice: NumberLiteral( @@ -2538,6 +2698,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2588,6 +2751,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), slice: NumberLiteral( @@ -2628,6 +2792,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2677,6 +2844,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2727,6 +2897,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2774,6 +2946,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2794,6 +2968,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2838,6 +3015,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2882,6 +3062,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2924,6 +3107,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -2966,6 +3152,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3019,6 +3208,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3051,6 +3243,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -3082,6 +3275,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3100,6 +3296,7 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -3119,6 +3316,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3137,6 +3337,7 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -3165,6 +3366,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3207,6 +3411,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -3226,6 +3431,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3277,6 +3485,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -3296,6 +3505,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3346,6 +3558,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -3365,6 +3578,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3423,6 +3639,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -3451,6 +3668,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3478,6 +3698,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -3506,6 +3727,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3540,6 +3764,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -3559,6 +3784,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3593,6 +3821,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -3621,6 +3850,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3656,6 +3888,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -3684,6 +3917,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3719,6 +3955,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -3747,6 +3984,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3782,6 +4022,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -3814,6 +4055,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3854,6 +4098,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), Name( @@ -3867,6 +4112,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -3895,6 +4141,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -3922,6 +4171,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -3966,6 +4216,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -3994,6 +4245,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -4029,6 +4283,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -4079,6 +4334,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -4121,6 +4379,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -4140,6 +4399,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -4182,6 +4444,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -4210,6 +4473,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -4267,6 +4533,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -4286,6 +4553,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -4343,6 +4613,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: None, @@ -4362,6 +4633,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -4424,11 +4698,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -4451,6 +4729,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -4513,11 +4794,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: true, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -4540,6 +4825,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -4602,11 +4890,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], parenthesized: true, @@ -4642,9 +4934,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__annotated_assignment.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__annotated_assignment.py.snap index dfcabffa7688ba..0e92f837840116 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__annotated_assignment.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__annotated_assignment.py.snap @@ -32,6 +32,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -66,6 +67,7 @@ Module( ), ), simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -107,6 +109,7 @@ Module( ), value: None, simple: false, + runtime_simple: None, }, ), AnnAssign( @@ -177,10 +180,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -236,6 +241,7 @@ Module( ), ), simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -272,6 +278,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -279,6 +287,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -303,9 +312,11 @@ Module( ), ), simple: true, + runtime_simple: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__assert.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__assert.py.snap index 15f2dac6054a28..dc72f856f290ad 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__assert.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__assert.py.snap @@ -41,6 +41,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), msg: None, @@ -67,6 +68,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -100,6 +103,7 @@ Module( }, ), ], + runtime_values: None, }, ), msg: None, @@ -131,6 +135,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -138,6 +144,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -282,6 +289,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -289,6 +298,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -380,6 +390,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__assignment.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__assignment.py.snap index 7239c8b5307ec2..bc5f0437ca3dbd 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__assignment.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__assignment.py.snap @@ -59,8 +59,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -92,6 +96,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -130,8 +135,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -162,6 +171,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], @@ -200,8 +210,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -265,8 +279,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -333,8 +351,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -373,6 +395,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -411,8 +434,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -451,6 +478,7 @@ Module( ), ], ctx: Store, + runtime_elts: None, }, ), ], @@ -488,8 +516,12 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -529,6 +561,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -567,8 +600,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -610,6 +647,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -652,6 +692,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -720,8 +763,12 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -791,8 +838,12 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -830,6 +881,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -880,6 +934,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -905,6 +962,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -918,6 +978,7 @@ Module( range: 682..684, elts: [], ctx: Store, + runtime_elts: None, }, ), ], @@ -944,8 +1005,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -960,6 +1025,7 @@ Module( elts: [], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), ], @@ -986,8 +1052,12 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1019,6 +1089,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), ], @@ -1030,6 +1101,9 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -1062,9 +1136,13 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__augmented_assignment.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__augmented_assignment.py.snap index 3b4ad5727e073b..8048dbc62120fd 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__augmented_assignment.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__augmented_assignment.py.snap @@ -94,6 +94,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -161,6 +162,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -547,6 +549,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__class.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__class.py.snap index 9ce6fb674c9c45..5f405bb7fc8068 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__class.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__class.py.snap @@ -36,6 +36,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -55,6 +57,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -87,6 +91,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -94,6 +100,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -104,9 +111,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -176,6 +189,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -192,6 +207,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -227,6 +244,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -259,6 +277,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), ], @@ -270,12 +289,21 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -312,6 +340,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -344,6 +374,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -351,6 +383,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -361,6 +394,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -392,6 +429,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -407,6 +446,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( StringLiteral( @@ -436,6 +477,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -446,9 +488,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -480,6 +528,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -488,6 +537,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -504,6 +555,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -544,6 +597,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -552,6 +606,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -568,6 +624,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -608,6 +666,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -616,6 +675,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -632,6 +693,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -696,6 +759,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -704,6 +768,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -720,6 +786,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -771,6 +839,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -778,6 +847,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -786,6 +856,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -802,6 +874,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -846,6 +920,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -854,6 +929,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -870,6 +947,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -914,6 +993,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -922,6 +1002,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -938,6 +1020,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -968,6 +1052,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -976,6 +1061,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -992,6 +1079,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -1067,6 +1156,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -1079,6 +1169,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -1087,6 +1178,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -1103,6 +1196,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -1170,6 +1265,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -1182,6 +1278,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -1190,6 +1287,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -1206,6 +1305,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -1236,6 +1337,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -1244,6 +1346,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -1260,6 +1364,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -1310,12 +1416,14 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ), }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -1324,6 +1432,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -1340,6 +1450,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -1417,6 +1529,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -1425,6 +1538,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -1435,9 +1550,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__delete.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__delete.py.snap index 50f3cb4b0bacc0..46156de2f749b0 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__delete.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__delete.py.snap @@ -24,6 +24,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Delete( @@ -40,6 +41,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Delete( @@ -64,6 +66,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Delete( @@ -103,6 +106,7 @@ Module( ], ctx: Del, parenthesized: true, + runtime_elts: None, }, ), Name( @@ -114,6 +118,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Delete( @@ -144,9 +149,11 @@ Module( ), ], ctx: Del, + runtime_elts: None, }, ), ], + runtime_targets: None, }, ), Delete( @@ -190,6 +197,7 @@ Module( ), ], ctx: Del, + runtime_elts: None, }, ), Name( @@ -202,9 +210,11 @@ Module( ), ], ctx: Del, + runtime_elts: None, }, ), ], + runtime_targets: None, }, ), Delete( @@ -233,6 +243,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Delete( @@ -264,6 +275,7 @@ Module( }, ), ], + runtime_targets: None, }, ), Delete( @@ -330,12 +342,15 @@ Module( ], ctx: Del, parenthesized: true, + runtime_elts: None, }, ), ], + runtime_targets: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__for.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__for.py.snap index c190c59f466bfc..bdcac42540c106 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__for.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__for.py.snap @@ -40,6 +40,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -90,6 +94,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), body: [ @@ -101,6 +106,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -145,6 +154,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -157,6 +168,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -217,6 +232,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -257,6 +276,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), body: [ @@ -268,6 +288,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -306,6 +330,7 @@ Module( }, ), ], + runtime_values: None, }, ), body: [ @@ -317,6 +342,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -356,6 +385,7 @@ Module( ], ctx: Store, parenthesized: false, + runtime_elts: None, }, ), iter: Name( @@ -375,6 +405,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -406,6 +440,7 @@ Module( ], ctx: Store, parenthesized: true, + runtime_elts: None, }, ), iter: Name( @@ -425,6 +460,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -465,6 +504,7 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), body: [ @@ -476,6 +516,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -520,6 +564,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -557,6 +605,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -564,6 +614,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -591,6 +642,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), For( @@ -650,6 +705,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), If( @@ -695,6 +754,10 @@ Module( ), ], orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, }, ), ], @@ -711,11 +774,15 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__from_import.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__from_import.py.snap index f0dda690b36298..9ee437da0a15d4 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__from_import.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__from_import.py.snap @@ -35,6 +35,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -56,6 +57,7 @@ Module( ], level: 1, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -105,6 +107,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -132,6 +135,7 @@ Module( ], level: 1, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -153,6 +157,7 @@ Module( ], level: 3, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -174,6 +179,7 @@ Module( ], level: 26, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -201,6 +207,7 @@ Module( ], level: 26, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -254,6 +261,7 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ImportFrom( @@ -281,9 +289,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__function.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__function.py.snap index b115bcc40987f1..25b4bd7b18a1ec 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__function.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__function.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -40,6 +41,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -71,6 +76,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -86,6 +93,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -101,6 +110,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -108,6 +119,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -118,6 +130,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -149,6 +165,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -164,6 +182,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -189,6 +209,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -206,6 +228,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -216,6 +239,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -246,6 +273,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -261,6 +290,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -288,6 +319,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -305,6 +338,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -315,6 +349,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -345,6 +383,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -362,6 +402,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -377,6 +419,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -384,6 +428,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -394,6 +439,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -424,6 +473,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -439,6 +490,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -466,6 +519,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -490,6 +545,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], @@ -503,8 +560,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -515,6 +575,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -548,6 +612,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -563,6 +629,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -578,11 +646,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -593,6 +664,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -626,6 +701,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -641,6 +718,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -666,6 +745,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -681,6 +762,7 @@ Module( }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -691,6 +773,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -720,6 +806,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -735,6 +823,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -750,6 +840,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -775,6 +867,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -790,6 +884,7 @@ Module( }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -800,6 +895,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -833,6 +932,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -848,6 +949,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -873,6 +976,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -897,8 +1002,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -909,6 +1017,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -938,6 +1050,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -953,6 +1067,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -968,6 +1084,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -993,6 +1111,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1017,8 +1137,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -1029,6 +1152,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1059,6 +1186,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1074,6 +1203,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1091,6 +1222,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1109,6 +1242,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1124,6 +1259,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1139,11 +1276,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1154,6 +1294,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1184,6 +1328,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1199,6 +1345,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1216,6 +1364,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1234,6 +1384,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1249,6 +1401,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1274,6 +1428,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1289,6 +1445,7 @@ Module( }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1299,6 +1456,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1329,6 +1490,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1344,6 +1507,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1361,6 +1526,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1375,6 +1542,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -1390,6 +1559,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1405,6 +1576,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1430,6 +1603,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1445,6 +1620,7 @@ Module( }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1455,6 +1631,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1485,6 +1665,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1500,6 +1682,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1517,6 +1701,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1535,6 +1721,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1550,6 +1738,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1575,6 +1765,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1599,8 +1791,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -1611,6 +1806,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1641,6 +1840,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1656,6 +1857,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1673,6 +1876,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1687,6 +1892,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -1702,6 +1909,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1717,6 +1926,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1742,6 +1953,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -1766,8 +1979,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -1778,6 +1994,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1809,6 +2029,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1824,6 +2046,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1839,6 +2063,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1857,6 +2083,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1872,6 +2100,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1887,11 +2117,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -1902,6 +2135,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -1933,6 +2170,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1948,6 +2187,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1963,6 +2204,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1981,6 +2224,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1996,6 +2241,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -2021,6 +2268,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -2036,6 +2285,7 @@ Module( }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -2046,6 +2296,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -2077,6 +2331,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2092,6 +2348,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2107,6 +2365,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2121,6 +2381,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -2136,6 +2398,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2151,6 +2415,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -2176,6 +2442,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -2191,6 +2459,7 @@ Module( }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -2201,6 +2470,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -2232,6 +2505,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2247,6 +2522,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2262,6 +2539,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2276,6 +2555,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [ @@ -2291,6 +2572,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2306,6 +2589,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -2331,6 +2616,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -2355,8 +2642,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -2367,6 +2657,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -2399,6 +2693,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -2427,6 +2722,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2434,6 +2731,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Name( @@ -2453,6 +2751,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -2494,6 +2796,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -2522,6 +2825,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2529,6 +2834,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Name( @@ -2548,6 +2854,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -2600,6 +2910,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -2607,6 +2918,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -2635,6 +2947,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2642,6 +2956,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Name( @@ -2661,6 +2976,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -2692,6 +3011,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -2725,10 +3045,13 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Subscript( @@ -2766,6 +3089,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -2780,6 +3104,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -2811,6 +3139,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -2849,6 +3178,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], @@ -2883,8 +3214,11 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -2895,6 +3229,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -2973,6 +3311,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -2983,6 +3322,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -2993,6 +3333,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3015,6 +3359,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -3031,6 +3376,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3053,6 +3402,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Name( @@ -3086,6 +3436,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -3110,6 +3462,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3139,10 +3495,13 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -3153,6 +3512,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3184,8 +3547,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -3196,6 +3562,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3225,6 +3595,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), kwonlyargs: [], @@ -3238,8 +3610,11 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), + runtime_defaults: None, }, returns: None, body: [ @@ -3250,6 +3625,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3280,6 +3659,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3288,6 +3669,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -3298,6 +3680,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3328,6 +3714,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3345,6 +3733,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3352,6 +3742,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -3362,6 +3753,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3392,6 +3787,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -3410,6 +3807,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -3420,6 +3818,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3450,6 +3852,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3465,6 +3869,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3484,11 +3890,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -3499,6 +3908,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3530,6 +3943,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -3558,11 +3973,14 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, ], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -3573,6 +3991,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3613,6 +4035,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3650,6 +4074,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3691,6 +4117,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3698,6 +4126,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -3708,6 +4137,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -3739,6 +4172,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3754,6 +4189,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -3779,6 +4216,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -3804,6 +4243,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: Some( NumberLiteral( @@ -3821,6 +4262,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -3831,9 +4273,14 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__if.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__if.py.snap index f2075c88437e18..4a8400024fe4f8 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__if.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__if.py.snap @@ -72,6 +72,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ElifElseClause { range: 20..28, @@ -94,8 +96,11 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), If( @@ -139,6 +144,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -171,6 +177,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), body: [ @@ -200,8 +207,11 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), If( @@ -252,8 +262,11 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), If( @@ -283,6 +296,7 @@ Module( }, ), ], + runtime_values: None, }, ), body: [ @@ -326,6 +340,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ElifElseClause { range: 158..173, @@ -354,6 +370,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ElifElseClause { range: 174..189, @@ -382,6 +400,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ElifElseClause { range: 190..203, @@ -409,14 +429,19 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), If( @@ -501,8 +526,11 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), If( @@ -531,6 +559,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -538,6 +568,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -591,6 +622,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -598,6 +631,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -625,8 +659,11 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), If( @@ -695,8 +732,11 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), If( @@ -769,11 +809,15 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__import.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__import.py.snap index 6a04816af68695..c2ecb48397bc2f 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__import.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__import.py.snap @@ -154,6 +154,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__match.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__match.py.snap index 695d20ca9079d4..18dc9196a33641 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__match.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__match.py.snap @@ -74,9 +74,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -130,6 +134,9 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -157,9 +164,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -230,9 +241,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 234..260, @@ -287,9 +302,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -377,6 +396,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -402,9 +422,13 @@ Module( value: true, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -466,6 +490,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchSequence( @@ -504,9 +529,11 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -534,9 +561,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -570,6 +601,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -604,6 +636,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 494..523, @@ -615,6 +648,8 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -649,6 +684,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -727,13 +763,18 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -761,9 +802,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 599..687, @@ -836,9 +881,12 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), MatchSingleton( @@ -849,10 +897,13 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchMapping( @@ -881,13 +932,17 @@ Module( node_index: NodeIndex(None), range: 634..636, patterns: [], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchMapping( @@ -948,13 +1003,18 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchSequence( @@ -962,6 +1022,7 @@ Module( node_index: NodeIndex(None), range: 659..661, patterns: [], + runtime_patterns: None, }, ), MatchValue( @@ -998,9 +1059,12 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -1028,9 +1092,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 692..714, @@ -1040,6 +1108,7 @@ Module( node_index: NodeIndex(None), range: 697..699, patterns: [], + runtime_patterns: None, }, ), guard: None, @@ -1067,9 +1136,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -1147,9 +1220,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -1218,9 +1295,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -1308,6 +1389,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -1333,9 +1415,13 @@ Module( value: true, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -1405,9 +1491,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -1461,6 +1551,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -1488,9 +1580,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 1042..1068, @@ -1528,6 +1624,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -1555,9 +1653,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 1073..1098, @@ -1575,6 +1677,8 @@ Module( node_index: NodeIndex(None), }, ), + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -1602,9 +1706,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -1630,6 +1738,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1650,6 +1760,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -1677,9 +1788,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -1740,9 +1855,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 1224..1245, @@ -1787,9 +1906,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -1854,6 +1977,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -1880,9 +2005,13 @@ Module( ctx: Load, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -1926,6 +2055,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), cases: [ @@ -1996,6 +2126,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -2023,9 +2154,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -2067,6 +2202,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -2094,9 +2230,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 1456..1498, @@ -2137,6 +2277,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: Some( @@ -2213,9 +2354,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 1503..1529, @@ -2256,6 +2401,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -2283,9 +2429,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -2347,6 +2497,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -2374,9 +2525,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -2461,9 +2616,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -2488,6 +2647,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), cases: [ @@ -2514,6 +2674,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -2541,9 +2702,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -2639,9 +2804,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -2694,9 +2863,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -2757,9 +2930,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -2812,9 +2989,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -2840,6 +3021,7 @@ Module( node_index: NodeIndex(None), range: 2008..2010, patterns: [], + runtime_patterns: None, }, ), guard: None, @@ -2867,9 +3049,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 2030..2054, @@ -2907,6 +3093,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -2934,9 +3121,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 2059..2081, @@ -2993,9 +3184,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -3055,9 +3250,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -3125,6 +3324,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -3152,9 +3352,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -3271,6 +3475,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: Some( @@ -3315,6 +3520,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ), @@ -3342,9 +3548,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -3423,13 +3633,18 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -3457,9 +3672,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 2383..2472, @@ -3532,9 +3751,12 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), MatchSingleton( @@ -3545,10 +3767,13 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchMapping( @@ -3577,13 +3802,17 @@ Module( node_index: NodeIndex(None), range: 2419..2421, patterns: [], + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchMapping( @@ -3644,13 +3873,18 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), MatchSequence( @@ -3658,6 +3892,7 @@ Module( node_index: NodeIndex(None), range: 2444..2446, patterns: [], + runtime_patterns: None, }, ), MatchValue( @@ -3694,9 +3929,12 @@ Module( keys: [], patterns: [], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -3724,9 +3962,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, MatchCase { range: 2477..2499, @@ -3736,6 +3978,7 @@ Module( node_index: NodeIndex(None), range: 2482..2484, patterns: [], + runtime_patterns: None, }, ), guard: None, @@ -3763,9 +4006,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -3809,6 +4056,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), cases: [ @@ -3849,6 +4097,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -3876,9 +4125,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -3922,6 +4175,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), cases: [ @@ -3962,6 +4216,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -3989,9 +4244,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -4016,6 +4275,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), cases: [ @@ -4042,6 +4302,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -4069,9 +4330,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -4104,6 +4369,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), cases: [ @@ -4144,6 +4410,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -4171,9 +4438,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -4212,6 +4483,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), cases: [ @@ -4253,6 +4525,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -4280,9 +4553,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -4332,6 +4609,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -4344,6 +4624,8 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), }, @@ -4357,6 +4639,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -4405,6 +4688,7 @@ Module( ), }, ], + runtime_values: None, }, ), cases: [ @@ -4424,6 +4708,8 @@ Module( node_index: NodeIndex(None), }, ), + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -4458,12 +4744,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ], }, @@ -4524,6 +4813,7 @@ Module( ), }, ], + runtime_values: None, }, ), cases: [ @@ -4586,6 +4876,9 @@ Module( patterns: [], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), MatchSingleton( @@ -4596,6 +4889,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), ), @@ -4610,6 +4904,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -4644,12 +4940,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ], }, @@ -4706,6 +5005,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -4733,9 +5033,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -4792,6 +5096,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -4819,9 +5124,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -4863,6 +5172,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -4890,9 +5200,13 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), ], + runtime_body: None, }, ], }, @@ -4917,6 +5231,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), cases: [ @@ -4946,6 +5261,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -4978,6 +5294,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), cases: [ @@ -5007,6 +5324,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -5039,6 +5357,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), cases: [ @@ -5068,6 +5387,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -5110,6 +5430,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3425..3447, @@ -5136,6 +5457,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3452..3475, @@ -5162,6 +5484,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -5223,6 +5546,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3536..3559, @@ -5280,6 +5604,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3564..3584, @@ -5326,6 +5651,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3589..3610, @@ -5372,6 +5698,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3615..3634, @@ -5406,6 +5733,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3639..3660, @@ -5440,6 +5768,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3665..3687, @@ -5475,6 +5804,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3692..3716, @@ -5526,6 +5856,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3721..3741, @@ -5567,6 +5898,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3746..3767, @@ -5608,6 +5940,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3772..3795, @@ -5649,6 +5982,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3800..3821, @@ -5683,6 +6017,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -5739,6 +6074,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -5756,6 +6092,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 3881..3927, @@ -5888,6 +6225,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -5905,6 +6243,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -5954,6 +6293,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -6018,6 +6358,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -6079,6 +6420,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), ), @@ -6106,6 +6448,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4065..4096, @@ -6172,6 +6515,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4101..4128, @@ -6232,6 +6576,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4133..4157, @@ -6274,6 +6619,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -6317,6 +6663,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -6388,6 +6735,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -6405,6 +6753,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4258..4286, @@ -6460,6 +6809,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -6477,6 +6827,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4291..4331, @@ -6566,6 +6917,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -6583,6 +6935,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4336..4370, @@ -6642,6 +6995,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), ), @@ -6669,6 +7023,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4375..4407, @@ -6741,6 +7096,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -6758,6 +7114,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4412..4440, @@ -6803,6 +7160,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), MatchValue( @@ -6821,6 +7179,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -6838,6 +7197,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4445..4466, @@ -6863,6 +7223,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -6880,6 +7241,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -6919,6 +7281,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -6936,6 +7299,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4526..4547, @@ -6953,6 +7317,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -6970,6 +7335,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4552..4583, @@ -7023,6 +7389,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -7040,6 +7407,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4588..4616, @@ -7087,6 +7455,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), guard: None, @@ -7104,6 +7473,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -7142,6 +7512,9 @@ Module( patterns: [], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -7159,6 +7532,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4681..4710, @@ -7205,6 +7579,9 @@ Module( patterns: [], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -7222,6 +7599,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4715..4745, @@ -7269,6 +7647,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -7286,6 +7667,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4750..4786, @@ -7357,6 +7739,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -7374,6 +7759,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4791..4822, @@ -7427,6 +7813,9 @@ Module( ], keywords: [], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -7444,6 +7833,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4827..4865, @@ -7500,6 +7890,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], @@ -7530,6 +7921,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -7547,6 +7941,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4870..4910, @@ -7612,6 +8007,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), }, @@ -7641,6 +8037,9 @@ Module( }, ], }, + runtime_patterns: None, + runtime_kwd_attrs: None, + runtime_kwd_patterns: None, }, ), guard: None, @@ -7658,6 +8057,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -7718,6 +8118,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -7735,6 +8137,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 4981..5028, @@ -7823,6 +8226,7 @@ Module( }, ), ], + runtime_patterns: None, }, ), ], @@ -7833,6 +8237,8 @@ Module( node_index: NodeIndex(None), }, ), + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -7850,6 +8256,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -7922,6 +8329,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 5085..5106, @@ -7968,6 +8376,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ), @@ -7985,6 +8394,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -8047,6 +8457,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -8109,6 +8520,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -8173,6 +8585,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -8341,6 +8755,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -8393,6 +8809,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -8437,10 +8855,13 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -8485,10 +8906,13 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -8579,6 +9003,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -8630,6 +9055,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ctx: Load, @@ -8670,6 +9096,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -8741,6 +9169,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Match( @@ -8783,6 +9212,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 5695..5715, @@ -8811,6 +9241,7 @@ Module( }, ), ], + runtime_body: None, }, ], }, @@ -8851,6 +9282,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -8858,6 +9291,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Compare( @@ -8885,10 +9319,14 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -8938,17 +9376,22 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__raise.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__raise.py.snap index 2a6b5c03b1b938..f142eb2f6fe682 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__raise.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__raise.py.snap @@ -64,6 +64,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -102,6 +103,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ), @@ -136,6 +138,7 @@ Module( }, ), ], + runtime_values: None, }, ), ), @@ -169,6 +172,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -176,6 +181,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -318,6 +324,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -365,6 +372,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ), @@ -408,6 +416,7 @@ Module( }, ), ], + runtime_values: None, }, ), ), @@ -450,6 +459,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -457,6 +468,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -552,6 +564,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__return.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__return.py.snap index e1c6e768fcebc1..0abb57949f8709 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__return.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__return.py.snap @@ -76,6 +76,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -154,6 +155,7 @@ Module( }, ), ], + runtime_values: None, }, ), ), @@ -191,6 +193,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), ), @@ -227,6 +230,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ), @@ -254,6 +258,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -294,6 +300,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -349,6 +357,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -356,6 +366,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -372,6 +383,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__simple.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__simple.py.snap index ee65e7f1fd4fee..ee393e08c678d1 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__simple.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__simple.py.snap @@ -49,6 +49,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), If( @@ -71,6 +72,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Expr( @@ -213,6 +215,7 @@ Module( }, ), ], + runtime_targets: None, }, ), ], @@ -237,8 +240,11 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), If( @@ -278,9 +284,11 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__try.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__try.py.snap index 0484a5941b0efa..0024032b20b907 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__try.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__try.py.snap @@ -49,12 +49,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -111,6 +116,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -148,12 +154,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -210,6 +221,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -232,6 +244,7 @@ Module( }, ), ], + runtime_body: None, }, ), ], @@ -251,6 +264,10 @@ Module( ), ], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -292,6 +309,7 @@ Module( }, ), ], + runtime_body: None, }, ), ], @@ -311,6 +329,10 @@ Module( ], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -352,6 +374,7 @@ Module( }, ), ], + runtime_body: None, }, ), ], @@ -384,6 +407,10 @@ Module( ), ], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -421,6 +448,10 @@ Module( ), ], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -471,6 +502,10 @@ Module( ), ], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -527,6 +562,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -558,12 +594,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -603,6 +644,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -701,12 +744,17 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -719,16 +767,21 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -820,12 +873,17 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -838,22 +896,31 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -935,6 +1002,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -965,6 +1034,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -995,6 +1066,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1025,15 +1098,20 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ], ctx: Load, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -1132,12 +1210,17 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1174,6 +1257,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1186,16 +1272,21 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -1287,12 +1378,17 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), Literal( @@ -1329,6 +1425,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -1341,22 +1440,31 @@ Module( }, ), }, + runtime_joined_str: None, + runtime_values: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: true, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), Try( @@ -1408,6 +1516,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -1434,6 +1543,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -1458,6 +1568,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -1500,6 +1611,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -1540,6 +1652,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -1570,6 +1683,7 @@ Module( }, ), ], + runtime_values: None, }, ), ), @@ -1582,6 +1696,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -1613,6 +1728,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -1642,6 +1758,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -1649,6 +1767,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -1671,6 +1790,7 @@ Module( }, ), ], + runtime_body: None, }, ), ExceptHandler( @@ -1717,12 +1837,17 @@ Module( }, ), ], + runtime_body: None, }, ), ], orelse: [], finalbody: [], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), If( @@ -1760,6 +1885,10 @@ Module( ), ], is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, }, ), ], @@ -1776,11 +1905,15 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__type.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__type.py.snap index d43c8c30bc93fd..05a7e8f46ea98a 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__type.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__type.py.snap @@ -153,6 +153,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: BinOp( @@ -241,6 +242,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -284,6 +286,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: BinOp( @@ -396,6 +399,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Tuple( @@ -430,6 +434,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -498,6 +503,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Tuple( @@ -532,6 +538,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -587,6 +594,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -618,6 +626,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Tuple( @@ -652,6 +661,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), }, @@ -696,6 +706,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: BinOp( @@ -787,6 +798,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: BinOp( @@ -896,6 +908,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -908,6 +921,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Subscript( @@ -961,6 +975,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -1018,12 +1033,14 @@ Module( ), ], ctx: Load, + runtime_elts: None, }, ), ), }, ), ], + runtime_type_params: None, }, ), value: Subscript( @@ -1062,6 +1079,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -1330,6 +1348,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -1373,6 +1392,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -1416,6 +1436,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -1534,6 +1555,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), TypeAlias( @@ -1585,6 +1608,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -1623,6 +1647,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Subscript( @@ -1661,6 +1686,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -1698,6 +1724,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Subscript( @@ -1736,6 +1763,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -1773,6 +1801,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Subscript( @@ -1818,6 +1847,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -1865,6 +1895,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Subscript( @@ -1943,6 +1974,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -1950,6 +1982,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Subscript( @@ -2035,6 +2068,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -2097,6 +2131,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, @@ -2161,6 +2196,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2329,6 +2366,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2381,6 +2420,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2425,10 +2466,13 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2473,10 +2517,13 @@ Module( elts: [], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2567,6 +2614,7 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), ctx: Load, @@ -2618,6 +2666,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ctx: Load, @@ -2658,6 +2707,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2729,6 +2780,7 @@ Module( ), ], elif_else_clauses: [], + runtime_body: None, }, ), Assign( @@ -2767,6 +2819,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -2774,6 +2828,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Compare( @@ -2801,10 +2856,14 @@ Module( }, ), ], + runtime_comparators: None, }, ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -2854,11 +2913,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2894,6 +2957,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -2938,8 +3003,12 @@ Module( }, ), ], + runtime_comparators: None, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -2982,9 +3051,14 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -3028,6 +3102,8 @@ Module( ), }, ], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -3056,6 +3132,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -3089,6 +3168,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Assign( @@ -3122,6 +3204,9 @@ Module( ), }, ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, ), Expr( @@ -3150,6 +3235,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -3157,6 +3244,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -3172,6 +3260,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__while.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__while.py.snap index 543ff6ee89baae..ff40ff7b764ac9 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__while.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__while.py.snap @@ -37,6 +37,8 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), While( @@ -75,6 +77,7 @@ Module( }, ), ], + runtime_comparators: None, }, ), Name( @@ -86,6 +89,7 @@ Module( }, ), ], + runtime_values: None, }, ), body: [ @@ -110,6 +114,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ), While( @@ -139,6 +145,7 @@ Module( }, ), ], + runtime_values: None, }, ), body: [ @@ -197,6 +204,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -247,6 +256,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -265,6 +276,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ), While( @@ -308,6 +321,8 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), While( @@ -351,6 +366,7 @@ Module( }, ), ], + runtime_values: None, }, ), body: [ @@ -368,6 +384,8 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), While( @@ -396,6 +414,8 @@ Module( node_index: NodeIndex(None), }, annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -403,6 +423,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, ), body: Name( @@ -430,6 +451,8 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), While( @@ -465,6 +488,8 @@ Module( ), ], orelse: [], + runtime_body: None, + runtime_orelse: None, }, ), If( @@ -507,6 +532,8 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ), ], @@ -523,11 +550,15 @@ Module( }, ), ], + runtime_body: None, + runtime_orelse: None, }, ], + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__with.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__with.py.snap index 7919e803c86e69..6a7ad34327b988 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__with.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@statement__with.py.snap @@ -44,6 +44,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -89,6 +92,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -138,6 +144,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -205,6 +214,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -262,6 +274,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -328,6 +343,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -356,6 +374,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -385,6 +405,9 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), With( @@ -413,6 +436,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), @@ -454,9 +479,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@template_strings_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@template_strings_py314.py.snap index e714e59451e567..b43823b8474c1d 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@template_strings_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@template_strings_py314.py.snap @@ -39,6 +39,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -51,6 +54,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -84,6 +89,9 @@ Module( debug_text: None, conversion: None, format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, }, ), ], @@ -96,6 +104,8 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, @@ -131,11 +141,14 @@ Module( }, ), }, + runtime_template_str: None, + runtime_values: None, }, ), }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@tuple_context_manager_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@tuple_context_manager_py38.py.snap index 230855ad42411e..4fe4642e0b1a23 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@tuple_context_manager_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@tuple_context_manager_py38.py.snap @@ -51,6 +51,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), optional_vars: Some( @@ -79,9 +80,13 @@ Module( }, ), ], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_default_py313.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_default_py313.py.snap index df2192d1fb2629..d7383a7ca264e0 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_default_py313.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_default_py313.py.snap @@ -50,6 +50,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -101,6 +102,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), parameters: Parameters { @@ -111,6 +113,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -127,6 +130,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ClassDef( @@ -167,6 +174,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), arguments: Some( @@ -175,6 +183,8 @@ Module( node_index: NodeIndex(None), args: [], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -191,9 +201,12 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_param_spec.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_param_spec.py.snap index abeecd80201392..e2fb9d35b742bd 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_param_spec.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_param_spec.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -91,6 +92,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -146,6 +148,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -210,6 +213,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -223,6 +227,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_type_var.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_type_var.py.snap index e3aad353421361..0104c3f30fd4c5 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_type_var.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_type_var.py.snap @@ -41,6 +41,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -93,6 +94,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -154,6 +156,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -217,6 +220,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -233,6 +237,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -327,6 +332,7 @@ Module( ], ctx: Load, parenthesized: true, + runtime_elts: None, }, ), ), @@ -343,6 +349,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -356,6 +363,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_type_var_tuple.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_type_var_tuple.py.snap index 715499e6fd2101..e70bb1ff777a10 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_type_var_tuple.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_param_type_var_tuple.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -91,6 +92,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -149,6 +151,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -204,6 +207,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -268,6 +272,7 @@ Module( }, ), ], + runtime_type_params: None, }, ), value: Name( @@ -281,6 +286,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_stmt_py312.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_stmt_py312.py.snap index c1849f86cc3122..a422a9436d1479 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_stmt_py312.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@type_stmt_py312.py.snap @@ -34,6 +34,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@unary_plus_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@unary_plus_py315.py.snap index 3454b5e0ad36c3..06c30dfda023a4 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@unary_plus_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@unary_plus_py315.py.snap @@ -63,6 +63,7 @@ Module( }, ), ], + runtime_body: None, }, MatchCase { range: 138..155, @@ -107,6 +108,8 @@ Module( ), ], rest: None, + runtime_keys: None, + runtime_patterns: None, }, ), guard: None, @@ -124,11 +127,13 @@ Module( }, ), ], + runtime_body: None, }, ], }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@unparenthesized_named_expr_index_py39.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@unparenthesized_named_expr_index_py39.py.snap index 1f121dbd2d8568..6931ce797ed5c7 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@unparenthesized_named_expr_index_py39.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@unparenthesized_named_expr_index_py39.py.snap @@ -55,6 +55,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@unparenthesized_named_expr_py39.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@unparenthesized_named_expr_py39.py.snap index e95fef868f1a9e..9882da1b407413 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@unparenthesized_named_expr_py39.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@unparenthesized_named_expr_py39.py.snap @@ -61,6 +61,7 @@ Module( }, ), ], + runtime_elts: None, }, ), }, @@ -134,11 +135,15 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, }, ), ifs: [], is_async: false, + runtime_ifs: None, + runtime_is_async: None, }, ], }, @@ -146,6 +151,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_class.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_class.py.snap index 87c63be67c4500..32fc3e65563838 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_class.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_class.py.snap @@ -50,6 +50,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -66,6 +68,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), FunctionDef( @@ -88,6 +92,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -126,6 +131,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -142,6 +149,8 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ClassDef( @@ -177,6 +186,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -193,9 +204,15 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -218,6 +235,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -254,6 +272,8 @@ Module( ), ], keywords: [], + runtime_args: None, + runtime_bases: None, }, ), body: [ @@ -270,12 +290,19 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_function_py313.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_function_py313.py.snap index c70dedf89f1484..81786ebbb1f1fe 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_function_py313.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_function_py313.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Named( @@ -70,6 +71,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -125,6 +130,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -132,6 +139,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -148,6 +156,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -170,6 +182,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -220,6 +233,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -227,6 +242,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -243,6 +259,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -265,6 +285,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Yield( @@ -299,6 +320,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -346,6 +371,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -353,6 +380,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -369,6 +397,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -391,6 +423,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( YieldFrom( @@ -423,9 +456,17 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -448,6 +489,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -471,6 +513,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: Some( Await( @@ -503,6 +546,10 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -550,6 +597,8 @@ Module( }, ), ), + runtime_type_comment: None, + runtime_type_comment_bytes: None, }, default: None, }, @@ -557,6 +606,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -573,12 +623,21 @@ Module( }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_py313.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_py313.py.snap index b8f364cf8bed09..f295038db3078f 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_py313.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_annotation_py313.py.snap @@ -47,6 +47,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), FunctionDef( @@ -69,6 +70,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -103,6 +105,7 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), AnnAssign( @@ -134,9 +137,14 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), FunctionDef( @@ -159,6 +167,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -191,12 +200,18 @@ Module( ), value: None, simple: true, + runtime_simple: None, }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_future_feature.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_future_feature.py.snap index 6ccb3ace97c0ba..e76157abcac125 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_future_feature.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@valid_future_feature.py.snap @@ -35,9 +35,11 @@ Module( ], level: 0, is_lazy: false, + runtime_level: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@walrus_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@walrus_py38.py.snap index 0dba7ff0cd00ef..844b80c29cefde 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@walrus_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@walrus_py38.py.snap @@ -40,6 +40,7 @@ Module( }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_parser/tests/snapshots/valid_syntax@yield_after_comma_parenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/valid_syntax@yield_after_comma_parenthesized.py.snap index a81d9c64dd58cc..b53c2c4bd706e1 100644 --- a/crates/ruff_python_parser/tests/snapshots/valid_syntax@yield_after_comma_parenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/valid_syntax@yield_after_comma_parenthesized.py.snap @@ -30,6 +30,7 @@ Module( vararg: None, kwonlyargs: [], kwarg: None, + runtime_defaults: None, }, returns: None, body: [ @@ -71,14 +72,20 @@ Module( ], ctx: Load, parenthesized: false, + runtime_elts: None, }, ), }, ), ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, }, ), ], + runtime_body: None, }, ) ``` diff --git a/crates/ruff_python_semantic/src/analyze/type_inference.rs b/crates/ruff_python_semantic/src/analyze/type_inference.rs index b2573a31db415f..27230ac5a0849e 100644 --- a/crates/ruff_python_semantic/src/analyze/type_inference.rs +++ b/crates/ruff_python_semantic/src/analyze/type_inference.rs @@ -342,6 +342,7 @@ impl From<&Expr> for ResolvedPythonType { ResolvedPythonType::Unknown } Expr::Lambda(_) + | Expr::Constant(_) | Expr::Await(_) | Expr::Yield(_) | Expr::YieldFrom(_) diff --git a/crates/ruff_python_semantic/src/imports.rs b/crates/ruff_python_semantic/src/imports.rs index 5fe53829296199..0c0d8f190ea264 100644 --- a/crates/ruff_python_semantic/src/imports.rs +++ b/crates/ruff_python_semantic/src/imports.rs @@ -232,6 +232,7 @@ impl<'de> serde::de::Deserialize<'de> for NameImports { is_lazy: _, range: _, node_index: _, + runtime_level: _, }) => names .iter() .map(|name| { diff --git a/crates/ruff_python_trivia/Cargo.toml b/crates/ruff_python_trivia/Cargo.toml index 97cc8eed2a1ba9..32c5619ccd3558 100644 --- a/crates/ruff_python_trivia/Cargo.toml +++ b/crates/ruff_python_trivia/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "ruff_python_trivia" -version = "0.0.16" -description = "This is an internal component crate of Ruff" +description = "Unofficial fork for RustPython" +name = "rustpython-ruff_python_trivia" +version = "0.16.10" authors = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } @@ -11,6 +11,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +name = "ruff_python_trivia" [dependencies] ruff_source_file = { workspace = true } diff --git a/crates/ruff_source_file/Cargo.toml b/crates/ruff_source_file/Cargo.toml index 67a3da546404a9..16e928ee200e62 100644 --- a/crates/ruff_source_file/Cargo.toml +++ b/crates/ruff_source_file/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "ruff_source_file" -version = "0.0.16" -description = "This is an internal component crate of Ruff" +description = "Unofficial fork for RustPython" +name = "rustpython-ruff_source_file" +version = "0.16.10" authors = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } @@ -11,6 +11,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +name = "ruff_source_file" [dependencies] ruff_text_size = { workspace = true } diff --git a/crates/ruff_text_size/Cargo.toml b/crates/ruff_text_size/Cargo.toml index 14f73e9efa090f..ec02d9db7aea8e 100644 --- a/crates/ruff_text_size/Cargo.toml +++ b/crates/ruff_text_size/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "ruff_text_size" -version = "0.0.16" -description = "This is an internal component crate of Ruff" +description = "Unofficial fork for RustPython" +name = "rustpython-ruff_text_size" +version = "0.16.10" authors = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } @@ -32,4 +32,5 @@ path = "tests/serde.rs" required-features = ["serde"] [lib] +name = "ruff_text_size" test = false diff --git a/crates/ty_module_resolver/src/module_name.rs b/crates/ty_module_resolver/src/module_name.rs index a476a460febbb6..490135c6f9595b 100644 --- a/crates/ty_module_resolver/src/module_name.rs +++ b/crates/ty_module_resolver/src/module_name.rs @@ -320,6 +320,7 @@ impl ModuleName { is_lazy: _, range: _, node_index: _, + runtime_level: _, } = node; Self::from_identifier_parts(db, importing_file, module.as_deref(), *level) } diff --git a/crates/ty_python_core/src/builder.rs b/crates/ty_python_core/src/builder.rs index e3ff3a964423de..3825cb0d8a927a 100644 --- a/crates/ty_python_core/src/builder.rs +++ b/crates/ty_python_core/src/builder.rs @@ -3854,6 +3854,10 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> { is_async: _, range: _, node_index: _, + runtime_decorator_list: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, } = function_def; for decorator in decorator_list { self.visit_decorator(decorator); @@ -4594,6 +4598,8 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> { orelse, range: _, node_index: _, + runtime_body: _, + runtime_orelse: _, }, ) => { // Pre-walk the loop to collect all the bound places, then create a loop header @@ -4772,6 +4778,10 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> { iter, body, orelse, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, + runtime_orelse: _, }, ) => { debug_assert_eq!(&self.current_assignments, &[]); @@ -5056,6 +5066,10 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> { is_star, range: _, node_index: _, + runtime_body: _, + runtime_handlers: _, + runtime_orelse: _, + runtime_finalbody: _, }) => { let was_in_try_statement = std::mem::replace(&mut self.in_try_statement, true); self.record_ambiguous_reachability(); @@ -5117,6 +5131,7 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> { body: handler_body, range: _, node_index: _, + runtime_body: _, } = except_handler; if let Some(handled_exceptions) = handled_exceptions { @@ -5448,6 +5463,7 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> { targets, range: _, node_index: _, + runtime_targets: _, }) => { // We will check the target expressions and then delete them. walk_stmt(self, stmt); @@ -6117,6 +6133,8 @@ fn dunder_all_extend_argument(value: &ast::Expr) -> Option<&ast::Expr> { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, }, .. } = value.as_call_expr()?; diff --git a/crates/ty_python_core/src/re_exports.rs b/crates/ty_python_core/src/re_exports.rs index c8c8d680473deb..0a7b8ce38ccb68 100644 --- a/crates/ty_python_core/src/re_exports.rs +++ b/crates/ty_python_core/src/re_exports.rs @@ -147,6 +147,8 @@ impl<'db> Visitor<'db> for ExportFinder<'db> { keys: _, range: _, node_index: _, + runtime_keys: _, + runtime_patterns: _, }) => { for pattern in patterns { self.visit_pattern(pattern); @@ -183,6 +185,8 @@ impl<'db> Visitor<'db> for ExportFinder<'db> { body: _, // We don't want to visit the body of the class range: _, node_index: _, + runtime_decorator_list: _, + runtime_body: _, }) => { self.possibly_add_export(&name.id, PossibleExportKind::Normal); for decorator in decorator_list { @@ -203,6 +207,10 @@ impl<'db> Visitor<'db> for ExportFinder<'db> { range: _, node_index: _, is_async: _, + runtime_decorator_list: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, }) => { self.possibly_add_export(&name.id, PossibleExportKind::Normal); for decorator in decorator_list { @@ -221,6 +229,7 @@ impl<'db> Visitor<'db> for ExportFinder<'db> { simple: _, range: _, node_index: _, + runtime_simple: _, }) => { if value.is_some() || self.visiting_stub_file { self.visit_expr(target); @@ -323,6 +332,7 @@ impl<'db> Visitor<'db> for ExportFinder<'db> { | ast::Expr::BytesLiteral(_) | ast::Expr::EllipsisLiteral(_) | ast::Expr::StringLiteral(_) => {} + ast::Expr::Constant(_) => {} // Walrus definitions "leak" from comprehension scopes into the comprehension's // enclosing scope; they thus need special handling @@ -377,6 +387,7 @@ impl<'db> Visitor<'db> for WalrusFinder<'_, 'db> { | ast::Expr::BytesLiteral(_) | ast::Expr::EllipsisLiteral(_) | ast::Expr::StringLiteral(_) + | ast::Expr::Constant(_) | ast::Expr::Name(_) => {} ast::Expr::Named(ast::ExprNamed { diff --git a/crates/ty_python_semantic/src/semantic_model.rs b/crates/ty_python_semantic/src/semantic_model.rs index ea5aa0428b6212..aa63793a338cb6 100644 --- a/crates/ty_python_semantic/src/semantic_model.rs +++ b/crates/ty_python_semantic/src/semantic_model.rs @@ -1126,6 +1126,7 @@ impl HasType for ast::Expr { Expr::Tuple(inner) => inner.inferred_type(model), Expr::Slice(inner) => inner.inferred_type(model), Expr::IpyEscapeCommand(inner) => inner.inferred_type(model), + Expr::Constant(_) => None, } } } diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 1370dbf3754a5d..341258c54abe9a 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -2305,6 +2305,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { test, body, elif_else_clauses, + runtime_body: _, } = if_statement; let test_ty = self.infer_standalone_expression(test, TypeContext::default()); @@ -2321,6 +2322,8 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { node_index: _, test, body, + runtime_body: _, + runtime_orelse: _, } = clause; if let Some(test) = &test { @@ -2344,6 +2347,10 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { orelse, finalbody, is_star: _, + runtime_body: _, + runtime_handlers: _, + runtime_orelse: _, + runtime_finalbody: _, } = try_statement; self.infer_body(body); @@ -2356,6 +2363,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { body, range: _, node_index: _, + runtime_body: _, } = handler; // If `symbol_name` is `Some()` and `handled_exceptions` is `None`, @@ -2383,6 +2391,9 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { is_async, items, body, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, } = with_statement; for item in items { let target = item.optional_vars.as_deref(); @@ -2777,6 +2788,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { body, pattern, guard, + runtime_body: _, } = case; self.infer_match_pattern(pattern); @@ -2895,6 +2907,9 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { node_index: _, cls, arguments, + runtime_patterns: _, + runtime_kwd_attrs: _, + runtime_kwd_patterns: _, } = match_class; for pattern in &arguments.patterns { self.infer_nested_match_pattern(pattern); @@ -2933,6 +2948,8 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { keys, patterns, rest, + runtime_keys: _, + runtime_patterns: _, } = match_mapping; for key in keys { self.infer_maybe_standalone_expression(key, TypeContext::default()); @@ -2950,6 +2967,9 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { node_index: _, cls, arguments, + runtime_patterns: _, + runtime_kwd_attrs: _, + runtime_kwd_patterns: _, } = match_class; for pattern in &arguments.patterns { self.infer_nested_match_pattern(pattern); @@ -2988,6 +3008,9 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { node_index: _, targets, value, + runtime_targets: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, } = assignment; if let [ast::Expr::Name(name)] = targets.as_slice() { @@ -3787,6 +3810,8 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, } = &call_expr.arguments; if args.iter().any(ast::Expr::is_starred_expr) { @@ -4311,6 +4336,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { value, target, simple: _, + runtime_simple: _, } = assignment; let annotated = self.infer_annotation_expression( annotation, @@ -5223,6 +5249,10 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { body, orelse, is_async, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, + runtime_orelse: _, } = for_statement; self.infer_target(target, iter, &|builder, tcx| { @@ -5306,6 +5336,8 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { test, body, orelse, + runtime_body: _, + runtime_orelse: _, } = while_statement; let test_ty = self.infer_standalone_expression(test, TypeContext::default()); @@ -5422,6 +5454,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { range: _, node_index: _, targets, + runtime_targets: _, } = delete; for target in targets { self.infer_expression(target, TypeContext::default()); @@ -6748,6 +6781,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { ast::Expr::IpyEscapeCommand(_) => { todo_type!("Ipy escape command support") } + ast::Expr::Constant(_) => Type::unknown(), }; self.finish_expression_type(expression, ty, tcx) @@ -7074,6 +7108,8 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { range: _, node_index: _, value, + runtime_joined_str: _, + runtime_values: _, } = fstring; let mut collector = StringPartsCollector::new(); @@ -7095,6 +7131,9 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { debug_text, conversion, format_spec, + runtime_str: _, + runtime_interpolation_format_spec: _, + runtime_formatted_value_format_spec: _, } = expression; let ty = self.infer_expression(expression, TypeContext::default()); @@ -7228,6 +7267,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { elts, ctx: _, parenthesized: _, + runtime_elts: _, } = tuple; // Remove any union elements of the annotation that are unrelated to the tuple type. @@ -7329,6 +7369,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { node_index: _, elts, ctx: _, + runtime_elts: _, } = list; let elts = elts.iter().map(|elt| [Some(elt)]).collect_vec(); @@ -7357,6 +7398,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { range: _, node_index: _, elts, + runtime_elts: _, } = set; let elts = elts.iter().map(|elt| [Some(elt)]).collect_vec(); @@ -7444,6 +7486,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { range: _, node_index: _, items, + runtime_values: _, } = dict; let mut item_types = FxHashMap::default(); @@ -8520,6 +8563,8 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { iter, ifs, is_async: _, + runtime_ifs: _, + runtime_is_async: _, } = comprehension; self.infer_target(target, iter, &|builder, tcx| { @@ -11619,6 +11664,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { node_index: _, op, values, + runtime_values: _, } = bool_op; // The first operand has no peers. If no later operand is a collection literal, // accumulating prior types cannot affect inference. @@ -11840,6 +11886,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { range: _, node_index: _, type_params, + runtime_type_params: _, } = type_parameters; for type_param in type_params { match type_param { diff --git a/crates/ty_python_semantic/src/types/infer/builder/class.rs b/crates/ty_python_semantic/src/types/infer/builder/class.rs index 43eb30880a3bdf..91e2d1fb3951c6 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/class.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/class.rs @@ -112,6 +112,8 @@ impl<'db> TypeInferenceBuilder<'db, '_> { decorator_list, arguments: _, body: _, + runtime_decorator_list: _, + runtime_body: _, } = class_node; let db = self.db(); diff --git a/crates/ty_python_semantic/src/types/infer/builder/enum_call.rs b/crates/ty_python_semantic/src/types/infer/builder/enum_call.rs index 6e016404bd41da..1e2d7246369818 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/enum_call.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/enum_call.rs @@ -304,6 +304,8 @@ impl<'db> TypeInferenceBuilder<'db, '_> { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, } = &call_expr.arguments; for kw in keywords { diff --git a/crates/ty_python_semantic/src/types/infer/builder/function.rs b/crates/ty_python_semantic/src/types/infer/builder/function.rs index 241dca14c11c48..585fb6b9031ad4 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/function.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/function.rs @@ -442,6 +442,10 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { returns: _, body: _, decorator_list, + runtime_decorator_list: _, + runtime_type_comment: _, + runtime_type_comment_bytes: _, + runtime_body: _, } = function; let db = self.db(); @@ -967,6 +971,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { vararg, kwonlyargs: _, kwarg, + runtime_defaults: _, } = parameters; self.context.inference_flags |= InferenceFlags::IN_PARAMETER_ANNOTATION; @@ -1099,6 +1104,8 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { node_index: _, name: _, annotation, + runtime_type_comment: _, + runtime_type_comment_bytes: _, } = parameter; if let Some(annotation) = annotation.as_deref() { diff --git a/crates/ty_python_semantic/src/types/infer/builder/imports.rs b/crates/ty_python_semantic/src/types/infer/builder/imports.rs index 7c10c8edabbab3..2ebab9d608e85b 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/imports.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/imports.rs @@ -330,6 +330,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { is_lazy: _, range: _, node_index: _, + runtime_level: _, } = import; let db = self.db(); diff --git a/crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs b/crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs index 099da7e8f30c85..adeaa7aa069843 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs @@ -60,6 +60,8 @@ impl<'db> TypeInferenceBuilder<'db, '_> { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, } = &call_expr.arguments; // Check for variadic arguments early, before extracting positional args. diff --git a/crates/ty_python_semantic/src/types/infer/builder/new_class.rs b/crates/ty_python_semantic/src/types/infer/builder/new_class.rs index 25b03eb133bdb3..cefe6a86c5b47b 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/new_class.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/new_class.rs @@ -35,6 +35,8 @@ impl<'db> TypeInferenceBuilder<'db, '_> { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, } = &call_expr.arguments; // `new_class(name, bases=(), kwds=None, exec_body=None)` diff --git a/crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/exemptions.rs b/crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/exemptions.rs index 0ca25051b289dc..a377252f9471a1 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/exemptions.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/exemptions.rs @@ -243,7 +243,8 @@ impl RedundantConditionContext { | ast::Expr::List(_) | ast::Expr::ListComp(_) | ast::Expr::TString(_) - | ast::Expr::NoneLiteral(_) => false, + | ast::Expr::NoneLiteral(_) + | ast::Expr::Constant(_) => false, // These expressions can contain subexpressions that are defined in terms of `sys.version_info`, // `sys.platform`, `os.name`, or `typing.TYPE_CHECKING`. We need to recurse into them to check for diff --git a/crates/ty_python_semantic/src/types/infer/builder/type_call.rs b/crates/ty_python_semantic/src/types/infer/builder/type_call.rs index b0b70027fe5584..d60020219d3d99 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/type_call.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/type_call.rs @@ -39,6 +39,8 @@ impl<'db> TypeInferenceBuilder<'db, '_> { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, } = &call_expr.arguments; for keyword in keywords { diff --git a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs index f5be0e19249578..8eb7257016b2a3 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs @@ -1254,6 +1254,8 @@ impl<'db> TypeInferenceBuilder<'db, '_> { Type::unknown() } + ast::Expr::Constant(_) => Type::unknown(), + ast::Expr::Starred(starred) => self.infer_starred_type_expression(starred), } } diff --git a/crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs b/crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs index de68bf80d14a45..58cebfe2dba2c9 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs @@ -82,6 +82,8 @@ impl<'db> TypeInferenceBuilder<'db, '_> { keywords, range: _, node_index: _, + runtime_args: _, + runtime_bases: _, } = &call_expr.arguments; let starred_arguments: SmallVec<[&ast::Expr; 1]> = @@ -336,6 +338,7 @@ impl<'db> TypeInferenceBuilder<'db, '_> { range: _, node_index: _, items, + runtime_values: _, } = dict; let key_tcx = diff --git a/crates/ty_python_semantic/src/types/narrow.rs b/crates/ty_python_semantic/src/types/narrow.rs index 346ed5d851bdd2..d177e304081862 100644 --- a/crates/ty_python_semantic/src/types/narrow.rs +++ b/crates/ty_python_semantic/src/types/narrow.rs @@ -4098,6 +4098,7 @@ impl<'db> NarrowingConstraintsBuilder<'db, '_> { node_index: _, ops, operands, + runtime_comparators: _, } = expr_compare; // Performance optimization: early return if there are no potential narrowing targets. diff --git a/crates/ty_python_semantic/src/types/signatures.rs b/crates/ty_python_semantic/src/types/signatures.rs index 2f30c04ebcc887..92b230357dc60e 100644 --- a/crates/ty_python_semantic/src/types/signatures.rs +++ b/crates/ty_python_semantic/src/types/signatures.rs @@ -5144,6 +5144,7 @@ impl<'db> Parameters<'db> { kwarg, range: _, node_index: _, + runtime_defaults: _, } = parameters; let index = semantic_index(db, definition.program_file(db)); diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index f4d624eb97c494..0bbbb945125cc7 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -19,11 +19,11 @@ cargo-fuzz = true [dependencies] ruff_db = { path = "../crates/ruff_db" } ruff_linter = { path = "../crates/ruff_linter" } -ruff_python_ast = { path = "../crates/ruff_python_ast" } +ruff_python_ast = { package = "rustpython-ruff_python_ast", path = "../crates/ruff_python_ast" } ruff_python_codegen = { path = "../crates/ruff_python_codegen" } -ruff_python_parser = { path = "../crates/ruff_python_parser" } +ruff_python_parser = { package = "rustpython-ruff_python_parser", path = "../crates/ruff_python_parser" } ruff_python_formatter = { path = "../crates/ruff_python_formatter" } -ruff_text_size = { path = "../crates/ruff_text_size" } +ruff_text_size = { package = "rustpython-ruff_text_size", path = "../crates/ruff_text_size" } ty_module_resolver = { path = "../crates/ty_module_resolver" } ty_python_semantic = { path = "../crates/ty_python_semantic", features = ["testing"] } diff --git a/hawk.toml b/hawk.toml index de8bf64cdc7390..07cfaec08b7e56 100644 --- a/hawk.toml +++ b/hawk.toml @@ -56,22 +56,22 @@ package = "ruff_notebook" package = "ruff_options_metadata" [[doctest]] -package = "ruff_python_ast" +package = "rustpython-ruff_python_ast" [[doctest]] -package = "ruff_python_parser" +package = "rustpython-ruff_python_parser" [[doctest]] package = "ruff_python_stdlib" [[doctest]] -package = "ruff_python_trivia" +package = "rustpython-ruff_python_trivia" [[doctest]] -package = "ruff_source_file" +package = "rustpython-ruff_source_file" [[doctest]] -package = "ruff_text_size" +package = "rustpython-ruff_text_size" [[doctest]] package = "ruff_workspace" From 2de650597a7370e3dbe19409d5bf4da8093ff298 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" <69878+youknowone@users.noreply.github.com> Date: Tue, 1 Sep 2026 02:38:21 +0900 Subject: [PATCH 02/20] Match CPython class generator syntax error (#5) Assisted-by: Codex:GPT-5 --- crates/ruff_python_parser/src/parser/expression.rs | 10 +++++++++- ...lass_def_unparenthesized_generator_argument.py.snap | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 05da2d80fe13bd..988b18d48ea2a7 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -3045,7 +3045,15 @@ impl<'src> Parser<'src> { // sum(x for x in range(10), 5) // total(1, 2, x for x in range(5), 6) // sum(x for x in range(10),) - self.add_error(ParseErrorType::UnparenthesizedGeneratorExpression, range); + let error = match context { + ArgumentsContext::Call => { + ParseErrorType::UnparenthesizedGeneratorExpression + } + ArgumentsContext::ClassDefinition => { + ParseErrorType::OtherError("invalid syntax".to_owned()) + } + }; + self.add_error(error, range); } } } diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap index 5b2f3d6882144a..950e45933a75df 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap @@ -100,4 +100,4 @@ Module( | 1 | class Foo(base for base in bases): ... - | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Unparenthesized generator expression cannot be used here + | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: invalid syntax From f2143fa284d64f9b20699ec27e9b03fc11575b91 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 13 Sep 2026 17:00:12 +0900 Subject: [PATCH 03/20] Strip unpublished dependencies for the 0.16.10 crates.io release Only the five rustpython-ruff_* crates are published. ruff_python_ast drops its optional ruff_cache, ruff_macros and salsa dependencies along with the cache and salsa features; the serde feature stays but no longer pulls ruff_cache. Workspace crates that requested cache or salsa stop doing so. ruff_annotate_snippets loses its version requirement so cargo drops it from the published parser dev-dependencies. Assisted-by: Claude Code:claude-fable-5-1 Assisted-by: Claude Code:claude-opus-5-5 --- Cargo.lock | 3 --- Cargo.toml | 2 +- crates/ruff_linter/Cargo.toml | 2 +- crates/ruff_python_ast/Cargo.toml | 12 ++++++------ crates/ty_module_resolver/Cargo.toml | 2 +- crates/ty_python_core/Cargo.toml | 2 +- crates/ty_python_semantic/Cargo.toml | 2 +- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d065d1de1f646c..297326a8406464 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3818,13 +3818,10 @@ dependencies = [ "get-size2", "is-macro", "memchr", - "ruff_cache", - "ruff_macros", "rustc-hash", "rustpython-ruff_python_trivia", "rustpython-ruff_source_file", "rustpython-ruff_text_size", - "salsa", "schemars", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 006be36c71c159..42bfa9513a24ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ license = "MIT" [workspace.dependencies] char_str = { version = "0.0.4", default-features = false, features = ["std"] } ruff = { version = "0.16.10", path = "crates/ruff" } -ruff_annotate_snippets = { version = "0.0.16", path = "crates/ruff_annotate_snippets" } +ruff_annotate_snippets = { path = "crates/ruff_annotate_snippets" } ruff_cache = { version = "0.0.16", path = "crates/ruff_cache" } ruff_command_line = { version = "0.0.16", path = "crates/ruff_command_line" } ruff_db = { version = "0.0.16", path = "crates/ruff_db", default-features = false } diff --git a/crates/ruff_linter/Cargo.toml b/crates/ruff_linter/Cargo.toml index d1ac538c735e46..0ce6ee532f2dde 100644 --- a/crates/ruff_linter/Cargo.toml +++ b/crates/ruff_linter/Cargo.toml @@ -18,7 +18,7 @@ ruff_db = { workspace = true, features = ["junit", "serde"] } ruff_diagnostics = { workspace = true, features = ["serde"] } ruff_macros = { workspace = true } ruff_notebook = { workspace = true } -ruff_python_ast = { workspace = true, features = ["serde", "cache"] } +ruff_python_ast = { workspace = true, features = ["serde"] } ruff_python_codegen = { workspace = true } ruff_python_edits = { workspace = true } ruff_python_importer = { workspace = true } diff --git a/crates/ruff_python_ast/Cargo.toml b/crates/ruff_python_ast/Cargo.toml index 4dcd66c6b6eeb5..b33af66e95cdb9 100644 --- a/crates/ruff_python_ast/Cargo.toml +++ b/crates/ruff_python_ast/Cargo.toml @@ -18,8 +18,9 @@ ignored = ["ruff_cache"] name = "ruff_python_ast" [dependencies] -ruff_cache = { workspace = true, optional = true } -ruff_macros = { workspace = true, optional = true } +# Not published: RustPython does not use the cache and salsa features. +# ruff_cache = { workspace = true, optional = true } +# ruff_macros = { workspace = true, optional = true } ruff_python_trivia = { workspace = true } ruff_source_file = { workspace = true } ruff_text_size = { workspace = true } @@ -33,7 +34,7 @@ get-size2 = { workspace = true, optional = true } is-macro = { workspace = true } memchr = { workspace = true } rustc-hash = { workspace = true } -salsa = { workspace = true, optional = true } +# salsa = { workspace = true, optional = true } schemars = { workspace = true, optional = true } serde = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } @@ -42,17 +43,16 @@ thin-vec = { workspace = true } [features] schemars = ["dep:schemars", "dep:serde_json"] -cache = ["dep:ruff_cache", "dep:ruff_macros"] +# cache = ["dep:ruff_cache", "dep:ruff_macros"] serde = [ "dep:serde", "ruff_text_size/serde", - "dep:ruff_cache", "char_str/serde", "compact_str/serde", "thin-vec/serde", ] get-size = ["dep:get-size2", "char_str/get-size", "ruff_text_size/get-size"] -salsa = ["dep:salsa"] +# salsa = ["dep:salsa"] [lints] workspace = true diff --git a/crates/ty_module_resolver/Cargo.toml b/crates/ty_module_resolver/Cargo.toml index 0e8022416e9b29..a9a3b65c7f9ddc 100644 --- a/crates/ty_module_resolver/Cargo.toml +++ b/crates/ty_module_resolver/Cargo.toml @@ -13,7 +13,7 @@ license = { workspace = true } [dependencies] ruff_db = { workspace = true } ruff_memory_usage = { workspace = true } -ruff_python_ast = { workspace = true, features = ["salsa"] } +ruff_python_ast = { workspace = true } ruff_python_stdlib = { workspace = true } anyhow = { workspace = true } diff --git a/crates/ty_python_core/Cargo.toml b/crates/ty_python_core/Cargo.toml index 2dbb3eeaaaa352..7e78a8e28d3428 100644 --- a/crates/ty_python_core/Cargo.toml +++ b/crates/ty_python_core/Cargo.toml @@ -14,7 +14,7 @@ license = { workspace = true } ruff_db = { workspace = true } ruff_index = { workspace = true, features = ["salsa"] } ruff_memory_usage = { workspace = true } -ruff_python_ast = { workspace = true, features = ["salsa"] } +ruff_python_ast = { workspace = true } ruff_python_parser = { workspace = true } ruff_text_size = { workspace = true } ty_module_resolver = { workspace = true } diff --git a/crates/ty_python_semantic/Cargo.toml b/crates/ty_python_semantic/Cargo.toml index 65aa39e085ee2d..afe1992487ea31 100644 --- a/crates/ty_python_semantic/Cargo.toml +++ b/crates/ty_python_semantic/Cargo.toml @@ -16,7 +16,7 @@ ruff_diagnostics = { workspace = true } ruff_index = { workspace = true, features = ["salsa"] } ruff_macros = { workspace = true } ruff_memory_usage = { workspace = true } -ruff_python_ast = { workspace = true, features = ["salsa"] } +ruff_python_ast = { workspace = true } ruff_python_edits = { workspace = true } ruff_python_codegen = { workspace = true } ruff_python_importer = { workspace = true } From d2f75922771cfd1181470439e991972bbb40b3c5 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 4 Oct 2026 14:31:55 +0900 Subject: [PATCH 04/20] Report unparenthesized except types once `as NAME :` matches The "Multiple exception types must be parenthesized when using `as`" error is now added after `as NAME` is parsed and only when the clause continues with `:`. Its range starts at the first exception type and ends at the start of the `:` token, covering `as NAME`. When the name or the `:` is missing, only the errors for those are reported. Assisted-by: Claude Code:claude-opus-5-5 --- ...tmt_unparenthesized_tuple_as_incomplete.py | 8 + .../src/parser/statement.rs | 33 ++- ...cept_stmt_unparenthesized_tuple_as.py.snap | 4 +- ...nparenthesized_tuple_as_incomplete.py.snap | 224 ++++++++++++++++++ 4 files changed, 260 insertions(+), 9 deletions(-) create mode 100644 crates/ruff_python_parser/resources/inline/err/except_stmt_unparenthesized_tuple_as_incomplete.py create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap diff --git a/crates/ruff_python_parser/resources/inline/err/except_stmt_unparenthesized_tuple_as_incomplete.py b/crates/ruff_python_parser/resources/inline/err/except_stmt_unparenthesized_tuple_as_incomplete.py new file mode 100644 index 00000000000000..c2929fc0c7944a --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/except_stmt_unparenthesized_tuple_as_incomplete.py @@ -0,0 +1,8 @@ +try: + pass +except x, y as (exc): + pass +try: + pass +except x, y as exc + pass diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index 84a296b5eb09bb..1da7a52eeb6d4c 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -1710,6 +1710,7 @@ impl<'src> Parser<'src> { ExceptClauseKind::Normal }; + let mut unparenthesized_types_start = None; let type_ = if self.at_expr() { // test_err except_stmt_invalid_expression // try: @@ -1738,13 +1739,7 @@ impl<'src> Parser<'src> { // pass // except* x, y as eg: // pass - self.add_error( - ParseErrorType::OtherError( - "Multiple exception types must be parenthesized when using `as`" - .to_string(), - ), - &parsed_expr, - ); + unparenthesized_types_start = Some(parsed_expr.start()); } else { // test_err except_stmt_unparenthesized_tuple_no_as_py313 // # parse_options: {"target-version": "3.13"} @@ -1824,6 +1819,30 @@ impl<'src> Parser<'src> { None }; + // The error is raised only once the whole `as NAME :` part has matched, and covers + // the exception types through `as NAME`, stopping just before the `:`. + + // test_err except_stmt_unparenthesized_tuple_as_incomplete + // try: + // pass + // except x, y as (exc): + // pass + // try: + // pass + // except x, y as exc + // pass + if let Some(types_start) = unparenthesized_types_start + && name.is_some() + && self.at(TokenKind::Colon) + { + self.add_error( + ParseErrorType::OtherError( + "Multiple exception types must be parenthesized when using `as`".to_string(), + ), + TextRange::new(types_start, self.current_token_range().start()), + ); + } + // test_err except_stmt_missing_exception_and_as_name // try: // pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap index 1d284e28ec6ff6..f8eb819ba1af2c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap @@ -169,7 +169,7 @@ Module( 1 | try: 2 | pass 3 | except x, y as exc: - | ^^^^ Syntax Error: Multiple exception types must be parenthesized when using `as` + | ^^^^^^^^^^^ Syntax Error: Multiple exception types must be parenthesized when using `as` 4 | pass 5 | try: | @@ -179,6 +179,6 @@ Module( 5 | try: 6 | pass 7 | except* x, y as eg: - | ^^^^ Syntax Error: Multiple exception types must be parenthesized when using `as` + | ^^^^^^^^^^ Syntax Error: Multiple exception types must be parenthesized when using `as` 8 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap new file mode 100644 index 00000000000000..35649f8dac59dd --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap @@ -0,0 +1,224 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/except_stmt_unparenthesized_tuple_as_incomplete.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..87, + body: [ + Try( + StmtTry { + node_index: NodeIndex(None), + range: 0..35, + body: [ + Pass( + StmtPass { + node_index: NodeIndex(None), + range: 9..13, + }, + ), + ], + handlers: [ + ExceptHandler( + ExceptHandlerExceptHandler { + range: 14..35, + node_index: NodeIndex(None), + type_: Some( + Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 21..25, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 21..22, + id: Name("x"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 24..25, + id: Name("y"), + ctx: Load, + }, + ), + ], + ctx: Load, + parenthesized: false, + runtime_elts: None, + }, + ), + ), + name: None, + body: [ + AnnAssign( + StmtAnnAssign { + node_index: NodeIndex(None), + range: 29..35, + target: Name( + ExprName { + node_index: NodeIndex(None), + range: 30..33, + id: Name("exc"), + ctx: Store, + }, + ), + annotation: Name( + ExprName { + node_index: NodeIndex(None), + range: 35..35, + id: Name(""), + ctx: Invalid, + }, + ), + value: None, + simple: false, + runtime_simple: None, + }, + ), + ], + runtime_body: None, + }, + ), + ], + orelse: [], + finalbody: [], + is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, + }, + ), + Pass( + StmtPass { + node_index: NodeIndex(None), + range: 40..44, + }, + ), + Try( + StmtTry { + node_index: NodeIndex(None), + range: 45..86, + body: [ + Pass( + StmtPass { + node_index: NodeIndex(None), + range: 54..58, + }, + ), + ], + handlers: [ + ExceptHandler( + ExceptHandlerExceptHandler { + range: 59..86, + node_index: NodeIndex(None), + type_: Some( + Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 66..70, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 66..67, + id: Name("x"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 69..70, + id: Name("y"), + ctx: Load, + }, + ), + ], + ctx: Load, + parenthesized: false, + runtime_elts: None, + }, + ), + ), + name: Some( + Identifier { + id: Name("exc"), + range: 74..77, + node_index: NodeIndex(None), + }, + ), + body: [ + Pass( + StmtPass { + node_index: NodeIndex(None), + range: 82..86, + }, + ), + ], + runtime_body: None, + }, + ), + ], + orelse: [], + finalbody: [], + is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | try: +2 | pass +3 | except x, y as (exc): + | ^ Syntax Error: Expected name after `as` +4 | pass +5 | try: + | + + + | +1 | try: +2 | pass +3 | except x, y as (exc): + | ^ Syntax Error: Expected an expression +4 | pass +5 | try: +6 | pass + | + + + | +2 | pass +3 | except x, y as (exc): +4 | pass + | ^^^^ Syntax Error: Unexpected indentation +5 | try: +6 | pass + | + + + | +5 | try: +6 | pass +7 | except x, y as exc + | ^ Syntax Error: Expected `:`, found newline +8 | pass + | From be649be9ba1d41d6913099cfc52b59c5be9b5371 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 4 Oct 2026 16:41:15 +0900 Subject: [PATCH 05/20] Emit CPython error message texts from the parser Error messages that RustPython rewrote by matching their text now come out of the parser in their final form: - `Display` of `ParseErrorType`, `LexicalErrorType` and the f-string and t-string error types produces the CPython wording, e.g. `invalid syntax`, `expected ':'`, `positional argument follows keyword argument`, `unterminated f-string literal`, with single quotes instead of backticks in f-string and t-string messages. - The list recovery messages and `Expected an identifier ...` become `invalid syntax`, and the `OtherError` messages for mixed bytes literals, keyword patterns, `not`, trailing commas, `except ... as`, `/` and `*` parameters, and `try` without handlers use the CPython wording. - All other messages, including `UnsupportedSyntaxError` messages, start with a lowercase letter, except `Type parameter list cannot be empty`, `Expected one or more names after 'import'` and `Generator expression must be parenthesized`. Snapshots are updated for the new texts. Assisted-by: Grok:grok-4.6 Assisted-by: Claude Code:claude-opus-5-5 --- crates/ruff_python_parser/src/error.rs | 197 ++++++++++-------- crates/ruff_python_parser/src/lexer.rs | 14 +- .../src/parser/expression.rs | 36 ++-- crates/ruff_python_parser/src/parser/mod.rs | 104 +++------ .../ruff_python_parser/src/parser/pattern.rs | 20 +- .../src/parser/statement.rs | 67 +++--- ...exer__tests__invalid_leading_zero_big.snap | 2 +- ...er__tests__invalid_leading_zero_small.snap | 2 +- ...ests__parse_f_t_string_concat_1_error.snap | 2 +- ...ests__parse_f_t_string_concat_2_error.snap | 2 +- ..._tests__parse_t_string_concat_1_error.snap | 2 +- ..._tests__parse_t_string_concat_2_error.snap | 2 +- ..._tests__parse_t_string_concat_3_error.snap | 2 +- ..._tests__parse_t_string_concat_4_error.snap | 2 +- ...ests__parse_u_t_string_concat_1_error.snap | 2 +- ...ests__parse_u_t_string_concat_2_error.snap | 2 +- ...ann_assign_stmt_invalid_annotation.py.snap | 8 +- ...tax@ann_assign_stmt_invalid_target.py.snap | 16 +- ...ntax@ann_assign_stmt_invalid_value.py.snap | 6 +- ...syntax@ann_assign_stmt_missing_rhs.py.snap | 2 +- ..._assign_stmt_type_alias_annotation.py.snap | 4 +- ...tax@args_unparenthesized_generator.py.snap | 6 +- .../invalid_syntax@assert_empty_msg.py.snap | 2 +- .../invalid_syntax@assert_empty_test.py.snap | 2 +- ...lid_syntax@assert_invalid_msg_expr.py.snap | 8 +- ...id_syntax@assert_invalid_test_expr.py.snap | 10 +- ..._syntax@assign_stmt_invalid_target.py.snap | 12 +- ...tax@assign_stmt_invalid_value_expr.py.snap | 10 +- ..._syntax@assign_stmt_keyword_target.py.snap | 4 +- ...lid_syntax@assign_stmt_missing_rhs.py.snap | 6 +- ...alid_syntax@async_unexpected_token.py.snap | 10 +- ...tax@aug_assign_stmt_invalid_target.py.snap | 12 +- ...ntax@aug_assign_stmt_invalid_value.py.snap | 10 +- ...syntax@aug_assign_stmt_missing_rhs.py.snap | 6 +- ...ash_continuation_indentation_error.py.snap | 2 +- ..._syntax@case_expect_indented_block.py.snap | 2 +- ...nvalid_syntax@class_def_empty_body.py.snap | 4 +- ...alid_syntax@class_def_missing_name.py.snap | 6 +- ...class_def_unclosed_type_param_list.py.snap | 2 +- ...lid_syntax@class_type_params_py311.py.snap | 4 +- ...yntax@clause_expect_indented_block.py.snap | 4 +- ...tax@clause_expect_single_statement.py.snap | 2 +- ...ntax@comma_separated_missing_comma.py.snap | 4 +- ...ted_missing_comma_between_elements.py.snap | 2 +- ...ted_missing_element_between_commas.py.snap | 2 +- ...ma_separated_missing_first_element.py.snap | 2 +- ...prehension_missing_for_after_async.py.snap | 4 +- ...ax@decorator_await_expression_py38.py.snap | 2 +- ...syntax@decorator_dict_literal_py38.py.snap | 2 +- ...d_syntax@decorator_expression_py38.py.snap | 2 +- ...yntax@decorator_float_literal_py38.py.snap | 2 +- ...yntax@decorator_invalid_expression.py.snap | 10 +- ...yntax@decorator_missing_expression.py.snap | 12 +- ...d_syntax@decorator_missing_newline.py.snap | 6 +- ...ax@decorator_named_expression_py37.py.snap | 4 +- ..._non_toplevel_call_expression_py38.py.snap | 2 +- ..._syntax@decorator_unexpected_token.py.snap | 4 +- ...valid_syntax@del_incomplete_target.py.snap | 2 +- .../invalid_syntax@del_stmt_empty.py.snap | 2 +- ...d_syntax@dotted_name_multiple_dots.py.snap | 6 +- .../invalid_syntax@except_star_py310.py.snap | 6 +- ...tax@except_stmt_invalid_expression.py.snap | 4 +- ...syntax@except_stmt_missing_as_name.py.snap | 4 +- ...ntax@except_stmt_missing_exception.py.snap | 8 +- ...stmt_missing_exception_and_as_name.py.snap | 4 +- ...cept_stmt_unparenthesized_tuple_as.py.snap | 4 +- ...nparenthesized_tuple_as_incomplete.py.snap | 8 +- ..._unparenthesized_tuple_no_as_py313.py.snap | 4 +- ...essions__arguments__double_starred.py.snap | 10 +- ...ons__arguments__invalid_expression.py.snap | 8 +- ...uments__invalid_keyword_expression.py.snap | 8 +- ...ressions__arguments__invalid_order.py.snap | 10 +- ...sions__arguments__missing_argument.py.snap | 2 +- ...ressions__arguments__missing_comma.py.snap | 2 +- ...ons__arguments__missing_expression.py.snap | 6 +- ...ax@expressions__arguments__starred.py.snap | 6 +- ...expressions__arguments__unclosed_0.py.snap | 2 +- ...expressions__arguments__unclosed_1.py.snap | 2 +- ...expressions__arguments__unclosed_2.py.snap | 2 +- ...essions__attribute__invalid_member.py.snap | 8 +- ...ressions__attribute__multiple_dots.py.snap | 8 +- ...@expressions__attribute__no_member.py.snap | 4 +- ...xpressions__await__no_expression_0.py.snap | 2 +- ...xpressions__await__no_expression_1.py.snap | 2 +- ...syntax@expressions__await__recover.py.snap | 18 +- ...ns__bin_op__invalid_rhs_expression.py.snap | 4 +- ...x@expressions__bin_op__missing_lhs.py.snap | 2 +- ...expressions__bin_op__missing_rhs_0.py.snap | 2 +- ...expressions__bin_op__missing_rhs_1.py.snap | 2 +- ...@expressions__bin_op__multiple_ops.py.snap | 4 +- ...ressions__bin_op__named_expression.py.snap | 4 +- ...ssions__bin_op__starred_expression.py.snap | 4 +- ...s__bool_op__invalid_rhs_expression.py.snap | 4 +- ...@expressions__bool_op__missing_lhs.py.snap | 2 +- ...@expressions__bool_op__missing_rhs.py.snap | 2 +- ...essions__bool_op__named_expression.py.snap | 4 +- ...sions__bool_op__starred_expression.py.snap | 4 +- ...xpressions__compare__invalid_order.py.snap | 10 +- ...s__compare__invalid_rhs_expression.py.snap | 4 +- ...@expressions__compare__missing_lhs.py.snap | 2 +- ...xpressions__compare__missing_rhs_0.py.snap | 2 +- ...xpressions__compare__missing_rhs_1.py.snap | 4 +- ...xpressions__compare__missing_rhs_2.py.snap | 2 +- ...ressions__compare__multiple_equals.py.snap | 8 +- ...essions__compare__named_expression.py.snap | 4 +- ...sions__compare__starred_expression.py.snap | 8 +- ...x@expressions__dict__comprehension.py.snap | 24 +-- ...tax@expressions__dict__double_star.py.snap | 20 +- ...s__dict__double_star_comprehension.py.snap | 2 +- ...ons__dict__missing_closing_brace_0.py.snap | 6 +- ...ons__dict__missing_closing_brace_2.py.snap | 2 +- ...ressions__dict__named_expression_0.py.snap | 4 +- ...ressions__dict__named_expression_1.py.snap | 8 +- ..._syntax@expressions__dict__recover.py.snap | 22 +- ...tax@expressions__emoji_identifiers.py.snap | 14 +- ...yntax@expressions__emoji_statement.py.snap | 2 +- ...essions__if__missing_orelse_expr_0.py.snap | 2 +- ...essions__if__missing_orelse_expr_1.py.snap | 2 +- ...pressions__if__missing_test_expr_0.py.snap | 2 +- ...pressions__if__missing_test_expr_1.py.snap | 2 +- ...id_syntax@expressions__if__recover.py.snap | 14 +- ...essions__lambda_default_parameters.py.snap | 2 +- ...sions__lambda_duplicate_parameters.py.snap | 2 +- ...x@expressions__list__comprehension.py.snap | 44 ++-- ...s__list__missing_closing_bracket_3.py.snap | 2 +- ..._syntax@expressions__list__recover.py.snap | 16 +- ...__list__star_expression_precedence.py.snap | 16 +- ...expressions__named__invalid_target.py.snap | 8 +- ...sions__named__missing_expression_0.py.snap | 4 +- ...sions__named__missing_expression_2.py.snap | 6 +- ...sions__named__missing_expression_4.py.snap | 2 +- ...ressions__parenthesized__generator.py.snap | 6 +- ...nthesized__missing_closing_paren_3.py.snap | 2 +- ...ions__parenthesized__parenthesized.py.snap | 4 +- ...@expressions__parenthesized__tuple.py.snap | 30 +-- ..._parenthesized__tuple_starred_expr.py.snap | 56 ++--- ...ax@expressions__set__comprehension.py.snap | 24 +-- ...set__missing_closing_curly_brace_3.py.snap | 2 +- ...d_syntax@expressions__set__recover.py.snap | 14 +- ...s__set__star_expression_precedence.py.snap | 16 +- ...__subscript__invalid_slice_element.py.snap | 12 +- ...sions__subscript__unclosed_slice_1.py.snap | 6 +- .../invalid_syntax@expressions__unary.py.snap | 2 +- ...pressions__unary__named_expression.py.snap | 4 +- ...xpressions__unary__no_expression_0.py.snap | 2 +- ...xpressions__unary__no_expression_1.py.snap | 2 +- ...pressions__yield__named_expression.py.snap | 4 +- ...xpressions__yield__star_expression.py.snap | 4 +- ...ns__yield_from__starred_expression.py.snap | 4 +- ...sions__yield_from__unparenthesized.py.snap | 6 +- ...d_syntax@f_string_empty_expression.py.snap | 4 +- ...ntax@f_string_invalid_starred_expr.py.snap | 6 +- ..._string_lambda_without_parentheses.py.snap | 6 +- ...id_syntax@f_string_unclosed_lbrace.py.snap | 10 +- ...ing_unclosed_lbrace_in_format_spec.py.snap | 4 +- ...nvalid_syntax@for_iter_unpack_py38.py.snap | 8 +- ..._syntax@for_stmt_invalid_iter_expr.py.snap | 8 +- ...lid_syntax@for_stmt_invalid_target.py.snap | 18 +- ...or_stmt_invalid_target_binary_expr.py.snap | 12 +- ...for_stmt_invalid_target_in_keyword.py.snap | 12 +- ...syntax@for_stmt_missing_in_keyword.py.snap | 4 +- ...valid_syntax@for_stmt_missing_iter.py.snap | 2 +- ...lid_syntax@for_stmt_missing_target.py.snap | 2 +- ...id_syntax@from_import_dotted_names.py.snap | 8 +- ...lid_syntax@from_import_empty_names.py.snap | 10 +- ..._syntax@from_import_missing_module.py.snap | 4 +- ...id_syntax@from_import_missing_rpar.py.snap | 4 +- ...tax@from_import_parenthesized_star.py.snap | 2 +- ...@from_import_star_with_other_names.py.snap | 8 +- ...ort_unparenthesized_trailing_comma.py.snap | 6 +- ...lid_syntax@function_def_empty_body.py.snap | 4 +- ...x@function_def_invalid_return_expr.py.snap | 6 +- ...ax@function_def_missing_identifier.py.snap | 4 +- ...x@function_def_missing_return_type.py.snap | 2 +- ...nction_def_unclosed_parameter_list.py.snap | 8 +- ...ction_def_unclosed_type_param_list.py.snap | 2 +- ...n_def_unparenthesized_return_types.py.snap | 4 +- ..._syntax@function_type_params_py311.py.snap | 4 +- .../invalid_syntax@global_stmt_empty.py.snap | 2 +- ...alid_syntax@global_stmt_expression.py.snap | 2 +- ..._syntax@global_stmt_trailing_comma.py.snap | 8 +- ..._syntax@if_stmt_elif_missing_colon.py.snap | 2 +- .../invalid_syntax@if_stmt_empty_body.py.snap | 2 +- ...tax@if_stmt_invalid_elif_test_expr.py.snap | 4 +- ...d_syntax@if_stmt_invalid_test_expr.py.snap | 6 +- ...valid_syntax@if_stmt_missing_colon.py.snap | 6 +- ...nvalid_syntax@if_stmt_missing_test.py.snap | 2 +- ...lid_syntax@if_stmt_misspelled_elif.py.snap | 12 +- ...y_concatenated_unterminated_string.py.snap | 2 +- ...ated_unterminated_string_multiline.py.snap | 6 +- ...syntax@import_alias_missing_asname.py.snap | 2 +- .../invalid_syntax@import_from_star.py.snap | 2 +- .../invalid_syntax@import_stmt_empty.py.snap | 2 +- ...ax@import_stmt_parenthesized_names.py.snap | 4 +- ...lid_syntax@import_stmt_star_import.py.snap | 10 +- ..._syntax@import_stmt_trailing_comma.py.snap | 6 +- ..._attribute_before_for_in_delimiter.py.snap | 12 +- .../invalid_syntax@invalid_del_target.py.snap | 18 +- ...ax@invalid_fstring_literal_element.py.snap | 4 +- ...alid_syntax@invalid_string_literal.py.snap | 4 +- ...lp_escape_command_error_recovery_1.py.snap | 6 +- ...lp_escape_command_error_recovery_2.py.snap | 4 +- ...lp_escape_command_error_recovery_3.py.snap | 6 +- ...lid_syntax@iter_unpack_return_py37.py.snap | 2 +- ...alid_syntax@iter_unpack_yield_py37.py.snap | 4 +- ...ntax@lambda_body_with_starred_expr.py.snap | 8 +- ...syntax@lambda_body_with_yield_expr.py.snap | 4 +- ...alid_syntax@lazy_import_stmt_py314.py.snap | 4 +- .../invalid_syntax@match_before_py310.py.snap | 2 +- ...d_syntax@match_classify_as_keyword.py.snap | 2 +- ..._classify_as_keyword_or_identifier.py.snap | 2 +- ...nvalid_syntax@match_expected_colon.py.snap | 2 +- ...x@match_stmt_expect_indented_block.py.snap | 4 +- ...tax@match_stmt_expected_case_block.py.snap | 8 +- ...ntax@match_stmt_invalid_guard_expr.py.snap | 6 +- ...ax@match_stmt_invalid_subject_expr.py.snap | 6 +- ...ntax@match_stmt_missing_guard_expr.py.snap | 2 +- ..._syntax@match_stmt_missing_pattern.py.snap | 2 +- ...@match_stmt_no_newline_before_case.py.snap | 4 +- ...@match_stmt_single_starred_subject.py.snap | 2 +- ...mixed_bytes_and_non_bytes_literals.py.snap | 6 +- ...x@mixed_tstring_and_bytes_literals.py.snap | 14 +- ...ntax@multiple_clauses_on_same_line.py.snap | 24 +-- .../invalid_syntax@named_expr_slice.py.snap | 14 +- ...yntax@named_expr_slice_parse_error.py.snap | 2 +- ...@nested_quote_in_format_spec_py312.py.snap | 2 +- ...nvalid_syntax@node_range_with_gaps.py.snap | 8 +- ...invalid_syntax@nonlocal_stmt_empty.py.snap | 2 +- ...id_syntax@nonlocal_stmt_expression.py.snap | 2 +- ...yntax@nonlocal_stmt_trailing_comma.py.snap | 8 +- ...id_syntax@param_missing_annotation.py.snap | 4 +- ...valid_syntax@param_missing_default.py.snap | 4 +- ...ntax@param_with_invalid_annotation.py.snap | 6 +- ..._syntax@param_with_invalid_default.py.snap | 6 +- ...param_with_invalid_star_annotation.py.snap | 8 +- ...x@param_with_star_annotation_py310.py.snap | 2 +- ...rams_expected_after_star_separator.py.snap | 10 +- ...x@params_follows_var_keyword_param.py.snap | 10 +- ...@params_kwarg_after_star_separator.py.snap | 2 +- ...alid_syntax@params_multiple_kwargs.py.snap | 2 +- ...ax@params_multiple_slash_separator.py.snap | 4 +- ...tax@params_multiple_star_separator.py.snap | 4 +- ...lid_syntax@params_multiple_varargs.py.snap | 6 +- ..._syntax@params_no_arg_before_slash.py.snap | 4 +- ...x@params_non_default_after_default.py.snap | 4 +- ...lid_syntax@params_star_after_slash.py.snap | 8 +- ...ms_star_separator_after_star_param.py.snap | 4 +- ...ax@params_var_keyword_with_default.py.snap | 8 +- ...params_var_positional_with_default.py.snap | 8 +- ...parenthesized_context_manager_py38.py.snap | 6 +- ...id_syntax@parenthesized_kwarg_py38.py.snap | 6 +- ...valid_syntax@pep701_f_string_py311.py.snap | 32 +-- ...@pep701_nested_interpolation_py311.py.snap | 4 +- ...ict_unpacking_comprehensions_py315.py.snap | 8 +- ...798_unpacking_comprehensions_py314.py.snap | 10 +- .../invalid_syntax@pos_only_py37.py.snap | 12 +- ...syntax@raise_stmt_from_without_exc.py.snap | 4 +- ...id_syntax@raise_stmt_invalid_cause.py.snap | 6 +- ...alid_syntax@raise_stmt_invalid_exc.py.snap | 6 +- ...e_stmt_unparenthesized_tuple_cause.py.snap | 4 +- ...ise_stmt_unparenthesized_tuple_exc.py.snap | 6 +- ...nvalid_syntax@re_lex_logical_token.py.snap | 38 ++-- ...yntax@re_lex_logical_token_mac_eol.py.snap | 4 +- ...x@re_lex_logical_token_windows_eol.py.snap | 4 +- ...x@re_lexing__fstring_format_spec_1.py.snap | 20 +- ...tax@re_lexing__line_continuation_1.py.snap | 6 +- ...ing__line_continuation_windows_eol.py.snap | 2 +- ...re_lexing__triple_quoted_fstring_1.py.snap | 8 +- ...re_lexing__triple_quoted_fstring_2.py.snap | 2 +- ...re_lexing__triple_quoted_fstring_3.py.snap | 4 +- .../invalid_syntax@re_lexing__ty_1828.py.snap | 14 +- ...id_syntax@return_stmt_invalid_expr.py.snap | 10 +- ...signed_pattern_non_literal_operand.py.snap | 10 +- ...ple_and_compound_stmt_on_same_line.py.snap | 2 +- ...ompound_stmt_on_same_line_in_block.py.snap | 4 +- ...d_syntax@simple_stmts_on_same_line.py.snap | 8 +- ...simple_stmts_on_same_line_in_block.py.snap | 4 +- .../invalid_syntax@star_index_py310.py.snap | 14 +- .../invalid_syntax@star_slices.py.snap | 4 +- ...lid_syntax@starred_list_comp_py314.py.snap | 2 +- ..._syntax@starred_starred_expression.py.snap | 4 +- ...atements__function_type_parameters.py.snap | 18 +- ...ents__if_extra_closing_parentheses.py.snap | 10 +- ...syntax@statements__if_extra_indent.py.snap | 18 +- ...ements__invalid_assignment_targets.py.snap | 64 +++--- ...nvalid_augmented_assignment_target.py.snap | 58 +++--- ...ax@statements__match__as_pattern_0.py.snap | 2 +- ...ax@statements__match__as_pattern_1.py.snap | 2 +- ...ax@statements__match__as_pattern_2.py.snap | 8 +- ...ax@statements__match__as_pattern_3.py.snap | 14 +- ...ax@statements__match__as_pattern_4.py.snap | 6 +- ...ents__match__invalid_class_pattern.py.snap | 12 +- ..._match__invalid_lhs_or_rhs_pattern.py.snap | 38 ++-- ...ts__match__invalid_mapping_pattern.py.snap | 26 +-- ...tements__match__star_pattern_usage.py.snap | 24 +-- ...statements__match__unary_add_usage.py.snap | 10 +- ...s__with__ambiguous_lpar_with_items.py.snap | 66 +++--- ...statements__with__empty_with_items.py.snap | 2 +- ...nts__with__unclosed_ambiguous_lpar.py.snap | 2 +- ...__with__unparenthesized_with_items.py.snap | 14 +- ...d_syntax@t_string_empty_expression.py.snap | 4 +- ...ntax@t_string_invalid_starred_expr.py.snap | 6 +- ..._string_lambda_without_parentheses.py.snap | 6 +- ...id_syntax@t_string_unclosed_lbrace.py.snap | 10 +- ...ing_unclosed_lbrace_in_format_spec.py.snap | 4 +- ...alid_syntax@template_strings_py313.py.snap | 6 +- ...alid_syntax@try_stmt_invalid_order.py.snap | 6 +- ...ax@try_stmt_missing_except_finally.py.snap | 4 +- ..._syntax@try_stmt_misspelled_except.py.snap | 18 +- ..._syntax@try_stmt_mixed_except_kind.py.snap | 8 +- ..._syntax@tuple_context_manager_py38.py.snap | 6 +- ..._syntax@type_alias_incomplete_stmt.py.snap | 4 +- ...ntax@type_alias_invalid_value_expr.py.snap | 8 +- ...id_syntax@type_param_default_py312.py.snap | 10 +- ...ntax@type_param_invalid_bound_expr.py.snap | 8 +- ...id_syntax@type_param_missing_bound.py.snap | 4 +- ...syntax@type_param_param_spec_bound.py.snap | 6 +- ...am_param_spec_invalid_default_expr.py.snap | 10 +- ...e_param_param_spec_missing_default.py.snap | 4 +- ...aram_type_var_invalid_default_expr.py.snap | 10 +- ...ype_param_type_var_missing_default.py.snap | 6 +- ...ax@type_param_type_var_tuple_bound.py.snap | 6 +- ...ype_var_tuple_invalid_default_expr.py.snap | 8 +- ...ram_type_var_tuple_missing_default.py.snap | 4 +- .../invalid_syntax@type_stmt_py311.py.snap | 2 +- .../invalid_syntax@unary_plus_py314.py.snap | 4 +- ...arenthesized_named_expr_index_py38.py.snap | 2 +- ...nthesized_named_expr_set_comp_py38.py.snap | 2 +- ...esized_named_expr_set_literal_py38.py.snap | 6 +- ...erminated_fstring_newline_recovery.py.snap | 12 +- .../invalid_syntax@walrus_py37.py.snap | 2 +- ...yntax@while_stmt_invalid_test_expr.py.snap | 8 +- ...id_syntax@while_stmt_missing_colon.py.snap | 2 +- ...lid_syntax@while_stmt_missing_test.py.snap | 4 +- ..._items_parenthesized_missing_colon.py.snap | 2 +- ..._items_parenthesized_missing_comma.py.snap | 10 +- .../invalid_syntax@yield_after_comma.py.snap | 2 +- 337 files changed, 1369 insertions(+), 1413 deletions(-) diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index 234cdb5f3c3980..3fcc9ae5fbb642 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -79,9 +79,9 @@ pub enum InterpolatedStringErrorType { impl std::fmt::Display for InterpolatedStringErrorType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - Self::UnclosedLbrace => write!(f, "expecting `}}`"), + Self::UnclosedLbrace => f.write_str("expecting '}'"), Self::InvalidConversionFlag => write!(f, "invalid conversion character"), - Self::SingleRbrace => write!(f, "single `}}` is not allowed"), + Self::SingleRbrace => f.write_str("single '}' is not allowed"), Self::UnterminatedString => write!(f, "unterminated string"), Self::UnterminatedTripleQuotedString => write!(f, "unterminated triple-quoted string"), Self::LambdaWithoutParentheses => { @@ -101,6 +101,22 @@ impl std::fmt::Display for InterpolatedStringErrorType { } } +fn write_interpolated_string_error( + f: &mut std::fmt::Formatter, + kind: InterpolatedStringKind, + error: &InterpolatedStringErrorType, +) -> std::fmt::Result { + match error { + InterpolatedStringErrorType::UnterminatedString => { + write!(f, "unterminated {kind} literal") + } + InterpolatedStringErrorType::UnterminatedTripleQuotedString => { + write!(f, "unterminated triple-quoted {kind} literal") + } + _ => write!(f, "{kind}: {error}"), + } +} + /// Represents the different types of errors that can occur during parsing. #[derive(Debug, PartialEq, Eq, Clone, get_size2::GetSize)] pub enum ParseErrorType { @@ -223,113 +239,110 @@ impl std::fmt::Display for ParseErrorType { match self { ParseErrorType::OtherError(msg) => f.write_str(msg), ParseErrorType::StringAnnotationError(msg) => f.write_str(msg), - ParseErrorType::ExpectedToken { found, expected } => { - write!(f, "Expected {expected}, found {found}") - } + ParseErrorType::ExpectedToken { found, expected } => match (*expected, *found) { + (TokenKind::Colon, TokenKind::Newline) => f.write_str("expected ':'"), + (TokenKind::Lpar, _) => f.write_str("expected '('"), + (TokenKind::Else, found) if found != TokenKind::Colon => { + f.write_str("expected 'else' after 'if' expression") + } + _ => f.write_str("invalid syntax"), + }, ParseErrorType::Lexical(lex_error) => write!(f, "{lex_error}"), - ParseErrorType::SimpleStatementsOnSameLine => { - f.write_str("Simple statements must be separated by newlines or semicolons") - } - ParseErrorType::SimpleAndCompoundStatementOnSameLine => f.write_str( - "Compound statements are not allowed on the same line as simple statements", - ), + ParseErrorType::SimpleStatementsOnSameLine => f.write_str("invalid syntax"), + ParseErrorType::SimpleAndCompoundStatementOnSameLine => f.write_str("invalid syntax"), ParseErrorType::UnexpectedTokenAfterAsync(kind) => { write!( f, - "Expected `def`, `with` or `for` to follow `async`, found {kind}", + "expected `def`, `with` or `for` to follow `async`, found {kind}", ) } ParseErrorType::InvalidArgumentUnpackingOrder => { - f.write_str("Iterable argument unpacking cannot follow keyword argument unpacking") + f.write_str("iterable argument unpacking follows keyword argument unpacking") } ParseErrorType::IterableUnpackingInComprehension => { - f.write_str("Iterable unpacking cannot be used in a comprehension") + f.write_str("iterable unpacking cannot be used in a comprehension") } ParseErrorType::UnparenthesizedNamedExpression => { - f.write_str("Unparenthesized named expression cannot be used here") + f.write_str("unparenthesized named expression cannot be used here") } ParseErrorType::UnparenthesizedTupleExpression => { - f.write_str("Unparenthesized tuple expression cannot be used here") + f.write_str("unparenthesized tuple expression cannot be used here") } ParseErrorType::UnparenthesizedGeneratorExpression => { - f.write_str("Unparenthesized generator expression cannot be used here") + f.write_str("Generator expression must be parenthesized") } ParseErrorType::InvalidYieldExpressionUsage => { - f.write_str("Yield expression cannot be used here") + f.write_str("yield expression cannot be used here") } ParseErrorType::InvalidLambdaExpressionUsage => { - f.write_str("Lambda expression cannot be used here") - } - ParseErrorType::InvalidStarredExpressionUsage => { - f.write_str("Starred expression cannot be used here") + f.write_str("lambda expression cannot be used here") } + ParseErrorType::InvalidStarredExpressionUsage => f.write_str("invalid syntax"), ParseErrorType::PositionalAfterKeywordArgument => { - f.write_str("Positional argument cannot follow keyword argument") + f.write_str("positional argument follows keyword argument") } ParseErrorType::PositionalAfterKeywordUnpacking => { - f.write_str("Positional argument cannot follow keyword argument unpacking") + f.write_str("positional argument follows keyword argument unpacking") } - ParseErrorType::EmptySlice => f.write_str("Expected index or slice expression"), + ParseErrorType::EmptySlice => f.write_str("expected index or slice expression"), ParseErrorType::EmptyGlobalNames => { - f.write_str("Global statement must have at least one name") + f.write_str("global statement must have at least one name") } ParseErrorType::EmptyNonlocalNames => { - f.write_str("Nonlocal statement must have at least one name") + f.write_str("nonlocal statement must have at least one name") } ParseErrorType::EmptyDeleteTargets => { - f.write_str("Delete statement must have at least one target") + f.write_str("delete statement must have at least one target") } ParseErrorType::EmptyImportNames => { - f.write_str("Expected one or more symbol names after import") + f.write_str("Expected one or more names after 'import'") } ParseErrorType::EmptyTypeParams => f.write_str("Type parameter list cannot be empty"), ParseErrorType::ParamAfterVarKeywordParam => { - f.write_str("Parameter cannot follow var-keyword parameter") + f.write_str("arguments cannot follow var-keyword argument") } ParseErrorType::NonDefaultParamAfterDefaultParam => { - f.write_str("Parameter without a default cannot follow a parameter with a default") + f.write_str("parameter without a default follows parameter with a default") } ParseErrorType::ExpectedKeywordParam => { - f.write_str("Expected one or more keyword parameter after `*` separator") + f.write_str("named arguments must follow bare *") } ParseErrorType::VarParameterWithDefault => { - f.write_str("Parameter with `*` or `**` cannot have default value") + f.write_str("var-positional argument cannot have default value") } ParseErrorType::InvalidStarPatternUsage => { - f.write_str("Star pattern cannot be used here") + f.write_str("cannot use starred expression here") } ParseErrorType::InvalidMatchPatternTarget => f.write_str("cannot use '_' as a target"), ParseErrorType::ExpectedRealNumber => { - f.write_str("Expected a real number in complex literal pattern") + f.write_str("expected a real number in complex literal pattern") } ParseErrorType::ExpectedImaginaryNumber => { - f.write_str("Expected an imaginary number in complex literal pattern") + f.write_str("expected an imaginary number in complex literal pattern") } - ParseErrorType::ExpectedExpression => f.write_str("Expected an expression"), - ParseErrorType::UnexpectedIndentation => f.write_str("Unexpected indentation"), - ParseErrorType::InvalidAssignmentTarget => f.write_str("Invalid assignment target"), + ParseErrorType::ExpectedExpression => f.write_str("invalid syntax"), + ParseErrorType::UnexpectedIndentation => f.write_str("unexpected indentation"), + ParseErrorType::InvalidAssignmentTarget => f.write_str("invalid assignment target"), ParseErrorType::InvalidAnnotatedAssignmentTarget => { - f.write_str("Invalid annotated assignment target") + f.write_str("illegal target for annotation") } ParseErrorType::InvalidNamedAssignmentTarget => { - f.write_str("Assignment expression target must be an identifier") + f.write_str("assignment expression target must be an identifier") } ParseErrorType::InvalidAugmentedAssignmentTarget => { - f.write_str("Invalid augmented assignment target") + f.write_str("invalid augmented assignment target") } - ParseErrorType::InvalidDeleteTarget => f.write_str("Invalid delete target"), + ParseErrorType::InvalidDeleteTarget => f.write_str("invalid syntax"), ParseErrorType::UnexpectedIpythonEscapeCommand => { f.write_str("IPython escape commands are only allowed in `Mode::Ipython`") } - ParseErrorType::FStringError(fstring_error) => { - write!(f, "f-string: {fstring_error}") - } - ParseErrorType::TStringError(tstring_error) => { - write!(f, "t-string: {tstring_error}") + ParseErrorType::FStringError(error) => { + write_interpolated_string_error(f, InterpolatedStringKind::FString, error) } - ParseErrorType::UnexpectedExpressionToken => { - write!(f, "Unexpected token at the end of an expression") + ParseErrorType::TStringError(error) => { + write_interpolated_string_error(f, InterpolatedStringKind::TString, error) } + ParseErrorType::UnexpectedExpressionToken => f.write_str("invalid syntax"), } } } @@ -441,21 +454,23 @@ impl LexicalErrorType { impl std::fmt::Display for LexicalErrorType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - Self::StringError => write!(f, "Got unexpected string"), - Self::FStringError(error) => write!(f, "f-string: {error}"), - Self::TStringError(error) => write!(f, "t-string: {error}"), + Self::StringError => write!(f, "got unexpected string"), + Self::FStringError(error) => { + write_interpolated_string_error(f, InterpolatedStringKind::FString, error) + } + Self::TStringError(error) => { + write_interpolated_string_error(f, InterpolatedStringKind::TString, error) + } Self::InvalidByteLiteral => { write!(f, "bytes can only contain ASCII literal characters") } - Self::UnicodeError => write!(f, "Got unexpected unicode"), + Self::UnicodeError => write!(f, "got unexpected unicode"), Self::IndentationError => { write!(f, "unindent does not match any outer indentation level") } - Self::UnrecognizedToken { tok } => { - write!(f, "Got unexpected token {tok}") - } + Self::UnrecognizedToken { .. } => f.write_str("invalid syntax"), Self::LineContinuationError => { - write!(f, "Expected a newline after line continuation character") + write!(f, "unexpected character after line continuation character") } Self::Eof => write!(f, "unexpected EOF while parsing"), Self::OtherError(msg) => write!(f, "{msg}"), @@ -463,10 +478,10 @@ impl std::fmt::Display for LexicalErrorType { write!(f, "missing closing quote in string literal") } Self::MissingUnicodeLbrace => { - write!(f, "Missing `{{` in Unicode escape sequence") + write!(f, "missing `{{` in Unicode escape sequence") } Self::MissingUnicodeRbrace => { - write!(f, "Missing `}}` in Unicode escape sequence") + write!(f, "missing `}}` in Unicode escape sequence") } } } @@ -964,35 +979,35 @@ pub enum UnsupportedSyntaxErrorKind { impl Display for UnsupportedSyntaxError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let kind = match self.kind { - UnsupportedSyntaxErrorKind::Match => "Cannot use `match` statement", - UnsupportedSyntaxErrorKind::Walrus => "Cannot use named assignment expression (`:=`)", - UnsupportedSyntaxErrorKind::ExceptStar => "Cannot use `except*`", + UnsupportedSyntaxErrorKind::Match => "cannot use `match` statement", + UnsupportedSyntaxErrorKind::Walrus => "cannot use named assignment expression (`:=`)", + UnsupportedSyntaxErrorKind::ExceptStar => "cannot use `except*`", UnsupportedSyntaxErrorKind::UnparenthesizedNamedExpr( UnparenthesizedNamedExprKind::SequenceIndex, - ) => "Cannot use unparenthesized assignment expression in a sequence index", + ) => "cannot use unparenthesized assignment expression in a sequence index", UnsupportedSyntaxErrorKind::UnparenthesizedNamedExpr( UnparenthesizedNamedExprKind::SetLiteral, - ) => "Cannot use unparenthesized assignment expression as an element in a set literal", + ) => "cannot use unparenthesized assignment expression as an element in a set literal", UnsupportedSyntaxErrorKind::UnparenthesizedNamedExpr( UnparenthesizedNamedExprKind::SetComprehension, ) => { - "Cannot use unparenthesized assignment expression as an element in a set comprehension" + "cannot use unparenthesized assignment expression as an element in a set comprehension" } UnsupportedSyntaxErrorKind::ParenthesizedKeywordArgumentName => { - "Cannot use parenthesized keyword argument name" + "cannot use parenthesized keyword argument name" } UnsupportedSyntaxErrorKind::StarTuple(StarTupleKind::Return) => { - "Cannot use iterable unpacking in return statements" + "cannot use iterable unpacking in return statements" } UnsupportedSyntaxErrorKind::StarTuple(StarTupleKind::Yield) => { - "Cannot use iterable unpacking in yield expressions" + "cannot use iterable unpacking in yield expressions" } UnsupportedSyntaxErrorKind::RelaxedDecorator(relaxed_decorator_error) => { return match relaxed_decorator_error { RelaxedDecoratorError::CallExpression => { write!( f, - "Cannot use a call expression in a decorator on Python {} \ + "cannot use a call expression in a decorator on Python {} \ unless it is the top-level expression or it occurs \ in the argument list of a top-level call expression \ (relaxed decorator syntax was {changed})", @@ -1002,7 +1017,7 @@ impl Display for UnsupportedSyntaxError { } RelaxedDecoratorError::Other(description) => write!( f, - "Cannot use {description} outside function call arguments in a decorator on Python {} \ + "cannot use {description} outside function call arguments in a decorator on Python {} \ (syntax was {changed})", self.target_version, changed = self.kind.changed_version(), @@ -1010,54 +1025,54 @@ impl Display for UnsupportedSyntaxError { }; } UnsupportedSyntaxErrorKind::PositionalOnlyParameter => { - "Cannot use positional-only parameter separator" + "cannot use positional-only parameter separator" } - UnsupportedSyntaxErrorKind::TypeParameterList => "Cannot use type parameter lists", - UnsupportedSyntaxErrorKind::LazyImportStatement => "Cannot use `lazy` import statement", - UnsupportedSyntaxErrorKind::TypeAliasStatement => "Cannot use `type` alias statement", + UnsupportedSyntaxErrorKind::TypeParameterList => "cannot use type parameter lists", + UnsupportedSyntaxErrorKind::LazyImportStatement => "cannot use `lazy` import statement", + UnsupportedSyntaxErrorKind::TypeAliasStatement => "cannot use `type` alias statement", UnsupportedSyntaxErrorKind::TypeParamDefault => { - "Cannot set default type for a type parameter" + "cannot set default type for a type parameter" } UnsupportedSyntaxErrorKind::Pep701FString(FStringKind::Backslash) => { - "Cannot use an escape sequence (backslash) in f-strings" + "cannot use an escape sequence (backslash) in f-strings" } UnsupportedSyntaxErrorKind::Pep701FString(FStringKind::Comment) => { - "Cannot use comments in f-strings" + "cannot use comments in f-strings" } UnsupportedSyntaxErrorKind::Pep701FString(FStringKind::LineBreak) => { - "Cannot use line breaks in non-triple-quoted f-string replacement fields" + "cannot use line breaks in non-triple-quoted f-string replacement fields" } UnsupportedSyntaxErrorKind::Pep701FString(FStringKind::NestedQuote) => { - "Cannot reuse outer quote character in f-strings" + "cannot reuse outer quote character in f-strings" } UnsupportedSyntaxErrorKind::ParenthesizedContextManager => { - "Cannot use parentheses within a `with` statement" + "cannot use parentheses within a `with` statement" } UnsupportedSyntaxErrorKind::StarExpressionInIndex => { - "Cannot use star expression in index" + "cannot use star expression in index" } - UnsupportedSyntaxErrorKind::StarAnnotation => "Cannot use star annotation", + UnsupportedSyntaxErrorKind::StarAnnotation => "cannot use star annotation", UnsupportedSyntaxErrorKind::UnpackingInComprehension( ComprehensionUnpackingKind::IterableInList, - ) => "Cannot use iterable unpacking in a list comprehension", + ) => "cannot use iterable unpacking in a list comprehension", UnsupportedSyntaxErrorKind::UnpackingInComprehension( ComprehensionUnpackingKind::IterableInSet, - ) => "Cannot use iterable unpacking in a set comprehension", + ) => "cannot use iterable unpacking in a set comprehension", UnsupportedSyntaxErrorKind::UnpackingInComprehension( ComprehensionUnpackingKind::IterableInGenerator, - ) => "Cannot use iterable unpacking in a generator expression", + ) => "cannot use iterable unpacking in a generator expression", UnsupportedSyntaxErrorKind::UnpackingInComprehension( ComprehensionUnpackingKind::DictInDict, - ) => "Cannot use dictionary unpacking in a dict comprehension", + ) => "cannot use dictionary unpacking in a dict comprehension", UnsupportedSyntaxErrorKind::UnparenthesizedUnpackInFor => { - "Cannot use iterable unpacking in `for` statements" + "cannot use iterable unpacking in `for` statements" } UnsupportedSyntaxErrorKind::UnparenthesizedExceptionTypes => { - "Multiple exception types must be parenthesized" + "multiple exception types must be parenthesized" } - UnsupportedSyntaxErrorKind::TemplateStrings => "Cannot use t-strings", + UnsupportedSyntaxErrorKind::TemplateStrings => "cannot use t-strings", UnsupportedSyntaxErrorKind::UnaryPlusMatchPattern => { - "Unary '+' is not allowed in a literal pattern" + "unary '+' is not allowed in a literal pattern" } }; diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 212216c86fe849..7aedc4722ba586 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -1059,7 +1059,15 @@ impl<'src> Lexer<'src> { if !number.has_digit { let err = u64::from_str_radix("", radix.as_u32()).unwrap_err(); return self.push_error(LexicalError::new( - LexicalErrorType::OtherError(format!("{err:?}").into_boxed_str()), + LexicalErrorType::OtherError({ + let msg = format!("{err:?}"); + let mut chars = msg.chars(); + match chars.next() { + Some(first) => format!("{}{}", first.to_ascii_lowercase(), chars.as_str()) + .into_boxed_str(), + None => msg.into_boxed_str(), + } + }), self.token_range(), )); } @@ -1083,7 +1091,7 @@ impl<'src> Lexer<'src> { let is_float = if first_digit_or_dot == '.' || self.cursor.eat_char('.') { if self.cursor.eat_char('_') { return self.push_error(LexicalError::new( - LexicalErrorType::OtherError("Invalid Syntax".to_string().into_boxed_str()), + LexicalErrorType::OtherError("invalid syntax".to_string().into_boxed_str()), TextRange::new(self.offset() - TextSize::new(1), self.offset()), )); } @@ -1117,7 +1125,7 @@ impl<'src> Lexer<'src> { // Leading zeros in decimal integer literals are not permitted. self.push_error(LexicalError::new( LexicalErrorType::OtherError( - "Invalid decimal integer literal" + "invalid decimal integer literal" .to_string() .into_boxed_str(), ), diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 988b18d48ea2a7..de23604617f020 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -344,7 +344,7 @@ impl<'src> Parser<'src> { if left_precedence > OperatorPrecedence::Not { self.add_error( ParseErrorType::OtherError( - "Boolean 'not' expression cannot be used here".to_string(), + "'not' after an operator must be parenthesized".to_string(), ), &expr, ); @@ -359,7 +359,7 @@ impl<'src> Parser<'src> { { self.add_error( ParseErrorType::OtherError(format!( - "Unary '{unary_op}' expression cannot be used here", + "unary '{unary_op}' expression cannot be used here", )), &expr, ); @@ -388,7 +388,7 @@ impl<'src> Parser<'src> { if left_precedence >= OperatorPrecedence::Await { self.add_error( ParseErrorType::OtherError( - "Await expression cannot be used here".to_string(), + "await expression cannot be used here".to_string(), ), &await_expr, ); @@ -441,14 +441,14 @@ impl<'src> Parser<'src> { } let expr_name = match parsed_expr.expr { - Expr::Compare(_) => "Comparison", + Expr::Compare(_) => "comparison", Expr::BoolOp(_) | Expr::UnaryOp(ast::ExprUnaryOp { op: ast::UnaryOp::Not, .. - }) => "Boolean", - Expr::If(_) => "Conditional", - Expr::Lambda(_) => "Lambda", + }) => "boolean", + Expr::If(_) => "conditional", + Expr::Lambda(_) => "lambda", _ => return parsed_expr, }; @@ -543,13 +543,7 @@ impl<'src> Parser<'src> { if self.current_token_kind().is_keyword() { // Non-soft keyword - self.add_error( - ParseErrorType::OtherError(format!( - "Expected an identifier, but found a keyword {} that cannot be used here", - self.current_token_kind() - )), - range, - ); + self.add_error(ParseErrorType::OtherError("invalid syntax".into()), range); let text = self.src_text(range); let id = self.intern_name(text); @@ -566,7 +560,7 @@ impl<'src> Parser<'src> { fn parse_missing_identifier(&mut self) -> ast::Identifier { self.add_error( - ParseErrorType::OtherError("Expected an identifier".into()), + ParseErrorType::OtherError("invalid syntax".into()), self.current_token_range(), ); @@ -830,7 +824,7 @@ impl<'src> Parser<'src> { // not a name expression. We could add the expression into `args` but // that means the error is a missing comma instead. parser.add_error( - ParseErrorType::OtherError("Expected a parameter name".to_string()), + ParseErrorType::OtherError("expected a parameter name".to_string()), &parsed_expr, ); ast::Identifier { @@ -1523,10 +1517,10 @@ impl<'src> Parser<'src> { [StringType::TString(_), StringType::TString(_)] | [StringType::Bytes(_), StringType::Bytes(_)] => continue, [StringType::TString(_), _] | [_, StringType::TString(_)] => { - "Cannot mix t-string literals with string or bytes literals" + "cannot mix t-string literals with string or bytes literals" } [StringType::Bytes(_), _] | [_, StringType::Bytes(_)] => { - "Bytes literal cannot be mixed with non-bytes literals" + "cannot mix bytes and nonbytes literals" } _ => continue, }; @@ -2058,7 +2052,7 @@ impl<'src> Parser<'src> { // Nice error message when having a unclosed open bracket `[` if self.at_ts(NEWLINE_EOF_SET) { self.add_error( - ParseErrorType::OtherError("Missing closing bracket `]`".to_string()), + ParseErrorType::OtherError("missing closing bracket `]`".to_string()), self.current_token_range(), ); } @@ -2151,7 +2145,7 @@ impl<'src> Parser<'src> { // Nice error message when having a unclosed open brace `{` if self.at_ts(NEWLINE_EOF_SET) { self.add_error( - ParseErrorType::OtherError("Missing closing brace `}`".to_string()), + ParseErrorType::OtherError("missing closing brace `}`".to_string()), self.current_token_range(), ); } @@ -2313,7 +2307,7 @@ impl<'src> Parser<'src> { if self.at_ts(NEWLINE_EOF_SET) { let range = self.current_token_range(); self.add_error( - ParseErrorType::OtherError("Missing closing parenthesis `)`".to_string()), + ParseErrorType::OtherError("missing closing parenthesis `)`".to_string()), range, ); } diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index f728bcc94debbe..817ecda7c97a92 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -917,7 +917,9 @@ impl<'src> Parser<'src> { if let Some(trailing_comma_range) = trailing_comma_range { if !recovery_context_kind.allow_trailing_comma() { self.add_error( - ParseErrorType::OtherError("Trailing comma not allowed".to_string()), + ParseErrorType::OtherError( + "trailing comma not allowed without surrounding parentheses".to_string(), + ), trailing_comma_range, ); } @@ -1497,91 +1499,37 @@ impl RecoveryContextKind { if p.at(TokenKind::Indent) { ParseErrorType::UnexpectedIndentation } else { - ParseErrorType::OtherError("Expected a statement".to_string()) - } - } - RecoveryContextKind::Elif => ParseErrorType::OtherError( - "Expected an `elif` or `else` clause, or the end of the `if` statement." - .to_string(), - ), - RecoveryContextKind::Except => ParseErrorType::OtherError( - "Expected an `except` or `finally` clause or the end of the `try` statement." - .to_string(), - ), - RecoveryContextKind::AssignmentTargets => { - if p.current_token_kind().is_keyword() { - ParseErrorType::OtherError( - "The keyword is not allowed as a variable declaration name".to_string(), - ) - } else { - ParseErrorType::OtherError("Expected an assignment target".to_string()) - } - } - RecoveryContextKind::TypeParams => ParseErrorType::OtherError( - "Expected a type parameter or the end of the type parameter list".to_string(), - ), - RecoveryContextKind::ImportFromAsNames(parenthesized) => { - if parenthesized.is_yes() { - ParseErrorType::OtherError("Expected an import name or a ')'".to_string()) - } else { - ParseErrorType::OtherError("Expected an import name".to_string()) - } - } - RecoveryContextKind::ImportNames => { - ParseErrorType::OtherError("Expected an import name".to_string()) - } - RecoveryContextKind::Slices => ParseErrorType::OtherError( - "Expected an expression or the end of the slice list".to_string(), - ), - RecoveryContextKind::ListElements => { - ParseErrorType::OtherError("Expected an expression or a ']'".to_string()) - } - RecoveryContextKind::SetElements | RecoveryContextKind::DictElements => { - ParseErrorType::OtherError("Expected an expression or a '}'".to_string()) - } - RecoveryContextKind::TupleElements(parenthesized) => { - if parenthesized.is_yes() { - ParseErrorType::OtherError("Expected an expression or a ')'".to_string()) - } else { - ParseErrorType::OtherError("Expected an expression".to_string()) + ParseErrorType::OtherError("invalid syntax".to_string()) } } - RecoveryContextKind::SequenceMatchPattern(_) => ParseErrorType::OtherError( - "Expected a pattern or the end of the sequence pattern".to_string(), - ), - RecoveryContextKind::MatchPatternMapping => ParseErrorType::OtherError( - "Expected a mapping pattern or the end of the mapping pattern".to_string(), - ), - RecoveryContextKind::MatchPatternClassArguments => { - ParseErrorType::OtherError("Expected a pattern or a ')'".to_string()) - } - RecoveryContextKind::Arguments => { - ParseErrorType::OtherError("Expected an expression or a ')'".to_string()) - } - RecoveryContextKind::DeleteTargets => { - ParseErrorType::OtherError("Expected a delete target".to_string()) - } - RecoveryContextKind::Identifiers => { - ParseErrorType::OtherError("Expected an identifier".to_string()) + RecoveryContextKind::Elif + | RecoveryContextKind::Except + | RecoveryContextKind::AssignmentTargets + | RecoveryContextKind::TypeParams + | RecoveryContextKind::ImportFromAsNames(_) + | RecoveryContextKind::ImportNames + | RecoveryContextKind::Slices + | RecoveryContextKind::ListElements + | RecoveryContextKind::SetElements + | RecoveryContextKind::DictElements + | RecoveryContextKind::TupleElements(_) + | RecoveryContextKind::SequenceMatchPattern(_) + | RecoveryContextKind::MatchPatternMapping + | RecoveryContextKind::MatchPatternClassArguments + | RecoveryContextKind::Arguments + | RecoveryContextKind::DeleteTargets + | RecoveryContextKind::Identifiers + | RecoveryContextKind::Parameters(_) + | RecoveryContextKind::WithItems(_) => { + ParseErrorType::OtherError("invalid syntax".to_string()) } - RecoveryContextKind::Parameters(_) => ParseErrorType::OtherError( - "Expected a parameter or the end of the parameter list".to_string(), - ), - RecoveryContextKind::WithItems(with_item_kind) => match with_item_kind { - WithItemKind::Parenthesized => { - ParseErrorType::OtherError("Expected an expression or a ')'".to_string()) - } - _ => ParseErrorType::OtherError( - "Expected an expression or the end of the with item list".to_string(), - ), - }, RecoveryContextKind::InterpolatedStringElements(kind) => match kind { InterpolatedStringElementsKind::Regular(string_kind) => ParseErrorType::OtherError( - format!("Expected an element of or the end of the {string_kind}"), + format!("expected an element of or the end of the {string_kind}"), ), InterpolatedStringElementsKind::FormatSpec(string_kind) => { ParseErrorType::OtherError(format!( - "Expected an {string_kind} element or a '}}'" + "expected an {string_kind} element or a '}}'" )) } }, diff --git a/crates/ruff_python_parser/src/parser/pattern.rs b/crates/ruff_python_parser/src/parser/pattern.rs index 600183758f99af..5cd876e083f72f 100644 --- a/crates/ruff_python_parser/src/parser/pattern.rs +++ b/crates/ruff_python_parser/src/parser/pattern.rs @@ -198,7 +198,7 @@ impl Parser<'_> { if rest.is_some() { parser.add_error( ParseErrorType::OtherError( - "Only one double star pattern is allowed".to_string(), + "only one double star pattern is allowed".to_string(), ), parser.node_range(mapping_item_start), ); @@ -232,7 +232,7 @@ impl Parser<'_> { }, pattern => { parser.add_error( - ParseErrorType::OtherError("Invalid mapping pattern key".to_string()), + ParseErrorType::OtherError("invalid mapping pattern key".to_string()), &pattern, ); recovery::pattern_to_expr(pattern) @@ -247,7 +247,7 @@ impl Parser<'_> { if rest.is_some() { parser.add_error( ParseErrorType::OtherError( - "Pattern cannot follow a double star pattern".to_string(), + "pattern cannot follow a double star pattern".to_string(), ), parser.node_range(mapping_item_start), ); @@ -331,7 +331,7 @@ impl Parser<'_> { // parenthesis, it'll consider `case` an identifier token instead. self.add_error( ParseErrorType::OtherError(format!( - "Missing '{closing}'", + "missing '{closing}'", closing = if parentheses.is_list() { "]" } else { ")" } )), self.current_token_range(), @@ -509,7 +509,7 @@ impl Parser<'_> { if !unary_expr.operand.is_number_literal_expr() { self.add_error( ParseErrorType::OtherError( - "Expected a numeric literal after unary operator".to_string(), + "expected a numeric literal after unary operator".to_string(), ), unary_expr.operand.range(), ); @@ -585,7 +585,7 @@ impl Parser<'_> { // Upon encountering an unexpected token, return a `Pattern::MatchValue` containing // an empty `Expr::Name`. self.add_error( - ParseErrorType::OtherError("Expected a pattern".to_string()), + ParseErrorType::OtherError("expected a pattern".to_string()), self.current_token_range(), ); let invalid_node = Expr::Name(ast::ExprName { @@ -718,7 +718,7 @@ impl Parser<'_> { } pattern => { self.add_error( - ParseErrorType::OtherError("Invalid value for a class pattern".to_string()), + ParseErrorType::OtherError("invalid value for a class pattern".to_string()), &pattern, ); Box::new(recovery::pattern_to_expr(pattern)) @@ -751,9 +751,7 @@ impl Parser<'_> { name } else { parser.add_error( - ParseErrorType::OtherError( - "Expected an identifier for the keyword pattern".to_string(), - ), + ParseErrorType::OtherError("invalid syntax".to_string()), &pattern, ); ast::Identifier { @@ -779,7 +777,7 @@ impl Parser<'_> { if has_seen_keyword_pattern && has_seen_pattern { parser.add_error( ParseErrorType::OtherError( - "Positional patterns cannot follow keyword patterns".to_string(), + "positional patterns follow keyword patterns".to_string(), ), parser.node_range(pattern_start), ); diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index 1da7a52eeb6d4c..b1fe2c5c395d45 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -540,7 +540,7 @@ impl<'src> Parser<'src> { // raise from None self.add_error( ParseErrorType::OtherError( - "Exception missing in `raise` statement with cause".to_string(), + "exception missing in `raise` statement with cause".to_string(), ), self.current_token_range(), ); @@ -684,7 +684,7 @@ impl<'src> Parser<'src> { // from // from import x self.add_error( - ParseErrorType::OtherError("Expected a module name".to_string()), + ParseErrorType::OtherError("expected a module name".to_string()), self.current_token_range(), ); } @@ -732,7 +732,7 @@ impl<'src> Parser<'src> { // test_err from_import_parenthesized_star // from x import (*) self.add_error( - ParseErrorType::OtherError("Star import cannot be parenthesized".to_string()), + ParseErrorType::OtherError("star import cannot be parenthesized".to_string()), self.node_range(names_start), ); } @@ -744,7 +744,7 @@ impl<'src> Parser<'src> { // from x import *, a as b // from x import *, *, a self.add_error( - ParseErrorType::OtherError("Star import must be the only import".to_string()), + ParseErrorType::OtherError("star import must be the only import".to_string()), self.node_range(names_start), ); } @@ -807,7 +807,7 @@ impl<'src> Parser<'src> { // test_err import_alias_missing_asname // import x as self.add_error( - ParseErrorType::OtherError("Expected symbol after `as`".to_string()), + ParseErrorType::OtherError("expected symbol after `as`".to_string()), self.current_token_range(), ); None @@ -1152,7 +1152,7 @@ impl<'src> Parser<'src> { } else { parser.add_error( ParseErrorType::OtherError( - "Only integer literals are allowed in subscript expressions \ + "only integer literals are allowed in subscript expressions \ in help end escape command" .to_string(), ), @@ -1171,7 +1171,7 @@ impl<'src> Parser<'src> { _ => { parser.add_error( ParseErrorType::OtherError( - "Expected name, subscript or attribute expression \ + "expected name, subscript or attribute expression \ in help end escape command" .to_string(), ), @@ -1194,7 +1194,7 @@ impl<'src> Parser<'src> { let token_range = self.node_range(start); self.add_error( ParseErrorType::OtherError( - "Help end escape command cannot be applied on a parenthesized expression" + "help end escape command cannot be applied on a parenthesized expression" .to_string(), ), token_range, @@ -1204,7 +1204,7 @@ impl<'src> Parser<'src> { if self.at(TokenKind::Question) { self.add_error( ParseErrorType::OtherError( - "Maximum of 2 `?` tokens are allowed in help end escape command".to_string(), + "maximum of 2 `?` tokens are allowed in help end escape command".to_string(), ), self.current_token_range(), ); @@ -1599,7 +1599,7 @@ impl<'src> Parser<'src> { for handler_err_range in mixed_except_ranges { self.add_error( ParseErrorType::OtherError( - "Cannot have both 'except' and 'except*' on the same 'try'".to_string(), + "cannot have both 'except' and 'except*' on the same 'try'".to_string(), ), handler_err_range, ); @@ -1644,9 +1644,7 @@ impl<'src> Parser<'src> { // else: // pass self.add_error( - ParseErrorType::OtherError( - "Expected `except` or `finally` after `try` block".to_string(), - ), + ParseErrorType::OtherError("expected 'except' or 'finally' block".to_string()), self.current_token_range(), ); } @@ -1786,7 +1784,7 @@ impl<'src> Parser<'src> { // except* as exc: // pass self.add_error( - ParseErrorType::OtherError("Expected one or more exception types".to_string()), + ParseErrorType::OtherError("expected one or more exception types".to_string()), self.current_token_range(), ); } @@ -1810,7 +1808,7 @@ impl<'src> Parser<'src> { // except Exception as // pass self.add_error( - ParseErrorType::OtherError("Expected name after `as`".to_string()), + ParseErrorType::OtherError("expected name after `as`".to_string()), self.current_token_range(), ); None @@ -1837,7 +1835,7 @@ impl<'src> Parser<'src> { { self.add_error( ParseErrorType::OtherError( - "Multiple exception types must be parenthesized when using `as`".to_string(), + "multiple exception types must be parenthesized when using 'as'".to_string(), ), TextRange::new(types_start, self.current_token_range().start()), ); @@ -2118,7 +2116,7 @@ impl<'src> Parser<'src> { // def foo() -> int, str: ... self.add_error( ParseErrorType::OtherError( - "Multiple return types must be parenthesized".to_string(), + "multiple return types must be parenthesized".to_string(), ), returns.range(), ); @@ -2280,7 +2278,7 @@ impl<'src> Parser<'src> { if !self.at_expr() { self.add_error( ParseErrorType::OtherError( - "Expected the start of an expression after `with` keyword".to_string(), + "expected the start of an expression after `with` keyword".to_string(), ), self.current_token_range(), ); @@ -2768,7 +2766,7 @@ impl<'src> Parser<'src> { // case _: ... self.add_error( ParseErrorType::OtherError( - "Expected an indented block after `match` statement".to_string(), + "expected an indented block after `match` statement".to_string(), ), self.current_token_range(), ); @@ -2794,7 +2792,7 @@ impl<'src> Parser<'src> { // match y: // case _: ... self.add_error( - ParseErrorType::OtherError("Expected `case` block".to_string()), + ParseErrorType::OtherError("expected `case` block".to_string()), self.current_token_range(), ); return cases; @@ -3088,7 +3086,7 @@ impl<'src> Parser<'src> { // x = 1 self.add_error( ParseErrorType::OtherError( - "Expected class, function definition or async function definition \ + "expected class, function definition or async function definition \ after decorator" .to_string(), ), @@ -3146,7 +3144,7 @@ impl<'src> Parser<'src> { // if True: self.add_error( ParseErrorType::OtherError(format!( - "Expected an indented block after {parent_clause}" + "expected an indented block after {parent_clause}" )), if self.current_token_range().is_empty() { newline_range @@ -3161,7 +3159,7 @@ impl<'src> Parser<'src> { // test_err clause_expect_single_statement // if True: if True: pass self.add_error( - ParseErrorType::OtherError("Expected a simple statement".to_string()), + ParseErrorType::OtherError("expected a simple statement".to_string()), self.current_token_range(), ); } @@ -3417,7 +3415,7 @@ impl<'src> Parser<'src> { // def foo(a, *args1, b, c, *args2): ... parser.add_error( ParseErrorType::OtherError( - "Only one '*' parameter allowed".to_string(), + "* argument may appear only once".to_string(), ), param_star_range, ); @@ -3437,7 +3435,7 @@ impl<'src> Parser<'src> { // def foo(a, *, b, c, *): ... parser.add_error( ParseErrorType::OtherError( - "Only one '*' separator allowed".to_string(), + "only one '*' separator allowed".to_string(), ), star_range, ); @@ -3449,7 +3447,7 @@ impl<'src> Parser<'src> { // def foo(a, *args, b, c, *): ... parser.add_error( ParseErrorType::OtherError( - "Keyword-only parameter separator not allowed \ + "keyword-only parameter separator not allowed \ after '*' parameter" .to_string(), ), @@ -3474,7 +3472,7 @@ impl<'src> Parser<'src> { // def foo(a, **kwargs1, **kwargs2): ... parser.add_error( ParseErrorType::OtherError( - "Only one '**' parameter allowed".to_string(), + "only one '**' parameter allowed".to_string(), ), param_double_star_range, ); @@ -3518,8 +3516,7 @@ impl<'src> Parser<'src> { // def foo(/, a): ... parser.add_error( ParseErrorType::OtherError( - "Position-only parameter separator not allowed as first parameter" - .to_string(), + "at least one argument must precede /".to_string(), ), slash_range, ); @@ -3530,9 +3527,7 @@ impl<'src> Parser<'src> { // def foo(a, /, /, b): ... // def foo(a, /, b, c, /): ... parser.add_error( - ParseErrorType::OtherError( - "Only one '/' separator allowed".to_string(), - ), + ParseErrorType::OtherError("/ may appear only once".to_string()), slash_range, ); } @@ -3544,9 +3539,7 @@ impl<'src> Parser<'src> { // def foo(a, *, /, b): ... // def foo(a, *, b, c, /, d): ... parser.add_error( - ParseErrorType::OtherError( - "'/' parameter must appear before '*' parameter".to_string(), - ), + ParseErrorType::OtherError("/ must be ahead of *".to_string()), slash_range, ); } @@ -3900,13 +3893,13 @@ impl<'src> Parser<'src> { match expr { Expr::List(_) => self.add_error( ParseErrorType::OtherError( - "Only single target (not list) can be annotated".to_string(), + "only single target (not list) can be annotated".to_string(), ), expr, ), Expr::Tuple(_) => self.add_error( ParseErrorType::OtherError( - "Only single target (not tuple) can be annotated".to_string(), + "only single target (not tuple) can be annotated".to_string(), ), expr, ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_big.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_big.snap index 895df4720c05d1..4297865f22dbef 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_big.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_big.snap @@ -14,7 +14,7 @@ expression: "lex_invalid(source, Mode::Module)" [ LexicalError { error: OtherError( - "Invalid decimal integer literal", + "invalid decimal integer literal", ), location: 0..85, }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_small.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_small.snap index 5fc95dcc0522ca..d5176b70751422 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_small.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_small.snap @@ -14,7 +14,7 @@ expression: "lex_invalid(source, Mode::Module)" [ LexicalError { error: OtherError( - "Invalid decimal integer literal", + "invalid decimal integer literal", ), location: 0..3, }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_t_string_concat_1_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_t_string_concat_1_error.snap index c7d1a2eae42d8c..819956a4275692 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_t_string_concat_1_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_t_string_concat_1_error.snap @@ -4,7 +4,7 @@ expression: suite --- ParseError { error: OtherError( - "Cannot mix t-string literals with string or bytes literals", + "cannot mix t-string literals with string or bytes literals", ), location: 0..18, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_t_string_concat_2_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_t_string_concat_2_error.snap index 0297635218dcba..3b4b4164ec2925 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_t_string_concat_2_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_t_string_concat_2_error.snap @@ -4,7 +4,7 @@ expression: suite --- ParseError { error: OtherError( - "Cannot mix t-string literals with string or bytes literals", + "cannot mix t-string literals with string or bytes literals", ), location: 0..22, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_1_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_1_error.snap index 753419af53e52f..c9da8b3ca7344e 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_1_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_1_error.snap @@ -4,7 +4,7 @@ expression: suite --- ParseError { error: OtherError( - "Cannot mix t-string literals with string or bytes literals", + "cannot mix t-string literals with string or bytes literals", ), location: 0..17, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_2_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_2_error.snap index 753419af53e52f..c9da8b3ca7344e 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_2_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_2_error.snap @@ -4,7 +4,7 @@ expression: suite --- ParseError { error: OtherError( - "Cannot mix t-string literals with string or bytes literals", + "cannot mix t-string literals with string or bytes literals", ), location: 0..17, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_3_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_3_error.snap index 0297635218dcba..3b4b4164ec2925 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_3_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_3_error.snap @@ -4,7 +4,7 @@ expression: suite --- ParseError { error: OtherError( - "Cannot mix t-string literals with string or bytes literals", + "cannot mix t-string literals with string or bytes literals", ), location: 0..22, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_4_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_4_error.snap index c5d67c1b43b07e..9ae7f8f91d1f00 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_4_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_t_string_concat_4_error.snap @@ -4,7 +4,7 @@ expression: suite --- ParseError { error: OtherError( - "Cannot mix t-string literals with string or bytes literals", + "cannot mix t-string literals with string or bytes literals", ), location: 0..31, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_t_string_concat_1_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_t_string_concat_1_error.snap index c7d1a2eae42d8c..819956a4275692 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_t_string_concat_1_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_t_string_concat_1_error.snap @@ -4,7 +4,7 @@ expression: suite --- ParseError { error: OtherError( - "Cannot mix t-string literals with string or bytes literals", + "cannot mix t-string literals with string or bytes literals", ), location: 0..18, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_t_string_concat_2_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_t_string_concat_2_error.snap index 0297635218dcba..3b4b4164ec2925 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_t_string_concat_2_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_t_string_concat_2_error.snap @@ -4,7 +4,7 @@ expression: suite --- ParseError { error: OtherError( - "Cannot mix t-string literals with string or bytes literals", + "cannot mix t-string literals with string or bytes literals", ), location: 0..22, } diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap index 7e0bffaec45795..6911290ff0bbfd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap @@ -198,7 +198,7 @@ Module( | 1 | x: *int = 1 - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | x: yield a = 1 3 | x: yield from b = 1 | @@ -207,7 +207,7 @@ Module( | 1 | x: *int = 1 2 | x: yield a = 1 - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | x: yield from b = 1 4 | x: y := int = 1 | @@ -217,7 +217,7 @@ Module( 1 | x: *int = 1 2 | x: yield a = 1 3 | x: yield from b = 1 - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 4 | x: y := int = 1 | @@ -226,7 +226,7 @@ Module( 2 | x: yield a = 1 3 | x: yield from b = 1 4 | x: y := int = 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap index 31092c4e4d7a1a..25b317e827f654 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap @@ -514,7 +514,7 @@ Module( | 1 | "abc": str = "def" - | ^^^^^ Syntax Error: Invalid annotated assignment target + | ^^^^^ Syntax Error: illegal target for annotation 2 | call(): str = "no" 3 | *x: int = 1, 2 | @@ -523,7 +523,7 @@ Module( | 1 | "abc": str = "def" 2 | call(): str = "no" - | ^^^^^^ Syntax Error: Invalid annotated assignment target + | ^^^^^^ Syntax Error: illegal target for annotation 3 | *x: int = 1, 2 4 | # Tuple assignment | @@ -533,7 +533,7 @@ Module( 1 | "abc": str = "def" 2 | call(): str = "no" 3 | *x: int = 1, 2 - | ^^ Syntax Error: Invalid annotated assignment target + | ^^ Syntax Error: illegal target for annotation 4 | # Tuple assignment 5 | x,: int = 1 | @@ -543,7 +543,7 @@ Module( 3 | *x: int = 1, 2 4 | # Tuple assignment 5 | x,: int = 1 - | ^^ Syntax Error: Only single target (not tuple) can be annotated + | ^^ Syntax Error: only single target (not tuple) can be annotated 6 | x, y: int = 1, 2 7 | (x, y): int = 1, 2 | @@ -553,7 +553,7 @@ Module( 4 | # Tuple assignment 5 | x,: int = 1 6 | x, y: int = 1, 2 - | ^^^^ Syntax Error: Only single target (not tuple) can be annotated + | ^^^^ Syntax Error: only single target (not tuple) can be annotated 7 | (x, y): int = 1, 2 8 | # List assignment | @@ -563,7 +563,7 @@ Module( 5 | x,: int = 1 6 | x, y: int = 1, 2 7 | (x, y): int = 1, 2 - | ^^^^^^ Syntax Error: Only single target (not tuple) can be annotated + | ^^^^^^ Syntax Error: only single target (not tuple) can be annotated 8 | # List assignment 9 | [x]: int = 1 | @@ -573,7 +573,7 @@ Module( 7 | (x, y): int = 1, 2 8 | # List assignment 9 | [x]: int = 1 - | ^^^ Syntax Error: Only single target (not list) can be annotated + | ^^^ Syntax Error: only single target (not list) can be annotated 10 | [x, y]: int = 1, 2 | @@ -582,4 +582,4 @@ Module( 8 | # List assignment 9 | [x]: int = 1 10 | [x, y]: int = 1, 2 - | ^^^^^^ Syntax Error: Only single target (not list) can be annotated + | ^^^^^^ Syntax Error: only single target (not list) can be annotated diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_value.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_value.py.snap index 06460f9b667f66..ec008d9cdefaae 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_value.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_value.py.snap @@ -234,7 +234,7 @@ Module( | 1 | x: Any = *a and b - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 2 | x: Any = x := 1 3 | x: list = [x, *a | b, *a or b] | @@ -243,7 +243,7 @@ Module( | 1 | x: Any = *a and b 2 | x: Any = x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 3 | x: list = [x, *a | b, *a or b] | @@ -252,4 +252,4 @@ Module( 1 | x: Any = *a and b 2 | x: Any = x := 1 3 | x: list = [x, *a | b, *a or b] - | ^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^ Syntax Error: boolean expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_missing_rhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_missing_rhs.py.snap index fe6cc24a22d5f3..92570b7f015ba3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_missing_rhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_missing_rhs.py.snap @@ -44,4 +44,4 @@ Module( | 1 | x: int = - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_type_alias_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_type_alias_annotation.py.snap index 71d670e65a0e59..89bcf3961a92f2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_type_alias_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_type_alias_annotation.py.snap @@ -119,7 +119,7 @@ Module( | 1 | a: type X = int - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax 2 | lambda: type X = int | @@ -127,4 +127,4 @@ Module( | 1 | a: type X = int 2 | lambda: type X = int - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_unparenthesized_generator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_unparenthesized_generator.py.snap index 02a77c22f577ac..e0a15c26424a21 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_unparenthesized_generator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_unparenthesized_generator.py.snap @@ -337,7 +337,7 @@ Module( | 1 | sum(x for x in range(10), 5) - | ^^^^^^^^^^^^^^^^^^^^ Syntax Error: Unparenthesized generator expression cannot be used here + | ^^^^^^^^^^^^^^^^^^^^ Syntax Error: Generator expression must be parenthesized 2 | total(1, 2, x for x in range(5), 6) 3 | sum(x for x in range(10),) | @@ -346,7 +346,7 @@ Module( | 1 | sum(x for x in range(10), 5) 2 | total(1, 2, x for x in range(5), 6) - | ^^^^^^^^^^^^^^^^^^^ Syntax Error: Unparenthesized generator expression cannot be used here + | ^^^^^^^^^^^^^^^^^^^ Syntax Error: Generator expression must be parenthesized 3 | sum(x for x in range(10),) | @@ -355,4 +355,4 @@ Module( 1 | sum(x for x in range(10), 5) 2 | total(1, 2, x for x in range(5), 6) 3 | sum(x for x in range(10),) - | ^^^^^^^^^^^^^^^^^^^^ Syntax Error: Unparenthesized generator expression cannot be used here + | ^^^^^^^^^^^^^^^^^^^^ Syntax Error: Generator expression must be parenthesized diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_msg.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_msg.py.snap index 4f6c6c2e3396e2..6dab2a954e8573 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_msg.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_msg.py.snap @@ -34,4 +34,4 @@ Module( | 1 | assert x, - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_test.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_test.py.snap index c19f27da4ad1a7..4c28c641aecb10 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_test.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_empty_test.py.snap @@ -34,4 +34,4 @@ Module( | 1 | assert - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap index 97293b6d4d3a7d..cd189ef161a5c6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap @@ -147,7 +147,7 @@ Module( | 1 | assert False, *x - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | assert False, assert x 3 | assert False, yield x | @@ -156,7 +156,7 @@ Module( | 1 | assert False, *x 2 | assert False, assert x - | ^^^^^^ Syntax Error: Expected an expression + | ^^^^^^ Syntax Error: invalid syntax 3 | assert False, yield x 4 | assert False, x := 1 | @@ -166,7 +166,7 @@ Module( 1 | assert False, *x 2 | assert False, assert x 3 | assert False, yield x - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 4 | assert False, x := 1 | @@ -175,4 +175,4 @@ Module( 2 | assert False, assert x 3 | assert False, yield x 4 | assert False, x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap index d8b43159b8a0cd..da455d6a67f409 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap @@ -123,7 +123,7 @@ Module( | 1 | assert *x - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | assert assert x 3 | assert yield x | @@ -132,7 +132,7 @@ Module( | 1 | assert *x 2 | assert assert x - | ^^^^^^ Syntax Error: Expected an identifier, but found a keyword `assert` that cannot be used here + | ^^^^^^ Syntax Error: invalid syntax 3 | assert yield x 4 | assert x := 1 | @@ -141,7 +141,7 @@ Module( | 1 | assert *x 2 | assert assert x - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax 3 | assert yield x 4 | assert x := 1 | @@ -151,7 +151,7 @@ Module( 1 | assert *x 2 | assert assert x 3 | assert yield x - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 4 | assert x := 1 | @@ -160,4 +160,4 @@ Module( 2 | assert assert x 3 | assert yield x 4 | assert x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap index 7870b203c98ca0..fe4f41f658a360 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap @@ -253,7 +253,7 @@ Module( | 1 | 1 = 1 - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target 2 | x = 1 = 2 3 | x = 1 = y = 2 = z | @@ -262,7 +262,7 @@ Module( | 1 | 1 = 1 2 | x = 1 = 2 - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target 3 | x = 1 = y = 2 = z 4 | ["a", "b"] = ["a", "b"] | @@ -272,7 +272,7 @@ Module( 1 | 1 = 1 2 | x = 1 = 2 3 | x = 1 = y = 2 = z - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target 4 | ["a", "b"] = ["a", "b"] | @@ -281,7 +281,7 @@ Module( 1 | 1 = 1 2 | x = 1 = 2 3 | x = 1 = y = 2 = z - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target 4 | ["a", "b"] = ["a", "b"] | @@ -290,11 +290,11 @@ Module( 2 | x = 1 = 2 3 | x = 1 = y = 2 = z 4 | ["a", "b"] = ["a", "b"] - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target | 2 | x = 1 = 2 3 | x = 1 = y = 2 = z 4 | ["a", "b"] = ["a", "b"] - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_value_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_value_expr.py.snap index 9f235c545a65d4..b016acc33e9af7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_value_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_value_expr.py.snap @@ -327,7 +327,7 @@ Module( | 1 | x = (*a and b,) - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 2 | x = (42, *yield x) 3 | x = (42, *yield from x) | @@ -336,7 +336,7 @@ Module( | 1 | x = (*a and b,) 2 | x = (42, *yield x) - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | x = (42, *yield from x) 4 | x = (*lambda x: x,) | @@ -346,7 +346,7 @@ Module( 1 | x = (*a and b,) 2 | x = (42, *yield x) 3 | x = (42, *yield from x) - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 4 | x = (*lambda x: x,) 5 | x = x := 1 | @@ -356,7 +356,7 @@ Module( 2 | x = (42, *yield x) 3 | x = (42, *yield from x) 4 | x = (*lambda x: x,) - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 5 | x = x := 1 | @@ -365,4 +365,4 @@ Module( 3 | x = (42, *yield from x) 4 | x = (*lambda x: x,) 5 | x = x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_keyword_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_keyword_target.py.snap index 74e150b4b2b599..cc058852ad7b55 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_keyword_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_keyword_target.py.snap @@ -155,7 +155,7 @@ Module( | 1 | a = pass = c - | ^^^^ Syntax Error: Expected an identifier, but found a keyword `pass` that cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | a + b 3 | a = b = pass = c | @@ -165,6 +165,6 @@ Module( 1 | a = pass = c 2 | a + b 3 | a = b = pass = c - | ^^^^ Syntax Error: Expected an identifier, but found a keyword `pass` that cannot be used here + | ^^^^ Syntax Error: invalid syntax 4 | a + b | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_missing_rhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_missing_rhs.py.snap index 1dfbced4fb626f..a99d1bc6e828f3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_missing_rhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_missing_rhs.py.snap @@ -209,7 +209,7 @@ Module( | 1 | x = - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 1 + 1 3 | x = y = 4 | 2 + 2 @@ -220,7 +220,7 @@ Module( 1 | x = 2 | 1 + 1 3 | x = y = - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | 2 + 2 5 | x = = y 6 | 3 + 3 @@ -231,6 +231,6 @@ Module( 3 | x = y = 4 | 2 + 2 5 | x = = y - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 6 | 3 + 3 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@async_unexpected_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@async_unexpected_token.py.snap index b11d8a0157286f..a908f13937d681 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@async_unexpected_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@async_unexpected_token.py.snap @@ -195,7 +195,7 @@ Module( | 1 | async class Foo: ... - | ^^^^^ Syntax Error: Expected `def`, `with` or `for` to follow `async`, found `class` + | ^^^^^ Syntax Error: expected `def`, `with` or `for` to follow `async`, found `class` 2 | async while test: ... 3 | async x = 1 | @@ -204,7 +204,7 @@ Module( | 1 | async class Foo: ... 2 | async while test: ... - | ^^^^^ Syntax Error: Expected `def`, `with` or `for` to follow `async`, found `while` + | ^^^^^ Syntax Error: expected `def`, `with` or `for` to follow `async`, found `while` 3 | async x = 1 4 | async async def foo(): ... | @@ -214,7 +214,7 @@ Module( 1 | async class Foo: ... 2 | async while test: ... 3 | async x = 1 - | ^ Syntax Error: Expected `def`, `with` or `for` to follow `async`, found identifier + | ^ Syntax Error: expected `def`, `with` or `for` to follow `async`, found identifier 4 | async async def foo(): ... 5 | async match test: | @@ -224,7 +224,7 @@ Module( 2 | async while test: ... 3 | async x = 1 4 | async async def foo(): ... - | ^^^^^ Syntax Error: Expected `def`, `with` or `for` to follow `async`, found `async` + | ^^^^^ Syntax Error: expected `def`, `with` or `for` to follow `async`, found `async` 5 | async match test: 6 | case _: ... | @@ -234,6 +234,6 @@ Module( 3 | async x = 1 4 | async async def foo(): ... 5 | async match test: - | ^^^^^ Syntax Error: Expected `def`, `with` or `for` to follow `async`, found `match` + | ^^^^^ Syntax Error: expected `def`, `with` or `for` to follow `async`, found `match` 6 | case _: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap index d84f95d27220ef..cf8dfad9a5753a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap @@ -207,7 +207,7 @@ Module( | 1 | 1 += 1 - | ^ Syntax Error: Invalid augmented assignment target + | ^ Syntax Error: invalid augmented assignment target 2 | "a" += "b" 3 | *x += 1 | @@ -216,7 +216,7 @@ Module( | 1 | 1 += 1 2 | "a" += "b" - | ^^^ Syntax Error: Invalid augmented assignment target + | ^^^ Syntax Error: invalid augmented assignment target 3 | *x += 1 4 | pass += 1 | @@ -226,7 +226,7 @@ Module( 1 | 1 += 1 2 | "a" += "b" 3 | *x += 1 - | ^^ Syntax Error: Invalid augmented assignment target + | ^^ Syntax Error: invalid augmented assignment target 4 | pass += 1 5 | x += pass | @@ -236,7 +236,7 @@ Module( 2 | "a" += "b" 3 | *x += 1 4 | pass += 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 5 | x += pass 6 | (x + y) += 1 | @@ -246,7 +246,7 @@ Module( 3 | *x += 1 4 | pass += 1 5 | x += pass - | ^^^^ Syntax Error: Expected an identifier, but found a keyword `pass` that cannot be used here + | ^^^^ Syntax Error: invalid syntax 6 | (x + y) += 1 | @@ -255,4 +255,4 @@ Module( 4 | pass += 1 5 | x += pass 6 | (x + y) += 1 - | ^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^ Syntax Error: invalid augmented assignment target diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_value.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_value.py.snap index b2fefb390b9d7a..6c4224ec37766f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_value.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_value.py.snap @@ -245,7 +245,7 @@ Module( | 1 | x += *a and b - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 2 | x += *yield x 3 | x += *yield from x | @@ -254,7 +254,7 @@ Module( | 1 | x += *a and b 2 | x += *yield x - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | x += *yield from x 4 | x += *lambda x: x | @@ -264,7 +264,7 @@ Module( 1 | x += *a and b 2 | x += *yield x 3 | x += *yield from x - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 4 | x += *lambda x: x 5 | x += y := 1 | @@ -274,7 +274,7 @@ Module( 2 | x += *yield x 3 | x += *yield from x 4 | x += *lambda x: x - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 5 | x += y := 1 | @@ -283,4 +283,4 @@ Module( 3 | x += *yield from x 4 | x += *lambda x: x 5 | x += y := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_missing_rhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_missing_rhs.py.snap index 5df76ca8fec132..89a0e1c7d0433b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_missing_rhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_missing_rhs.py.snap @@ -127,7 +127,7 @@ Module( | 1 | x += - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 1 + 1 3 | x += y += 4 | 2 + 2 @@ -138,7 +138,7 @@ Module( 1 | x += 2 | 1 + 1 3 | x += y += - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 4 | 2 + 2 | @@ -147,6 +147,6 @@ Module( 1 | x += 2 | 1 + 1 3 | x += y += - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 4 | 2 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap index 5bd5bb17aba6df..9a0b8e2ef7cf53 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap @@ -69,4 +69,4 @@ Module( 2 | 1 3 | / \ 4 | | 2 - | |____^ Syntax Error: Unexpected indentation + | |____^ Syntax Error: unexpected indentation diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap index 1596207cb4787c..d83d217f061314 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap @@ -94,4 +94,4 @@ Module( 1 | match subject: 2 | case 1: 3 | case 2: ... - | ^^^^ Syntax Error: Expected an indented block after `case` block + | ^^^^ Syntax Error: expected an indented block after `case` block diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap index cf5e90eb9a2544..ffabbbe51134e5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap @@ -91,7 +91,7 @@ Module( | 1 | class Foo: 2 | class Foo(): - | ^^^^^ Syntax Error: Expected an indented block after `class` definition + | ^^^^^ Syntax Error: expected an indented block after `class` definition 3 | x = 42 | @@ -100,4 +100,4 @@ Module( 1 | class Foo: 2 | class Foo(): 3 | x = 42 - | ^ Syntax Error: Expected an indented block after `class` definition + | ^ Syntax Error: expected an indented block after `class` definition diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_missing_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_missing_name.py.snap index ff33234e31651f..4a7c1916d125e3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_missing_name.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_missing_name.py.snap @@ -147,7 +147,7 @@ Module( | 1 | class : ... - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax 2 | class (): ... 3 | class (metaclass=ABC): ... | @@ -156,7 +156,7 @@ Module( | 1 | class : ... 2 | class (): ... - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax 3 | class (metaclass=ABC): ... | @@ -165,4 +165,4 @@ Module( 1 | class : ... 2 | class (): ... 3 | class (metaclass=ABC): ... - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap index 4dc456924ebd84..104e87b7484b7b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap @@ -130,7 +130,7 @@ Module( | 1 | class Foo[T1, *T2(a, b): - | ^ Syntax Error: Expected `]`, found `(` + | ^ Syntax Error: invalid syntax 2 | pass 3 | x = 10 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_type_params_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_type_params_py311.py.snap index f6eade30006136..9fd4889b31667b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_type_params_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_type_params_py311.py.snap @@ -191,7 +191,7 @@ Module( | 1 | # parse_options: {"target-version": "3.11"} 2 | class Foo[S: (str, bytes), T: float, *Ts, **P]: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Cannot use type parameter lists on Python 3.11 (syntax was added in Python 3.12) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot use type parameter lists on Python 3.11 (syntax was added in Python 3.12) 3 | class Foo[]: ... | @@ -200,4 +200,4 @@ Module( 1 | # parse_options: {"target-version": "3.11"} 2 | class Foo[S: (str, bytes), T: float, *Ts, **P]: ... 3 | class Foo[]: ... - | ^^ Syntax Error: Cannot use type parameter lists on Python 3.11 (syntax was added in Python 3.12) + | ^^ Syntax Error: cannot use type parameter lists on Python 3.11 (syntax was added in Python 3.12) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap index 10161b4220a0f2..d2a4c57dd55f91 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap @@ -59,7 +59,7 @@ Module( 1 | # Here, the error is highlighted at the `pass` token 2 | if True: 3 | pass - | ^^^^ Syntax Error: Expected an indented block after `if` statement + | ^^^^ Syntax Error: expected an indented block after `if` statement 4 | # The parser is at the end of the program, so let's highlight 5 | # at the newline token after `:` | @@ -69,4 +69,4 @@ Module( 4 | # The parser is at the end of the program, so let's highlight 5 | # at the newline token after `:` 6 | if True: - | ^ Syntax Error: Expected an indented block after `if` statement + | ^ Syntax Error: expected an indented block after `if` statement diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_single_statement.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_single_statement.py.snap index c9934eb6ff119b..1cf42da43b68e0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_single_statement.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_single_statement.py.snap @@ -58,4 +58,4 @@ Module( | 1 | if True: if True: pass - | ^^ Syntax Error: Expected a simple statement + | ^^ Syntax Error: expected a simple statement diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap index aeeb4d643fda0e..5146d3006b35ba 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap @@ -71,9 +71,9 @@ Module( | 1 | call(**x := 1) - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax | 1 | call(**x := 1) - | ^ Syntax Error: Positional argument cannot follow keyword argument unpacking + | ^ Syntax Error: positional argument follows keyword argument unpacking diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap index 8171e5fb5f0c17..936a5d05e97fcd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap @@ -63,4 +63,4 @@ Module( | 1 | # The comma between the first two elements is expected in `parse_list_expression`. 2 | [0, 1 2] - | ^ Syntax Error: Expected `,`, found int + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_element_between_commas.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_element_between_commas.py.snap index e7a6d1ee0a86af..900e1241d3db73 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_element_between_commas.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_element_between_commas.py.snap @@ -62,4 +62,4 @@ Module( | 1 | [0, 1, , 2] - | ^ Syntax Error: Expected an expression or a ']' + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_first_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_first_element.py.snap index a3b6e67d189ef8..fc41c123e0d1a0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_first_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_first_element.py.snap @@ -57,4 +57,4 @@ Module( | 1 | call(= 1) - | ^ Syntax Error: Expected an expression or a ')' + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_for_after_async.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_for_after_async.py.snap index 8e619d2219e0a0..d67e380eb70e27 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_for_after_async.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_for_after_async.py.snap @@ -80,7 +80,7 @@ Module( | 1 | (async) - | ^^^^^ Syntax Error: Expected an identifier, but found a keyword `async` that cannot be used here + | ^^^^^ Syntax Error: invalid syntax 2 | (x async x in iter) | @@ -88,4 +88,4 @@ Module( | 1 | (async) 2 | (x async x in iter) - | ^ Syntax Error: Expected `for`, found identifier + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_await_expression_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_await_expression_py38.py.snap index 74504f1d8b22b8..da517b7787a5f1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_await_expression_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_await_expression_py38.py.snap @@ -114,6 +114,6 @@ Module( 1 | # parse_options: { "target-version": "3.8" } 2 | async def foo(): 3 | @await bar - | ^^^^^^^^^ Syntax Error: Cannot use `await` expression outside function call arguments in a decorator on Python 3.8 (syntax was added in Python 3.9) + | ^^^^^^^^^ Syntax Error: cannot use `await` expression outside function call arguments in a decorator on Python 3.8 (syntax was added in Python 3.9) 4 | def baz(): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_dict_literal_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_dict_literal_py38.py.snap index a9ef37e493b634..614706eeea0110 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_dict_literal_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_dict_literal_py38.py.snap @@ -99,6 +99,6 @@ Module( | 1 | # parse_options: { "target-version": "3.8" } 2 | @{3: 3} - | ^^^^^^ Syntax Error: Cannot use a dict literal outside function call arguments in a decorator on Python 3.8 (syntax was added in Python 3.9) + | ^^^^^^ Syntax Error: cannot use a dict literal outside function call arguments in a decorator on Python 3.8 (syntax was added in Python 3.9) 3 | def bar(): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_expression_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_expression_py38.py.snap index e76d1393a9b58f..d71c8124d76d4b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_expression_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_expression_py38.py.snap @@ -116,6 +116,6 @@ Module( | 1 | # parse_options: { "target-version": "3.8" } 2 | @buttons[0].clicked.connect - | ^^^^^^^^^^ Syntax Error: Cannot use subscript expression outside function call arguments in a decorator on Python 3.8 (syntax was added in Python 3.9) + | ^^^^^^^^^^ Syntax Error: cannot use subscript expression outside function call arguments in a decorator on Python 3.8 (syntax was added in Python 3.9) 3 | def spam(): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_float_literal_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_float_literal_py38.py.snap index d58e143d03a041..4cfd421d7a9cd2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_float_literal_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_float_literal_py38.py.snap @@ -77,6 +77,6 @@ Module( | 1 | # parse_options: { "target-version": "3.8" } 2 | @3.14 - | ^^^^ Syntax Error: Cannot use a float literal outside function call arguments in a decorator on Python 3.8 (syntax was added in Python 3.9) + | ^^^^ Syntax Error: cannot use a float literal outside function call arguments in a decorator on Python 3.8 (syntax was added in Python 3.9) 3 | def bar(): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap index e1ba4a8db24071..bcafc4596c3bec 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap @@ -158,7 +158,7 @@ Module( | 1 | @*x - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | @(*x) 3 | @((*x)) | @@ -167,7 +167,7 @@ Module( | 1 | @*x 2 | @(*x) - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 3 | @((*x)) 4 | @yield x | @@ -177,7 +177,7 @@ Module( 1 | @*x 2 | @(*x) 3 | @((*x)) - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 4 | @yield x 5 | @yield from x | @@ -187,7 +187,7 @@ Module( 2 | @(*x) 3 | @((*x)) 4 | @yield x - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 5 | @yield from x 6 | def foo(): ... | @@ -197,6 +197,6 @@ Module( 3 | @((*x)) 4 | @yield x 5 | @yield from x - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 6 | def foo(): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_expression.py.snap index 61580d9ae4f7eb..e045c1827d481f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_expression.py.snap @@ -244,7 +244,7 @@ Module( | 1 | @def foo(): ... - | ^^^ Syntax Error: Expected an identifier + | ^^^ Syntax Error: invalid syntax 2 | @ 3 | def foo(): ... | @@ -253,7 +253,7 @@ Module( | 1 | @def foo(): ... 2 | @ - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | def foo(): ... 4 | @@ 5 | def foo(): ... @@ -264,7 +264,7 @@ Module( 2 | @ 3 | def foo(): ... 4 | @@ - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 5 | def foo(): ... 6 | @test | @@ -274,7 +274,7 @@ Module( 2 | @ 3 | def foo(): ... 4 | @@ - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 5 | def foo(): ... 6 | @test 7 | @ @@ -285,7 +285,7 @@ Module( 5 | def foo(): ... 6 | @test 7 | @ - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 8 | class Test | @@ -294,4 +294,4 @@ Module( 6 | @test 7 | @ 8 | class Test - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_newline.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_newline.py.snap index 5d38b5aa91d778..62a35ce4d9965c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_newline.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_missing_newline.py.snap @@ -174,7 +174,7 @@ Module( | 1 | @x def foo(): ... - | ^^^ Syntax Error: Expected newline, found `def` + | ^^^ Syntax Error: invalid syntax 2 | @x async def foo(): ... 3 | @x class Foo: ... | @@ -183,7 +183,7 @@ Module( | 1 | @x def foo(): ... 2 | @x async def foo(): ... - | ^^^^^ Syntax Error: Expected newline, found `async` + | ^^^^^ Syntax Error: invalid syntax 3 | @x class Foo: ... | @@ -192,4 +192,4 @@ Module( 1 | @x def foo(): ... 2 | @x async def foo(): ... 3 | @x class Foo: ... - | ^^^^^ Syntax Error: Expected newline, found `class` + | ^^^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_named_expression_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_named_expression_py37.py.snap index 978e905a0feeb9..c0f391cdacac23 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_named_expression_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_named_expression_py37.py.snap @@ -149,7 +149,7 @@ Module( | 1 | # parse_options: { "target-version": "3.7" } 2 | @(x := lambda x: x)(foo) - | ^^^^^^^^^^^^^^^^ Syntax Error: Cannot use named assignment expression (`:=`) on Python 3.7 (syntax was added in Python 3.8) + | ^^^^^^^^^^^^^^^^ Syntax Error: cannot use named assignment expression (`:=`) on Python 3.7 (syntax was added in Python 3.8) 3 | def bar(): ... | @@ -157,6 +157,6 @@ Module( | 1 | # parse_options: { "target-version": "3.7" } 2 | @(x := lambda x: x)(foo) - | ^^^^^^^^^^^^^^^^ Syntax Error: Cannot use assignment expression outside function call arguments in a decorator on Python 3.7 (syntax was added in Python 3.9) + | ^^^^^^^^^^^^^^^^ Syntax Error: cannot use assignment expression outside function call arguments in a decorator on Python 3.7 (syntax was added in Python 3.9) 3 | def bar(): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_non_toplevel_call_expression_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_non_toplevel_call_expression_py38.py.snap index 2facf25cdd5855..6afa982dbc9302 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_non_toplevel_call_expression_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_non_toplevel_call_expression_py38.py.snap @@ -116,6 +116,6 @@ Module( | 1 | # parse_options: { "target-version": "3.8" } 2 | @foo().bar() - | ^^^^^ Syntax Error: Cannot use a call expression in a decorator on Python 3.8 unless it is the top-level expression or it occurs in the argument list of a top-level call expression (relaxed decorator syntax was added in Python 3.9) + | ^^^^^ Syntax Error: cannot use a call expression in a decorator on Python 3.8 unless it is the top-level expression or it occurs in the argument list of a top-level call expression (relaxed decorator syntax was added in Python 3.9) 3 | def baz(): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_unexpected_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_unexpected_token.py.snap index 4ad6b22b50c68e..d3f54691c7ceb7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_unexpected_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_unexpected_token.py.snap @@ -173,7 +173,7 @@ Module( | 1 | @foo 2 | async with x: ... - | ^^^^^ Syntax Error: Expected class, function definition or async function definition after decorator + | ^^^^^ Syntax Error: expected class, function definition or async function definition after decorator 3 | @foo 4 | x = 1 | @@ -183,4 +183,4 @@ Module( 2 | async with x: ... 3 | @foo 4 | x = 1 - | ^ Syntax Error: Expected class, function definition or async function definition after decorator + | ^ Syntax Error: expected class, function definition or async function definition after decorator diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap index c0b2b380aa5553..7ce171d0bf2ec2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap @@ -129,7 +129,7 @@ Module( | 1 | del x, y. - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax 2 | z 3 | del x, y[ 4 | z diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_stmt_empty.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_stmt_empty.py.snap index cc7e8d9b49945c..95ce641c57d6a5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_stmt_empty.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_stmt_empty.py.snap @@ -27,4 +27,4 @@ Module( | 1 | del - | ^ Syntax Error: Delete statement must have at least one target + | ^ Syntax Error: delete statement must have at least one target diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dotted_name_multiple_dots.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dotted_name_multiple_dots.py.snap index fec5589f5aa9a4..a1ef5d11ba9f5c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dotted_name_multiple_dots.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dotted_name_multiple_dots.py.snap @@ -83,7 +83,7 @@ Module( | 1 | import a..b - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax 2 | import a...b | @@ -91,10 +91,10 @@ Module( | 1 | import a..b 2 | import a...b - | ^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^ Syntax Error: invalid syntax | 1 | import a..b 2 | import a...b - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_star_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_star_py310.py.snap index f3d98a565eefb6..47b7d9dd810772 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_star_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_star_py310.py.snap @@ -146,7 +146,7 @@ Module( 1 | # parse_options: {"target-version": "3.10"} 2 | try: ... 3 | except* ValueError: ... - | ^ Syntax Error: Cannot use `except*` on Python 3.10 (syntax was added in Python 3.11) + | ^ Syntax Error: cannot use `except*` on Python 3.10 (syntax was added in Python 3.11) 4 | except* KeyError: ... 5 | except * Error: ... | @@ -156,7 +156,7 @@ Module( 2 | try: ... 3 | except* ValueError: ... 4 | except* KeyError: ... - | ^ Syntax Error: Cannot use `except*` on Python 3.10 (syntax was added in Python 3.11) + | ^ Syntax Error: cannot use `except*` on Python 3.10 (syntax was added in Python 3.11) 5 | except * Error: ... | @@ -165,4 +165,4 @@ Module( 3 | except* ValueError: ... 4 | except* KeyError: ... 5 | except * Error: ... - | ^ Syntax Error: Cannot use `except*` on Python 3.10 (syntax was added in Python 3.11) + | ^ Syntax Error: cannot use `except*` on Python 3.10 (syntax was added in Python 3.11) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap index a6bfe57bb47eef..fb9829ff918766 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap @@ -134,7 +134,7 @@ Module( 1 | try: 2 | pass 3 | except yield x: - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 4 | pass 5 | try: | @@ -144,6 +144,6 @@ Module( 5 | try: 6 | pass 7 | except* *x: - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 8 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_as_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_as_name.py.snap index 8b7ce868b76f2f..1fcc50f1d07f13 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_as_name.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_as_name.py.snap @@ -96,7 +96,7 @@ Module( 1 | try: 2 | pass 3 | except Exception as: - | ^ Syntax Error: Expected name after `as` + | ^ Syntax Error: expected name after `as` 4 | pass 5 | except Exception as | @@ -106,6 +106,6 @@ Module( 3 | except Exception as: 4 | pass 5 | except Exception as - | ^ Syntax Error: Expected name after `as` + | ^ Syntax Error: expected name after `as` 6 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception.py.snap index 21f7b322ed3bbe..921d456a7e98bc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception.py.snap @@ -147,7 +147,7 @@ Module( 1 | try: 2 | pass 3 | except as exc: - | ^^ Syntax Error: Expected one or more exception types + | ^^ Syntax Error: expected one or more exception types 4 | pass 5 | # If a '*' is present then exception type is required | @@ -157,7 +157,7 @@ Module( 6 | try: 7 | pass 8 | except*: - | ^ Syntax Error: Expected one or more exception types + | ^ Syntax Error: expected one or more exception types 9 | pass 10 | except* | @@ -167,7 +167,7 @@ Module( 8 | except*: 9 | pass 10 | except* - | ^ Syntax Error: Expected one or more exception types + | ^ Syntax Error: expected one or more exception types 11 | pass 12 | except* as exc: 13 | pass @@ -178,6 +178,6 @@ Module( 10 | except* 11 | pass 12 | except* as exc: - | ^^ Syntax Error: Expected one or more exception types + | ^^ Syntax Error: expected one or more exception types 13 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception_and_as_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception_and_as_name.py.snap index 2d54c4846f2364..56a3dbd002ff2d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception_and_as_name.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_missing_exception_and_as_name.py.snap @@ -61,7 +61,7 @@ Module( 1 | try: 2 | pass 3 | except as: - | ^^ Syntax Error: Expected one or more exception types + | ^^ Syntax Error: expected one or more exception types 4 | pass | @@ -70,6 +70,6 @@ Module( 1 | try: 2 | pass 3 | except as: - | ^ Syntax Error: Expected name after `as` + | ^ Syntax Error: expected name after `as` 4 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap index f8eb819ba1af2c..b6d2d5fcd72d17 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as.py.snap @@ -169,7 +169,7 @@ Module( 1 | try: 2 | pass 3 | except x, y as exc: - | ^^^^^^^^^^^ Syntax Error: Multiple exception types must be parenthesized when using `as` + | ^^^^^^^^^^^ Syntax Error: multiple exception types must be parenthesized when using 'as' 4 | pass 5 | try: | @@ -179,6 +179,6 @@ Module( 5 | try: 6 | pass 7 | except* x, y as eg: - | ^^^^^^^^^^ Syntax Error: Multiple exception types must be parenthesized when using `as` + | ^^^^^^^^^^ Syntax Error: multiple exception types must be parenthesized when using 'as' 8 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap index 35649f8dac59dd..188fbda1d97336 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap @@ -188,7 +188,7 @@ Module( 1 | try: 2 | pass 3 | except x, y as (exc): - | ^ Syntax Error: Expected name after `as` + | ^ Syntax Error: expected name after `as` 4 | pass 5 | try: | @@ -198,7 +198,7 @@ Module( 1 | try: 2 | pass 3 | except x, y as (exc): - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | pass 5 | try: 6 | pass @@ -209,7 +209,7 @@ Module( 2 | pass 3 | except x, y as (exc): 4 | pass - | ^^^^ Syntax Error: Unexpected indentation + | ^^^^ Syntax Error: unexpected indentation 5 | try: 6 | pass | @@ -219,6 +219,6 @@ Module( 5 | try: 6 | pass 7 | except x, y as exc - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 8 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_no_as_py313.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_no_as_py313.py.snap index 27b43a43eb2ffd..1865ab08d1d307 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_no_as_py313.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_no_as_py313.py.snap @@ -157,7 +157,7 @@ Module( 2 | try: 3 | pass 4 | except x, y: - | ^^^^ Syntax Error: Multiple exception types must be parenthesized on Python 3.13 (syntax was added in Python 3.14) + | ^^^^ Syntax Error: multiple exception types must be parenthesized on Python 3.13 (syntax was added in Python 3.14) 5 | pass 6 | try: | @@ -167,6 +167,6 @@ Module( 6 | try: 7 | pass 8 | except* x, y: - | ^^^^ Syntax Error: Multiple exception types must be parenthesized on Python 3.13 (syntax was added in Python 3.14) + | ^^^^ Syntax Error: multiple exception types must be parenthesized on Python 3.13 (syntax was added in Python 3.14) 9 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap index d6cfc32f6184b4..c94716bb7bb19d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap @@ -219,7 +219,7 @@ Module( | 1 | call(**yield x) - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 2 | call(** *x) 3 | call(***x) | @@ -228,7 +228,7 @@ Module( | 1 | call(**yield x) 2 | call(** *x) - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 3 | call(***x) | @@ -237,7 +237,7 @@ Module( 1 | call(**yield x) 2 | call(** *x) 3 | call(***x) - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 4 | 5 | call(**x := 1) | @@ -247,11 +247,11 @@ Module( 3 | call(***x) 4 | 5 | call(**x := 1) - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax | 3 | call(***x) 4 | 5 | call(**x := 1) - | ^ Syntax Error: Positional argument cannot follow keyword argument unpacking + | ^ Syntax Error: positional argument follows keyword argument unpacking diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap index dac3238ebb7669..8c53336af733ba 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap @@ -205,7 +205,7 @@ Module( | 1 | call(x + y = 1) - | ^^^^^ Syntax Error: Expected a parameter name + | ^^^^^ Syntax Error: expected a parameter name 2 | call(x := 1 = 1) | @@ -213,7 +213,7 @@ Module( | 1 | call(x + y = 1) 2 | call(x := 1 = 1) - | ^^^^^^ Syntax Error: Expected a parameter name + | ^^^^^^ Syntax Error: expected a parameter name 3 | 4 | call(yield x) | @@ -223,7 +223,7 @@ Module( 2 | call(x := 1 = 1) 3 | 4 | call(yield x) - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 5 | call(yield from x) | @@ -231,4 +231,4 @@ Module( | 4 | call(yield x) 5 | call(yield from x) - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap index 28f4690d345188..04b42f4517d8fc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap @@ -239,7 +239,7 @@ Module( | 1 | call(x = yield y) - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 2 | call(x = yield from y) 3 | call(x = *y) | @@ -248,7 +248,7 @@ Module( | 1 | call(x = yield y) 2 | call(x = yield from y) - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 3 | call(x = *y) 4 | call(x = (*y)) | @@ -258,7 +258,7 @@ Module( 1 | call(x = yield y) 2 | call(x = yield from y) 3 | call(x = *y) - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 4 | call(x = (*y)) | @@ -267,4 +267,4 @@ Module( 2 | call(x = yield from y) 3 | call(x = *y) 4 | call(x = (*y)) - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap index a669334924f7f7..e7b3dbec5f794a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap @@ -315,7 +315,7 @@ Module( | 1 | call(**kwargs, x) - | ^ Syntax Error: Positional argument cannot follow keyword argument unpacking + | ^ Syntax Error: positional argument follows keyword argument unpacking 2 | call(x=1, y) 3 | call(x=1, **kwargs, y) | @@ -324,7 +324,7 @@ Module( | 1 | call(**kwargs, x) 2 | call(x=1, y) - | ^ Syntax Error: Positional argument cannot follow keyword argument + | ^ Syntax Error: positional argument follows keyword argument 3 | call(x=1, **kwargs, y) 4 | call(**kwargs, *args) | @@ -334,7 +334,7 @@ Module( 1 | call(**kwargs, x) 2 | call(x=1, y) 3 | call(x=1, **kwargs, y) - | ^ Syntax Error: Positional argument cannot follow keyword argument unpacking + | ^ Syntax Error: positional argument follows keyword argument unpacking 4 | call(**kwargs, *args) 5 | call(**kwargs, (*args)) | @@ -344,7 +344,7 @@ Module( 2 | call(x=1, y) 3 | call(x=1, **kwargs, y) 4 | call(**kwargs, *args) - | ^^^^^ Syntax Error: Iterable argument unpacking cannot follow keyword argument unpacking + | ^^^^^ Syntax Error: iterable argument unpacking follows keyword argument unpacking 5 | call(**kwargs, (*args)) | @@ -353,4 +353,4 @@ Module( 3 | call(x=1, **kwargs, y) 4 | call(**kwargs, *args) 5 | call(**kwargs, (*args)) - | ^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_argument.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_argument.py.snap index 633e02742087bc..b43f1dee2a76e8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_argument.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_argument.py.snap @@ -64,4 +64,4 @@ Module( | 1 | call(x,,y) - | ^ Syntax Error: Expected an expression or a ')' + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap index fbd746dfb827ad..50b7e158734c67 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap @@ -64,4 +64,4 @@ Module( | 1 | call(x y) - | ^ Syntax Error: Expected `,`, found identifier + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap index e7f64870ed7d99..d4784379987aee 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap @@ -171,7 +171,7 @@ Module( | 1 | call( = 1) - | ^ Syntax Error: Expected an expression or a ')' + | ^ Syntax Error: invalid syntax 2 | call(x = ) 3 | call(*, y) | @@ -180,7 +180,7 @@ Module( | 1 | call( = 1) 2 | call(x = ) - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | call(*, y) | @@ -189,7 +189,7 @@ Module( 1 | call( = 1) 2 | call(x = ) 3 | call(*, y) - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | 5 | foo | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__starred.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__starred.py.snap index 81b1487c68f2e1..f368ac48eae261 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__starred.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__starred.py.snap @@ -199,7 +199,7 @@ Module( | 1 | call(*data for data in iter) 2 | call(*yield x) - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | call(*yield from x) | @@ -208,14 +208,14 @@ Module( 1 | call(*data for data in iter) 2 | call(*yield x) 3 | call(*yield from x) - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here ## Unsupported Syntax Errors | 1 | call(*data for data in iter) - | ^^^^^ Syntax Error: Cannot use iterable unpacking in a generator expression on Python 3.14 (syntax was added in Python 3.15) + | ^^^^^ Syntax Error: cannot use iterable unpacking in a generator expression on Python 3.14 (syntax was added in Python 3.15) 2 | call(*yield x) 3 | call(*yield from x) | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap index 6ae17dd5ae5423..e16c7dbe432f78 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap @@ -84,7 +84,7 @@ Module( | 1 | call( - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 2 | 3 | def foo(): 4 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap index 7e6c53e1fe1ff5..a3b2aebe77f48d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap @@ -93,7 +93,7 @@ Module( | 1 | call(x - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 2 | 3 | def foo(): 4 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap index 356e2a3f16223d..9f0a0a5fc37b1e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap @@ -93,7 +93,7 @@ Module( | 1 | call(x, - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 2 | 3 | def foo(): 4 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__invalid_member.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__invalid_member.py.snap index 3355b7300f7723..3e767d8d27be8d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__invalid_member.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__invalid_member.py.snap @@ -134,7 +134,7 @@ Module( | 1 | x.1 - | ^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^ Syntax Error: invalid syntax 2 | x.1.0 3 | x.[0] | @@ -143,7 +143,7 @@ Module( | 1 | x.1 2 | x.1.0 - | ^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^ Syntax Error: invalid syntax 3 | x.[0] | @@ -151,7 +151,7 @@ Module( | 1 | x.1 2 | x.1.0 - | ^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^ Syntax Error: invalid syntax 3 | x.[0] | @@ -160,4 +160,4 @@ Module( 1 | x.1 2 | x.1.0 3 | x.[0] - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__multiple_dots.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__multiple_dots.py.snap index 74451a7731c447..b732befe3455e6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__multiple_dots.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__multiple_dots.py.snap @@ -145,7 +145,7 @@ Module( | 1 | extra..dot - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax 2 | multiple....dots 3 | multiple.....dots | @@ -154,7 +154,7 @@ Module( | 1 | extra..dot 2 | multiple....dots - | ^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^ Syntax Error: invalid syntax 3 | multiple.....dots | @@ -163,11 +163,11 @@ Module( 1 | extra..dot 2 | multiple....dots 3 | multiple.....dots - | ^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^ Syntax Error: invalid syntax | 1 | extra..dot 2 | multiple....dots 3 | multiple.....dots - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap index 6c28085cdb8123..b5f295ab8f4ce4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__attribute__no_member.py.snap @@ -86,7 +86,7 @@ Module( | 1 | # The `second` is a variable on another line and not part of the attribute expression. 2 | first. - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax 3 | second 4 | 5 | # No member access after the dot. @@ -96,4 +96,4 @@ Module( | 5 | # No member access after the dot. 6 | last. - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap index c7a05ce70a601d..bb6f54aa1d0d02 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_0.py.snap @@ -69,7 +69,7 @@ Module( | 1 | # No expression after `await`, an expression on another line 2 | await - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | 4 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap index 7ff63f861dd3f4..a6af5f33c35ded 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__no_expression_1.py.snap @@ -77,7 +77,7 @@ Module( | 1 | # No expression after `await`, a statement on another line 2 | await - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | 4 | def foo(): 5 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap index 739751c4288f1d..2e64245210720f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap @@ -292,7 +292,7 @@ Module( | 4 | # Nested await 5 | await await x - | ^^^^^^^ Syntax Error: Await expression cannot be used here + | ^^^^^^^ Syntax Error: await expression cannot be used here 6 | 7 | # Starred expressions | @@ -301,7 +301,7 @@ Module( | 7 | # Starred expressions 8 | await *x - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 9 | await (*x) | @@ -310,7 +310,7 @@ Module( 7 | # Starred expressions 8 | await *x 9 | await (*x) - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 10 | 11 | # Invalid expression as per precedence | @@ -319,7 +319,7 @@ Module( | 11 | # Invalid expression as per precedence 12 | await yield x - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 13 | await lambda x: x 14 | await +x | @@ -329,7 +329,7 @@ Module( 11 | # Invalid expression as per precedence 12 | await yield x 13 | await lambda x: x - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 14 | await +x 15 | await -x | @@ -339,7 +339,7 @@ Module( 12 | await yield x 13 | await lambda x: x 14 | await +x - | ^^ Syntax Error: Unary '+' expression cannot be used here + | ^^ Syntax Error: unary '+' expression cannot be used here 15 | await -x 16 | await ~x | @@ -349,7 +349,7 @@ Module( 13 | await lambda x: x 14 | await +x 15 | await -x - | ^^ Syntax Error: Unary '-' expression cannot be used here + | ^^ Syntax Error: unary '-' expression cannot be used here 16 | await ~x 17 | await not x | @@ -359,7 +359,7 @@ Module( 14 | await +x 15 | await -x 16 | await ~x - | ^^ Syntax Error: Unary '~' expression cannot be used here + | ^^ Syntax Error: unary '~' expression cannot be used here 17 | await not x | @@ -368,4 +368,4 @@ Module( 15 | await -x 16 | await ~x 17 | await not x - | ^^^^^ Syntax Error: Boolean 'not' expression cannot be used here + | ^^^^^ Syntax Error: 'not' after an operator must be parenthesized diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap index 637ceb217ea14c..9a704c982199e7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__invalid_rhs_expression.py.snap @@ -121,7 +121,7 @@ Module( | 1 | x + lambda y: y - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 2 | 3 | x - yield y | @@ -131,4 +131,4 @@ Module( 1 | x + lambda y: y 2 | 3 | x - yield y - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap index 9840e01b6096dd..9ca23012a1e76b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_lhs.py.snap @@ -64,7 +64,7 @@ Module( | 1 | / y - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap index 036b4e805d4b49..e4bd365d3db27d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_0.py.snap @@ -80,7 +80,7 @@ Module( | 1 | 0 + - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap index 599a62211545ac..6330ae245bcaf2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__missing_rhs_1.py.snap @@ -112,7 +112,7 @@ Module( | 1 | 1 + 2 - 3 * - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 3 | 4 + 5 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__multiple_ops.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__multiple_ops.py.snap index a335ad0bf8a27a..6c13ed962f550d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__multiple_ops.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__multiple_ops.py.snap @@ -153,7 +153,7 @@ Module( | 1 | x++ - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 1 + 2 3 | x-- 4 | 1 - 2 @@ -164,6 +164,6 @@ Module( 1 | x++ 2 | 1 + 2 3 | x-- - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | 1 - 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap index 06988f7f14aaac..a9267d530552bd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap @@ -127,7 +127,7 @@ Module( | 1 | x - y := (1, 2) - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 2 | x / y := 2 | @@ -135,4 +135,4 @@ Module( | 1 | x - y := (1, 2) 2 | x / y := 2 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap index 27d711fd5585d7..b9cb398c61c83b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap @@ -91,7 +91,7 @@ Module( | 1 | x + *y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | x ** *y | @@ -99,4 +99,4 @@ Module( | 1 | x + *y 2 | x ** *y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap index 91f94d09f2607e..69f44e4a4b91f3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__invalid_rhs_expression.py.snap @@ -127,7 +127,7 @@ Module( | 1 | x and lambda y: y - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 2 | 3 | x or yield y | @@ -137,4 +137,4 @@ Module( 1 | x and lambda y: y 2 | 3 | x or yield y - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_lhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_lhs.py.snap index 56091fe1c53b32..04a82592aba760 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_lhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_lhs.py.snap @@ -33,4 +33,4 @@ Module( | 1 | and y - | ^^^ Syntax Error: Expected a statement + | ^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap index 20ee8ce3f03805..8c73b643024ae0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__missing_rhs.py.snap @@ -82,7 +82,7 @@ Module( | 1 | x and - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap index f3a6c5100d04f7..70142d071d599f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap @@ -111,7 +111,7 @@ Module( | 1 | x and a := b - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 2 | x or a := b | @@ -119,4 +119,4 @@ Module( | 1 | x and a := b 2 | x or a := b - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap index 569714154c834f..0d8597d695f99f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap @@ -97,7 +97,7 @@ Module( | 1 | x and *y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | x or *y | @@ -105,4 +105,4 @@ Module( | 1 | x and *y 2 | x or *y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap index bfa0ff5d66856d..088d61a57156e1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_order.py.snap @@ -156,7 +156,7 @@ Module( | 1 | x in not y - | ^^^^^ Syntax Error: Boolean 'not' expression cannot be used here + | ^^^^^ Syntax Error: 'not' after an operator must be parenthesized 2 | 3 | # `=>` instead of `>=` | @@ -165,7 +165,7 @@ Module( | 3 | # `=>` instead of `>=` 4 | x => y - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 5 | 6 | # Same here as well, `not` without `in` is considered to be a unary operator | @@ -174,16 +174,16 @@ Module( | 6 | # Same here as well, `not` without `in` is considered to be a unary operator 7 | x not is y - | ^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^ Syntax Error: invalid syntax | 6 | # Same here as well, `not` without `in` is considered to be a unary operator 7 | x not is y - | ^^ Syntax Error: Expected an identifier, but found a keyword `is` that cannot be used here + | ^^ Syntax Error: invalid syntax | 6 | # Same here as well, `not` without `in` is considered to be a unary operator 7 | x not is y - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap index b1fcf591dda47b..151bb1f3ee75c6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__invalid_rhs_expression.py.snap @@ -131,7 +131,7 @@ Module( | 1 | x not in lambda y: y - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 2 | 3 | x == yield y | @@ -141,4 +141,4 @@ Module( 1 | x not in lambda y: y 2 | 3 | x == yield y - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap index f58a622b75ba88..cf7c19aa790c8c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_lhs.py.snap @@ -64,7 +64,7 @@ Module( | 1 | > y - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap index ea26ff00ac040b..75209662f688d5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_0.py.snap @@ -84,7 +84,7 @@ Module( | 1 | x > - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap index 81f95ea93424e2..f0e1055a34f451 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_1.py.snap @@ -86,7 +86,7 @@ Module( | 1 | # Without the `in`, this is considered to be a unary `not` 2 | x not - | ^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^ Syntax Error: invalid syntax 3 | 4 | 1 + 2 | @@ -95,7 +95,7 @@ Module( | 1 | # Without the `in`, this is considered to be a unary `not` 2 | x not - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | 4 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap index a2c9f8ded5b950..7e621e0e1f17a7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__missing_rhs_2.py.snap @@ -84,7 +84,7 @@ Module( | 1 | x is not - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 3 | 1 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap index 9029679c6435b6..cd6f5595f919b7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap @@ -114,7 +114,7 @@ Module( | 1 | # This is not JavaScript 2 | x === y - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | x !== y | @@ -122,7 +122,7 @@ Module( | 1 | # This is not JavaScript 2 | x === y - | ^^^^ Syntax Error: Invalid assignment target + | ^^^^ Syntax Error: invalid assignment target 3 | x !== y | @@ -131,11 +131,11 @@ Module( 1 | # This is not JavaScript 2 | x === y 3 | x !== y - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax | 1 | # This is not JavaScript 2 | x === y 3 | x !== y - | ^^^^ Syntax Error: Invalid assignment target + | ^^^^ Syntax Error: invalid assignment target diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap index 4767fbba48bb52..4152869dc8446c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap @@ -137,7 +137,7 @@ Module( | 1 | x not in y := (1, 2) - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 2 | x > y := 2 | @@ -145,4 +145,4 @@ Module( | 1 | x not in y := (1, 2) 2 | x > y := 2 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap index d8572908ec31f9..3f820762c30a07 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap @@ -183,7 +183,7 @@ Module( | 1 | x >= *y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | x not in *y | @@ -191,7 +191,7 @@ Module( | 1 | x >= *y 2 | x not in *y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 3 | 4 | *x < y | @@ -201,7 +201,7 @@ Module( 2 | x not in *y 3 | 4 | *x < y - | ^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^ Syntax Error: comparison expression cannot be used here 5 | *x is not y | @@ -209,4 +209,4 @@ Module( | 4 | *x < y 5 | *x is not y - | ^^^^^^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^^^^^^ Syntax Error: comparison expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap index 8552da90cc2724..7b784d6d669f20 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap @@ -887,7 +887,7 @@ Module( | 1 | # Invalid target 2 | {x: y for 1 in y} - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target 3 | {x: y for 'a' in y} 4 | {x: y for call() in y} | @@ -897,7 +897,7 @@ Module( 1 | # Invalid target 2 | {x: y for 1 in y} 3 | {x: y for 'a' in y} - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target 4 | {x: y for call() in y} 5 | {x: y for {a, b} in y} | @@ -907,7 +907,7 @@ Module( 2 | {x: y for 1 in y} 3 | {x: y for 'a' in y} 4 | {x: y for call() in y} - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 5 | {x: y for {a, b} in y} | @@ -916,7 +916,7 @@ Module( 3 | {x: y for 'a' in y} 4 | {x: y for call() in y} 5 | {x: y for {a, b} in y} - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 6 | 7 | # Invalid iter | @@ -925,7 +925,7 @@ Module( | 7 | # Invalid iter 8 | {x: y for x in *y} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 9 | {x: y for x in yield y} 10 | {x: y for x in yield from y} | @@ -935,7 +935,7 @@ Module( 7 | # Invalid iter 8 | {x: y for x in *y} 9 | {x: y for x in yield y} - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 10 | {x: y for x in yield from y} 11 | {x: y for x in lambda y: y} | @@ -945,7 +945,7 @@ Module( 8 | {x: y for x in *y} 9 | {x: y for x in yield y} 10 | {x: y for x in yield from y} - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 11 | {x: y for x in lambda y: y} | @@ -954,7 +954,7 @@ Module( 9 | {x: y for x in yield y} 10 | {x: y for x in yield from y} 11 | {x: y for x in lambda y: y} - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 12 | 13 | # Invalid if | @@ -963,7 +963,7 @@ Module( | 13 | # Invalid if 14 | {x: y for x in data if *y} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 15 | {x: y for x in data if yield y} 16 | {x: y for x in data if yield from y} | @@ -973,7 +973,7 @@ Module( 13 | # Invalid if 14 | {x: y for x in data if *y} 15 | {x: y for x in data if yield y} - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 16 | {x: y for x in data if yield from y} 17 | {x: y for x in data if lambda y: y} | @@ -983,7 +983,7 @@ Module( 14 | {x: y for x in data if *y} 15 | {x: y for x in data if yield y} 16 | {x: y for x in data if yield from y} - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 17 | {x: y for x in data if lambda y: y} | @@ -992,4 +992,4 @@ Module( 15 | {x: y for x in data if yield y} 16 | {x: y for x in data if yield from y} 17 | {x: y for x in data if lambda y: y} - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap index 31a214169bb469..af79ff2c0105bc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap @@ -562,7 +562,7 @@ Module( 2 | # the ones which are higher than that. 3 | 4 | {**x := 1} - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax 5 | {a: 1, **x if True else y} 6 | {**lambda x: x, b: 2} | @@ -572,7 +572,7 @@ Module( 2 | # the ones which are higher than that. 3 | 4 | {**x := 1} - | ^ Syntax Error: Expected `:`, found `}` + | ^ Syntax Error: invalid syntax 5 | {a: 1, **x if True else y} 6 | {**lambda x: x, b: 2} | @@ -581,7 +581,7 @@ Module( | 4 | {**x := 1} 5 | {a: 1, **x if True else y} - | ^^^^^^^^^^^^^^^^ Syntax Error: Conditional expression cannot be used here + | ^^^^^^^^^^^^^^^^ Syntax Error: conditional expression cannot be used here 6 | {**lambda x: x, b: 2} 7 | {a: 1, **x or y} | @@ -591,7 +591,7 @@ Module( 4 | {**x := 1} 5 | {a: 1, **x if True else y} 6 | {**lambda x: x, b: 2} - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 7 | {a: 1, **x or y} 8 | {**x and y, b: 2} | @@ -601,7 +601,7 @@ Module( 5 | {a: 1, **x if True else y} 6 | {**lambda x: x, b: 2} 7 | {a: 1, **x or y} - | ^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^ Syntax Error: boolean expression cannot be used here 8 | {**x and y, b: 2} 9 | {a: 1, **not x, b: 2} | @@ -611,7 +611,7 @@ Module( 6 | {**lambda x: x, b: 2} 7 | {a: 1, **x or y} 8 | {**x and y, b: 2} - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 9 | {a: 1, **not x, b: 2} 10 | {**x in y} | @@ -621,7 +621,7 @@ Module( 7 | {a: 1, **x or y} 8 | {**x and y, b: 2} 9 | {a: 1, **not x, b: 2} - | ^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^ Syntax Error: boolean expression cannot be used here 10 | {**x in y} 11 | {**x not in y} | @@ -631,7 +631,7 @@ Module( 8 | {**x and y, b: 2} 9 | {a: 1, **not x, b: 2} 10 | {**x in y} - | ^^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^^ Syntax Error: comparison expression cannot be used here 11 | {**x not in y} 12 | {**x < y} | @@ -641,7 +641,7 @@ Module( 9 | {a: 1, **not x, b: 2} 10 | {**x in y} 11 | {**x not in y} - | ^^^^^^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^^^^^^ Syntax Error: comparison expression cannot be used here 12 | {**x < y} | @@ -650,4 +650,4 @@ Module( 10 | {**x in y} 11 | {**x not in y} 12 | {**x < y} - | ^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^ Syntax Error: comparison expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap index 00fb1cccf5edec..8b78c5d41828ab 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap @@ -96,7 +96,7 @@ Module( 2 | # it's actually a comprehension. 3 | 4 | {**x: y for x, y in data} - | ^^^ Syntax Error: Starred expression cannot be used here + | ^^^ Syntax Error: invalid syntax 5 | 6 | # TODO(dhruvmanila): This test case fails because there's no way to represent `**y` | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap index a9a551bb24b318..ac36a64deb9efa 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap @@ -90,7 +90,7 @@ Module( 1 | {x: 2 | 3 | def foo(): - | ^^^ Syntax Error: Expected an identifier, but found a keyword `def` that cannot be used here + | ^^^ Syntax Error: invalid syntax 4 | pass | @@ -99,7 +99,7 @@ Module( 1 | {x: 2 | 3 | def foo(): - | ^^^ Syntax Error: Expected `,`, found identifier + | ^^^ Syntax Error: invalid syntax 4 | pass | @@ -107,7 +107,7 @@ Module( | 3 | def foo(): 4 | pass - | ^^^^ Syntax Error: Expected an identifier, but found a keyword `pass` that cannot be used here + | ^^^^ Syntax Error: invalid syntax | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap index 7db2a6203d51e0..1ba383b08598df 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap @@ -92,7 +92,7 @@ Module( | 1 | {x: 1, - | ^ Syntax Error: Expected `}`, found newline + | ^ Syntax Error: invalid syntax 2 | 3 | def foo(): 4 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap index bbae05b830d894..beb0558afddcfb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap @@ -141,7 +141,7 @@ Module( 1 | # Unparenthesized named expression not allowed in key 2 | 3 | {x := 1: y, z := 2: a} - | ^^^^^^ Syntax Error: Unparenthesized named expression cannot be used here + | ^^^^^^ Syntax Error: unparenthesized named expression cannot be used here 4 | 5 | x + y | @@ -151,7 +151,7 @@ Module( 1 | # Unparenthesized named expression not allowed in key 2 | 3 | {x := 1: y, z := 2: a} - | ^^ Syntax Error: Expected `:`, found `:=` + | ^^ Syntax Error: invalid syntax 4 | 5 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap index b30ab101a6126c..cfe52f2a965bd2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap @@ -147,7 +147,7 @@ Module( 1 | # Unparenthesized named expression not allowed in value 2 | 3 | {x: y := 1, z: a := 2} - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax 4 | 5 | x + y | @@ -157,7 +157,7 @@ Module( 1 | # Unparenthesized named expression not allowed in value 2 | 3 | {x: y := 1, z: a := 2} - | ^ Syntax Error: Expected `:`, found `,` + | ^ Syntax Error: invalid syntax 4 | 5 | x + y | @@ -167,7 +167,7 @@ Module( 1 | # Unparenthesized named expression not allowed in value 2 | 3 | {x: y := 1, z: a := 2} - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax 4 | 5 | x + y | @@ -177,7 +177,7 @@ Module( 1 | # Unparenthesized named expression not allowed in value 2 | 3 | {x: y := 1, z: a := 2} - | ^ Syntax Error: Expected `:`, found `}` + | ^ Syntax Error: invalid syntax 4 | 5 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap index 09d87681a1ba6a..7fce88bdb76a59 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap @@ -485,7 +485,7 @@ Module( 1 | # Test cases for dictionary expressions where the parser recovers from a syntax error. 2 | 3 | {,} - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | 5 | {1: 2,,3: 4} | @@ -495,7 +495,7 @@ Module( 3 | {,} 4 | 5 | {1: 2,,3: 4} - | ^ Syntax Error: Expected an expression or a '}' + | ^ Syntax Error: invalid syntax 6 | 7 | {1: 2,,} | @@ -505,7 +505,7 @@ Module( 5 | {1: 2,,3: 4} 6 | 7 | {1: 2,,} - | ^ Syntax Error: Expected an expression or a '}' + | ^ Syntax Error: invalid syntax 8 | 9 | # Missing comma | @@ -514,7 +514,7 @@ Module( | 9 | # Missing comma 10 | {1: 2 3: 4} - | ^ Syntax Error: Expected `,`, found int + | ^ Syntax Error: invalid syntax 11 | 12 | # No value | @@ -523,7 +523,7 @@ Module( | 12 | # No value 13 | {1: } - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 14 | 15 | # No value for double star unpacking | @@ -532,7 +532,7 @@ Module( | 15 | # No value for double star unpacking 16 | {**} - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 17 | {x: y, **, a: b} | @@ -541,7 +541,7 @@ Module( 15 | # No value for double star unpacking 16 | {**} 17 | {x: y, **, a: b} - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 18 | 19 | # This is not a double star unpacking | @@ -550,7 +550,7 @@ Module( | 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 24 | {x: *y, z: *a} | @@ -558,7 +558,7 @@ Module( | 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 24 | {x: *y, z: *a} | @@ -567,11 +567,11 @@ Module( 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} 24 | {x: *y, z: *a} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax | 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} 24 | {x: *y, z: *a} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap index 4c5393effbee69..df8919487a4eb0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap @@ -94,7 +94,7 @@ Module( | 1 | a = (🐶 - | ^^ Syntax Error: Got unexpected token 🐶 + | ^^ Syntax Error: invalid syntax 2 | # comment 🐶 3 | ) | @@ -104,7 +104,7 @@ Module( 1 | a = (🐶 2 | # comment 🐶 3 | ) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 4 | 5 | a = (🐶 + | @@ -114,7 +114,7 @@ Module( 1 | a = (🐶 2 | # comment 🐶 3 | ) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 4 | 5 | a = (🐶 + 6 | # comment @@ -125,7 +125,7 @@ Module( 3 | ) 4 | 5 | a = (🐶 + - | ^^ Syntax Error: Got unexpected token 🐶 + | ^^ Syntax Error: invalid syntax 6 | # comment 7 | 🐶) | @@ -135,18 +135,18 @@ Module( 5 | a = (🐶 + 6 | # comment 7 | 🐶) - | ^^ Syntax Error: Got unexpected token 🐶 + | ^^ Syntax Error: invalid syntax | 5 | a = (🐶 + 6 | # comment 7 | 🐶) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax | 5 | a = (🐶 + 6 | # comment 7 | 🐶) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap index b798ab9885a8c6..1ce96dca91ee41 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap @@ -18,4 +18,4 @@ Module( | 1 | 👍 - | ^^ Syntax Error: Got unexpected token 👍 + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap index ab55b69092d41c..3e2d753e67f93b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap @@ -93,7 +93,7 @@ Module( | 1 | # Missing orelse expression, followed by a statement 2 | x if expr else - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | 4 | def foo(): 5 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap index 8262008c39f050..367c97b5b28385 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap @@ -87,7 +87,7 @@ Module( | 1 | # Missing orelse expression, followed by an expression 2 | x if expr else - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | 4 | 1 + 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap index eed6f0fba20579..b85fc280d84820 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_0.py.snap @@ -93,7 +93,7 @@ Module( | 1 | # Missing test expression, followed by a statement 2 | x if - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | 4 | def foo(): 5 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap index da6fdb72a6ddb0..c3fdb8ad8640ab 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_test_expr_1.py.snap @@ -87,7 +87,7 @@ Module( | 1 | # Missing test expression, followed by an expression 2 | x if - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | 4 | 1 + 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap index 084c2168e6a8cb..ed79e9aee5d3c6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap @@ -350,7 +350,7 @@ Module( | 1 | # Invalid test expression 2 | x if *expr else y - | ^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^ Syntax Error: invalid syntax 3 | x if lambda x: x else y 4 | x if yield x else y | @@ -360,7 +360,7 @@ Module( 1 | # Invalid test expression 2 | x if *expr else y 3 | x if lambda x: x else y - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 4 | x if yield x else y 5 | x if yield from x else y | @@ -370,7 +370,7 @@ Module( 2 | x if *expr else y 3 | x if lambda x: x else y 4 | x if yield x else y - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 5 | x if yield from x else y | @@ -379,7 +379,7 @@ Module( 3 | x if lambda x: x else y 4 | x if yield x else y 5 | x if yield from x else y - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 6 | 7 | # Invalid orelse expression | @@ -388,7 +388,7 @@ Module( | 7 | # Invalid orelse expression 8 | x if expr else *orelse - | ^^^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^^^ Syntax Error: invalid syntax 9 | x if expr else yield y 10 | x if expr else yield from y | @@ -398,7 +398,7 @@ Module( 7 | # Invalid orelse expression 8 | x if expr else *orelse 9 | x if expr else yield y - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 10 | x if expr else yield from y | @@ -407,4 +407,4 @@ Module( 8 | x if expr else *orelse 9 | x if expr else yield y 10 | x if expr else yield from y - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_default_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_default_parameters.py.snap index be2996d8ace0ca..b4e16e45f7148a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_default_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_default_parameters.py.snap @@ -114,4 +114,4 @@ Module( | 1 | lambda a, b=20, c: 1 - | ^ Syntax Error: Parameter without a default cannot follow a parameter with a default + | ^ Syntax Error: parameter without a default follows parameter with a default diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap index f44abf6dff0d40..6a43d14bf84a22 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap @@ -364,7 +364,7 @@ Module( 7 | lambda a, *a: 1 8 | 9 | lambda a, *, **a: 1 - | ^^^ Syntax Error: Expected one or more keyword parameter after `*` separator + | ^^^ Syntax Error: named arguments must follow bare * ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap index 53f578e796f934..4bcc73eb1d390e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap @@ -1146,7 +1146,7 @@ Module( | 1 | # Invalid target 2 | [x for 1 in y] - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target 3 | [x for 'a' in y] 4 | [x for call() in y] | @@ -1156,7 +1156,7 @@ Module( 1 | # Invalid target 2 | [x for 1 in y] 3 | [x for 'a' in y] - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target 4 | [x for call() in y] 5 | [x for {a, b} in y] | @@ -1166,7 +1166,7 @@ Module( 2 | [x for 1 in y] 3 | [x for 'a' in y] 4 | [x for call() in y] - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 5 | [x for {a, b} in y] | @@ -1175,7 +1175,7 @@ Module( 3 | [x for 'a' in y] 4 | [x for call() in y] 5 | [x for {a, b} in y] - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 6 | 7 | # Invalid iter | @@ -1184,7 +1184,7 @@ Module( | 7 | # Invalid iter 8 | [x for x in *y] - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 9 | [x for x in yield y] 10 | [x for x in yield from y] | @@ -1194,7 +1194,7 @@ Module( 7 | # Invalid iter 8 | [x for x in *y] 9 | [x for x in yield y] - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 10 | [x for x in yield from y] 11 | [x for x in lambda y: y] | @@ -1204,7 +1204,7 @@ Module( 8 | [x for x in *y] 9 | [x for x in yield y] 10 | [x for x in yield from y] - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 11 | [x for x in lambda y: y] 12 | [**x for x in [{1: 2}]] | @@ -1214,7 +1214,7 @@ Module( 9 | [x for x in yield y] 10 | [x for x in yield from y] 11 | [x for x in lambda y: y] - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] | @@ -1224,7 +1224,7 @@ Module( 10 | [x for x in yield from y] 11 | [x for x in lambda y: y] 12 | [**x for x in [{1: 2}]] - | ^^ Syntax Error: Expected an expression + | ^^ Syntax Error: invalid syntax 13 | [*x, for x in y] 14 | [*x, *y for x in y] | @@ -1234,7 +1234,7 @@ Module( 11 | [x for x in lambda y: y] 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] - | ^^^ Syntax Error: Expected `]`, found `for` + | ^^^ Syntax Error: invalid syntax 14 | [*x, *y for x in y] | @@ -1243,7 +1243,7 @@ Module( 11 | [x for x in lambda y: y] 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] - | ^ Syntax Error: Expected `:`, found `]` + | ^ Syntax Error: invalid syntax 14 | [*x, *y for x in y] | @@ -1252,7 +1252,7 @@ Module( 11 | [x for x in lambda y: y] 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 14 | [*x, *y for x in y] 15 | 16 | # Invalid if @@ -1263,7 +1263,7 @@ Module( 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] 14 | [*x, *y for x in y] - | ^^^ Syntax Error: Expected `]`, found `for` + | ^^^ Syntax Error: invalid syntax 15 | 16 | # Invalid if | @@ -1273,7 +1273,7 @@ Module( 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] 14 | [*x, *y for x in y] - | ^ Syntax Error: Expected `:`, found `]` + | ^ Syntax Error: invalid syntax 15 | 16 | # Invalid if | @@ -1283,7 +1283,7 @@ Module( 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] 14 | [*x, *y for x in y] - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 15 | 16 | # Invalid if 17 | [x for x in data if *y] @@ -1293,7 +1293,7 @@ Module( | 16 | # Invalid if 17 | [x for x in data if *y] - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 18 | [x for x in data if yield y] 19 | [x for x in data if yield from y] | @@ -1303,7 +1303,7 @@ Module( 16 | # Invalid if 17 | [x for x in data if *y] 18 | [x for x in data if yield y] - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 19 | [x for x in data if yield from y] 20 | [x for x in data if lambda y: y] | @@ -1313,7 +1313,7 @@ Module( 17 | [x for x in data if *y] 18 | [x for x in data if yield y] 19 | [x for x in data if yield from y] - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 20 | [x for x in data if lambda y: y] 21 | [*x if x else y for x in z] | @@ -1323,7 +1323,7 @@ Module( 18 | [x for x in data if yield y] 19 | [x for x in data if yield from y] 20 | [x for x in data if lambda y: y] - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 21 | [*x if x else y for x in z] 22 | [x if x else *y for x in z] | @@ -1333,7 +1333,7 @@ Module( 19 | [x for x in data if yield from y] 20 | [x for x in data if lambda y: y] 21 | [*x if x else y for x in z] - | ^^^^^^^^^^^^^ Syntax Error: Conditional expression cannot be used here + | ^^^^^^^^^^^^^ Syntax Error: conditional expression cannot be used here 22 | [x if x else *y for x in z] | @@ -1342,7 +1342,7 @@ Module( 20 | [x for x in data if lambda y: y] 21 | [*x if x else y for x in z] 22 | [x if x else *y for x in z] - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax ## Unsupported Syntax Errors @@ -1351,6 +1351,6 @@ Module( 19 | [x for x in data if yield from y] 20 | [x for x in data if lambda y: y] 21 | [*x if x else y for x in z] - | ^^^^^^^^^^^^^^ Syntax Error: Cannot use iterable unpacking in a list comprehension on Python 3.14 (syntax was added in Python 3.15) + | ^^^^^^^^^^^^^^ Syntax Error: cannot use iterable unpacking in a list comprehension on Python 3.14 (syntax was added in Python 3.15) 22 | [x if x else *y for x in z] | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap index 0ed2e8acf52595..be24e50b936ec5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap @@ -92,7 +92,7 @@ Module( 2 | # token starts a statement. 3 | 4 | [1, 2 - | ^ Syntax Error: Expected `]`, found newline + | ^ Syntax Error: invalid syntax 5 | 6 | def foo(): 7 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap index 574fa9d8e117a4..1a303bc6724fc8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap @@ -285,7 +285,7 @@ Module( 1 | # Test cases for list expressions where the parser recovers from a syntax error. 2 | 3 | [,] - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | 5 | [1,,2] | @@ -295,7 +295,7 @@ Module( 3 | [,] 4 | 5 | [1,,2] - | ^ Syntax Error: Expected an expression or a ']' + | ^ Syntax Error: invalid syntax 6 | 7 | [1,,] | @@ -305,7 +305,7 @@ Module( 5 | [1,,2] 6 | 7 | [1,,] - | ^ Syntax Error: Expected an expression or a ']' + | ^ Syntax Error: invalid syntax 8 | 9 | # Missing comma | @@ -314,7 +314,7 @@ Module( | 9 | # Missing comma 10 | [1 2] - | ^ Syntax Error: Expected `,`, found int + | ^ Syntax Error: invalid syntax 11 | 12 | # Dictionary element in a list | @@ -323,7 +323,7 @@ Module( | 12 | # Dictionary element in a list 13 | [1: 2] - | ^ Syntax Error: Expected an expression or a ']' + | ^ Syntax Error: invalid syntax 14 | 15 | # Missing expression | @@ -332,7 +332,7 @@ Module( | 15 | # Missing expression 16 | [1, x + ] - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 17 | 18 | [1; 2] | @@ -342,7 +342,7 @@ Module( 16 | [1, x + ] 17 | 18 | [1; 2] - | ^ Syntax Error: Expected an expression or a ']' + | ^ Syntax Error: invalid syntax 19 | 20 | [*] | @@ -352,4 +352,4 @@ Module( 18 | [1; 2] 19 | 20 | [*] - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap index 2b600b89809e9d..265a08bbae5130 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap @@ -468,7 +468,7 @@ Module( 1 | # For list expression, the minimum binding power of star expression is bitwise or. 2 | 3 | [(*x), y] - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 4 | [*x in y, z] 5 | [*not x, z] | @@ -477,7 +477,7 @@ Module( | 3 | [(*x), y] 4 | [*x in y, z] - | ^^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^^ Syntax Error: comparison expression cannot be used here 5 | [*not x, z] 6 | [*x and y, z] | @@ -487,7 +487,7 @@ Module( 3 | [(*x), y] 4 | [*x in y, z] 5 | [*not x, z] - | ^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^ Syntax Error: boolean expression cannot be used here 6 | [*x and y, z] 7 | [*x or y, z] | @@ -497,7 +497,7 @@ Module( 4 | [*x in y, z] 5 | [*not x, z] 6 | [*x and y, z] - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 7 | [*x or y, z] 8 | [*x if True else y, z] | @@ -507,7 +507,7 @@ Module( 5 | [*not x, z] 6 | [*x and y, z] 7 | [*x or y, z] - | ^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^ Syntax Error: boolean expression cannot be used here 8 | [*x if True else y, z] 9 | [*lambda x: x, z] | @@ -517,7 +517,7 @@ Module( 6 | [*x and y, z] 7 | [*x or y, z] 8 | [*x if True else y, z] - | ^^^^^^^^^^^^^^^^ Syntax Error: Conditional expression cannot be used here + | ^^^^^^^^^^^^^^^^ Syntax Error: conditional expression cannot be used here 9 | [*lambda x: x, z] 10 | [*x := 2, z] | @@ -527,7 +527,7 @@ Module( 7 | [*x or y, z] 8 | [*x if True else y, z] 9 | [*lambda x: x, z] - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 10 | [*x := 2, z] | @@ -536,4 +536,4 @@ Module( 8 | [*x if True else y, z] 9 | [*lambda x: x, z] 10 | [*x := 2, z] - | ^^ Syntax Error: Assignment expression target must be an identifier + | ^^ Syntax Error: assignment expression target must be an identifier diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap index 1dc3c831421f58..faa2bcbde3ab9a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap @@ -208,7 +208,7 @@ Module( 1 | # Assignment expression target can only be an identifier 2 | 3 | (x.y := 1) - | ^^^ Syntax Error: Assignment expression target must be an identifier + | ^^^ Syntax Error: assignment expression target must be an identifier 4 | (x[y] := 1) 5 | (*x := 1) | @@ -217,7 +217,7 @@ Module( | 3 | (x.y := 1) 4 | (x[y] := 1) - | ^^^^ Syntax Error: Assignment expression target must be an identifier + | ^^^^ Syntax Error: assignment expression target must be an identifier 5 | (*x := 1) 6 | ([x, y] := [1, 2]) | @@ -227,7 +227,7 @@ Module( 3 | (x.y := 1) 4 | (x[y] := 1) 5 | (*x := 1) - | ^^ Syntax Error: Assignment expression target must be an identifier + | ^^ Syntax Error: assignment expression target must be an identifier 6 | ([x, y] := [1, 2]) | @@ -236,4 +236,4 @@ Module( 4 | (x[y] := 1) 5 | (*x := 1) 6 | ([x, y] := [1, 2]) - | ^^^^^^ Syntax Error: Assignment expression target must be an identifier + | ^^^^^^ Syntax Error: assignment expression target must be an identifier diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap index 763170445a70e7..6beff1efce0b95 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_0.py.snap @@ -35,11 +35,11 @@ Module( 1 | # There are no parentheses, so this isn't parsed as named expression. 2 | 3 | x := - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax | 1 | # There are no parentheses, so this isn't parsed as named expression. 2 | 3 | x := - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap index a47f5ea3956e6e..414930d14ed63c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap @@ -88,7 +88,7 @@ Module( 3 | (x := 4 | 5 | def foo(): - | ^^^ Syntax Error: Expected an identifier, but found a keyword `def` that cannot be used here + | ^^^ Syntax Error: invalid syntax 6 | pass | @@ -97,7 +97,7 @@ Module( 3 | (x := 4 | 5 | def foo(): - | ^^^ Syntax Error: Expected `)`, found identifier + | ^^^ Syntax Error: invalid syntax 6 | pass | @@ -105,7 +105,7 @@ Module( | 5 | def foo(): 6 | pass - | ^^^^ Syntax Error: Expected an identifier, but found a keyword `pass` that cannot be used here + | ^^^^ Syntax Error: invalid syntax | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap index 9e350aa0142086..519e9d34eb446f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_4.py.snap @@ -78,7 +78,7 @@ Module( 1 | # No expression on the right side of the assignment expression 2 | 3 | (x := ) - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | 5 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap index f22d9e8250f3b8..07309f06260902 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap @@ -88,14 +88,14 @@ Module( | 1 | (x := 1, for x in y) - | ^^^ Syntax Error: Expected `)`, found `for` + | ^^^ Syntax Error: invalid syntax | 1 | (x := 1, for x in y) - | ^ Syntax Error: Expected `:`, found `)` + | ^ Syntax Error: invalid syntax | 1 | (x := 1, for x in y) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap index 38b6a70c0dc30b..136a9f14232c7d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap @@ -93,7 +93,7 @@ Module( 2 | # token starts a statement. 3 | 4 | (1, 2 - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 5 | 6 | def foo(): 7 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap index 4ad25409ab9f42..a6b3e86363206f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap @@ -70,7 +70,7 @@ Module( | 1 | # Starred expression isn't allowed in a parenthesized expression. 2 | (*x) - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 3 | 4 | # Unparenthesized named expression is allowed. | @@ -79,4 +79,4 @@ Module( | 4 | # Unparenthesized named expression is allowed. 5 | x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap index e81959f1c97b49..c96a4fa6182585 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap @@ -293,7 +293,7 @@ Module( 1 | # Test cases for tuple expressions where the parser recovers from a syntax error. 2 | 3 | (,) - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | 5 | (1,,2) | @@ -303,7 +303,7 @@ Module( 3 | (,) 4 | 5 | (1,,2) - | ^ Syntax Error: Expected an expression or a ')' + | ^ Syntax Error: invalid syntax 6 | 7 | (1,,) | @@ -313,7 +313,7 @@ Module( 5 | (1,,2) 6 | 7 | (1,,) - | ^ Syntax Error: Expected an expression or a ')' + | ^ Syntax Error: invalid syntax 8 | 9 | # Missing comma | @@ -322,7 +322,7 @@ Module( | 9 | # Missing comma 10 | (1 2) - | ^ Syntax Error: Expected `)`, found int + | ^ Syntax Error: invalid syntax 11 | 12 | # Dictionary element in a list | @@ -331,7 +331,7 @@ Module( | 9 | # Missing comma 10 | (1 2) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 11 | 12 | # Dictionary element in a list | @@ -340,7 +340,7 @@ Module( | 9 | # Missing comma 10 | (1 2) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 11 | 12 | # Dictionary element in a list 13 | (1: 2) @@ -350,7 +350,7 @@ Module( | 12 | # Dictionary element in a list 13 | (1: 2) - | ^ Syntax Error: Expected `)`, found `:` + | ^ Syntax Error: invalid syntax 14 | 15 | # Missing expression | @@ -359,7 +359,7 @@ Module( | 12 | # Dictionary element in a list 13 | (1: 2) - | ^ Syntax Error: Invalid annotated assignment target + | ^ Syntax Error: illegal target for annotation 14 | 15 | # Missing expression | @@ -368,7 +368,7 @@ Module( | 12 | # Dictionary element in a list 13 | (1: 2) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 14 | 15 | # Missing expression | @@ -377,7 +377,7 @@ Module( | 12 | # Dictionary element in a list 13 | (1: 2) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 14 | 15 | # Missing expression 16 | (1, x + ) @@ -387,7 +387,7 @@ Module( | 15 | # Missing expression 16 | (1, x + ) - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 17 | 18 | (1; 2) | @@ -397,7 +397,7 @@ Module( 16 | (1, x + ) 17 | 18 | (1; 2) - | ^ Syntax Error: Expected `)`, found `;` + | ^ Syntax Error: invalid syntax 19 | 20 | # Unparenthesized named expression is not allowed | @@ -407,7 +407,7 @@ Module( 16 | (1, x + ) 17 | 18 | (1; 2) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 19 | 20 | # Unparenthesized named expression is not allowed | @@ -417,7 +417,7 @@ Module( 16 | (1, x + ) 17 | 18 | (1; 2) - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 19 | 20 | # Unparenthesized named expression is not allowed 21 | x, y := 2, z @@ -427,4 +427,4 @@ Module( | 20 | # Unparenthesized named expression is not allowed 21 | x, y := 2, z - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap index ffcab4dce9c382..315cc313132361 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap @@ -1325,7 +1325,7 @@ Module( 2 | # Test the first and any other element as there are two separate calls. 3 | 4 | (*x in y, z, *x in y) - | ^^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^^ Syntax Error: comparison expression cannot be used here 5 | (*not x, z, *not x) 6 | (*x and y, z, *x and y) | @@ -1335,7 +1335,7 @@ Module( 2 | # Test the first and any other element as there are two separate calls. 3 | 4 | (*x in y, z, *x in y) - | ^^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^^ Syntax Error: comparison expression cannot be used here 5 | (*not x, z, *not x) 6 | (*x and y, z, *x and y) | @@ -1344,7 +1344,7 @@ Module( | 4 | (*x in y, z, *x in y) 5 | (*not x, z, *not x) - | ^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^ Syntax Error: boolean expression cannot be used here 6 | (*x and y, z, *x and y) 7 | (*x or y, z, *x or y) | @@ -1353,7 +1353,7 @@ Module( | 4 | (*x in y, z, *x in y) 5 | (*not x, z, *not x) - | ^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^ Syntax Error: boolean expression cannot be used here 6 | (*x and y, z, *x and y) 7 | (*x or y, z, *x or y) | @@ -1363,7 +1363,7 @@ Module( 4 | (*x in y, z, *x in y) 5 | (*not x, z, *not x) 6 | (*x and y, z, *x and y) - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 7 | (*x or y, z, *x or y) 8 | (*x if True else y, z, *x if True else y) | @@ -1373,7 +1373,7 @@ Module( 4 | (*x in y, z, *x in y) 5 | (*not x, z, *not x) 6 | (*x and y, z, *x and y) - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 7 | (*x or y, z, *x or y) 8 | (*x if True else y, z, *x if True else y) | @@ -1383,7 +1383,7 @@ Module( 5 | (*not x, z, *not x) 6 | (*x and y, z, *x and y) 7 | (*x or y, z, *x or y) - | ^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^ Syntax Error: boolean expression cannot be used here 8 | (*x if True else y, z, *x if True else y) 9 | (*lambda x: x, z, *lambda x: x) | @@ -1393,7 +1393,7 @@ Module( 5 | (*not x, z, *not x) 6 | (*x and y, z, *x and y) 7 | (*x or y, z, *x or y) - | ^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^ Syntax Error: boolean expression cannot be used here 8 | (*x if True else y, z, *x if True else y) 9 | (*lambda x: x, z, *lambda x: x) | @@ -1403,7 +1403,7 @@ Module( 6 | (*x and y, z, *x and y) 7 | (*x or y, z, *x or y) 8 | (*x if True else y, z, *x if True else y) - | ^^^^^^^^^^^^^^^^ Syntax Error: Conditional expression cannot be used here + | ^^^^^^^^^^^^^^^^ Syntax Error: conditional expression cannot be used here 9 | (*lambda x: x, z, *lambda x: x) 10 | (*x := 2, z, *x := 2) | @@ -1413,7 +1413,7 @@ Module( 6 | (*x and y, z, *x and y) 7 | (*x or y, z, *x or y) 8 | (*x if True else y, z, *x if True else y) - | ^^^^^^^^^^^^^^^^ Syntax Error: Conditional expression cannot be used here + | ^^^^^^^^^^^^^^^^ Syntax Error: conditional expression cannot be used here 9 | (*lambda x: x, z, *lambda x: x) 10 | (*x := 2, z, *x := 2) | @@ -1423,7 +1423,7 @@ Module( 7 | (*x or y, z, *x or y) 8 | (*x if True else y, z, *x if True else y) 9 | (*lambda x: x, z, *lambda x: x) - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 10 | (*x := 2, z, *x := 2) | @@ -1432,7 +1432,7 @@ Module( 7 | (*x or y, z, *x or y) 8 | (*x if True else y, z, *x if True else y) 9 | (*lambda x: x, z, *lambda x: x) - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 10 | (*x := 2, z, *x := 2) | @@ -1441,20 +1441,20 @@ Module( 8 | (*x if True else y, z, *x if True else y) 9 | (*lambda x: x, z, *lambda x: x) 10 | (*x := 2, z, *x := 2) - | ^^ Syntax Error: Assignment expression target must be an identifier + | ^^ Syntax Error: assignment expression target must be an identifier | 8 | (*x if True else y, z, *x if True else y) 9 | (*lambda x: x, z, *lambda x: x) 10 | (*x := 2, z, *x := 2) - | ^^ Syntax Error: Assignment expression target must be an identifier + | ^^ Syntax Error: assignment expression target must be an identifier | 13 | # Non-parenthesized 14 | *x in y, z, *x in y - | ^^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^^ Syntax Error: comparison expression cannot be used here 15 | *not x, z, *not x 16 | *x and y, z, *x and y | @@ -1463,7 +1463,7 @@ Module( | 13 | # Non-parenthesized 14 | *x in y, z, *x in y - | ^^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^^ Syntax Error: comparison expression cannot be used here 15 | *not x, z, *not x 16 | *x and y, z, *x and y | @@ -1473,7 +1473,7 @@ Module( 13 | # Non-parenthesized 14 | *x in y, z, *x in y 15 | *not x, z, *not x - | ^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^ Syntax Error: boolean expression cannot be used here 16 | *x and y, z, *x and y 17 | *x or y, z, *x or y | @@ -1483,7 +1483,7 @@ Module( 13 | # Non-parenthesized 14 | *x in y, z, *x in y 15 | *not x, z, *not x - | ^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^ Syntax Error: boolean expression cannot be used here 16 | *x and y, z, *x and y 17 | *x or y, z, *x or y | @@ -1493,7 +1493,7 @@ Module( 14 | *x in y, z, *x in y 15 | *not x, z, *not x 16 | *x and y, z, *x and y - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 17 | *x or y, z, *x or y 18 | *x if True else y, z, *x if True else y | @@ -1503,7 +1503,7 @@ Module( 14 | *x in y, z, *x in y 15 | *not x, z, *not x 16 | *x and y, z, *x and y - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 17 | *x or y, z, *x or y 18 | *x if True else y, z, *x if True else y | @@ -1513,7 +1513,7 @@ Module( 15 | *not x, z, *not x 16 | *x and y, z, *x and y 17 | *x or y, z, *x or y - | ^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^ Syntax Error: boolean expression cannot be used here 18 | *x if True else y, z, *x if True else y 19 | *lambda x: x, z, *lambda x: x | @@ -1523,7 +1523,7 @@ Module( 15 | *not x, z, *not x 16 | *x and y, z, *x and y 17 | *x or y, z, *x or y - | ^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^ Syntax Error: boolean expression cannot be used here 18 | *x if True else y, z, *x if True else y 19 | *lambda x: x, z, *lambda x: x | @@ -1533,7 +1533,7 @@ Module( 16 | *x and y, z, *x and y 17 | *x or y, z, *x or y 18 | *x if True else y, z, *x if True else y - | ^^^^^^^^^^^^^^^^ Syntax Error: Conditional expression cannot be used here + | ^^^^^^^^^^^^^^^^ Syntax Error: conditional expression cannot be used here 19 | *lambda x: x, z, *lambda x: x 20 | *x := 2, z, *x := 2 | @@ -1543,7 +1543,7 @@ Module( 16 | *x and y, z, *x and y 17 | *x or y, z, *x or y 18 | *x if True else y, z, *x if True else y - | ^^^^^^^^^^^^^^^^ Syntax Error: Conditional expression cannot be used here + | ^^^^^^^^^^^^^^^^ Syntax Error: conditional expression cannot be used here 19 | *lambda x: x, z, *lambda x: x 20 | *x := 2, z, *x := 2 | @@ -1553,7 +1553,7 @@ Module( 17 | *x or y, z, *x or y 18 | *x if True else y, z, *x if True else y 19 | *lambda x: x, z, *lambda x: x - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 20 | *x := 2, z, *x := 2 | @@ -1562,7 +1562,7 @@ Module( 17 | *x or y, z, *x or y 18 | *x if True else y, z, *x if True else y 19 | *lambda x: x, z, *lambda x: x - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 20 | *x := 2, z, *x := 2 | @@ -1571,11 +1571,11 @@ Module( 18 | *x if True else y, z, *x if True else y 19 | *lambda x: x, z, *lambda x: x 20 | *x := 2, z, *x := 2 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax | 18 | *x if True else y, z, *x if True else y 19 | *lambda x: x, z, *lambda x: x 20 | *x := 2, z, *x := 2 - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap index 7ecf8227e5af53..97fab935909093 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap @@ -767,7 +767,7 @@ Module( | 1 | # Invalid target 2 | {x for 1 in y} - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target 3 | {x for 'a' in y} 4 | {x for call() in y} | @@ -777,7 +777,7 @@ Module( 1 | # Invalid target 2 | {x for 1 in y} 3 | {x for 'a' in y} - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target 4 | {x for call() in y} 5 | {x for {a, b} in y} | @@ -787,7 +787,7 @@ Module( 2 | {x for 1 in y} 3 | {x for 'a' in y} 4 | {x for call() in y} - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 5 | {x for {a, b} in y} | @@ -796,7 +796,7 @@ Module( 3 | {x for 'a' in y} 4 | {x for call() in y} 5 | {x for {a, b} in y} - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 6 | 7 | # Invalid iter | @@ -805,7 +805,7 @@ Module( | 7 | # Invalid iter 8 | {x for x in *y} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 9 | {x for x in yield y} 10 | {x for x in yield from y} | @@ -815,7 +815,7 @@ Module( 7 | # Invalid iter 8 | {x for x in *y} 9 | {x for x in yield y} - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 10 | {x for x in yield from y} 11 | {x for x in lambda y: y} | @@ -825,7 +825,7 @@ Module( 8 | {x for x in *y} 9 | {x for x in yield y} 10 | {x for x in yield from y} - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 11 | {x for x in lambda y: y} | @@ -834,7 +834,7 @@ Module( 9 | {x for x in yield y} 10 | {x for x in yield from y} 11 | {x for x in lambda y: y} - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 12 | 13 | # Invalid if | @@ -843,7 +843,7 @@ Module( | 13 | # Invalid if 14 | {x for x in data if *y} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 15 | {x for x in data if yield y} 16 | {x for x in data if yield from y} | @@ -853,7 +853,7 @@ Module( 13 | # Invalid if 14 | {x for x in data if *y} 15 | {x for x in data if yield y} - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 16 | {x for x in data if yield from y} 17 | {x for x in data if lambda y: y} | @@ -863,7 +863,7 @@ Module( 14 | {x for x in data if *y} 15 | {x for x in data if yield y} 16 | {x for x in data if yield from y} - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 17 | {x for x in data if lambda y: y} | @@ -872,4 +872,4 @@ Module( 15 | {x for x in data if yield y} 16 | {x for x in data if yield from y} 17 | {x for x in data if lambda y: y} - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap index 9cd61f1d9eaf0a..5880118381ebcf 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap @@ -91,7 +91,7 @@ Module( 2 | # token starts a statement. 3 | 4 | {1, 2 - | ^ Syntax Error: Expected `}`, found newline + | ^ Syntax Error: invalid syntax 5 | 6 | def foo(): 7 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap index 97fbfdad6a23ff..1bd56589652e25 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap @@ -282,7 +282,7 @@ Module( 3 | # These are same as for the list expressions. 4 | 5 | {,} - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 6 | 7 | {1,,2} | @@ -292,7 +292,7 @@ Module( 5 | {,} 6 | 7 | {1,,2} - | ^ Syntax Error: Expected an expression or a '}' + | ^ Syntax Error: invalid syntax 8 | 9 | {1,,} | @@ -302,7 +302,7 @@ Module( 7 | {1,,2} 8 | 9 | {1,,} - | ^ Syntax Error: Expected an expression or a '}' + | ^ Syntax Error: invalid syntax 10 | 11 | # Missing comma | @@ -311,7 +311,7 @@ Module( | 11 | # Missing comma 12 | {1 2} - | ^ Syntax Error: Expected `,`, found int + | ^ Syntax Error: invalid syntax 13 | 14 | # Dictionary element in a list | @@ -320,7 +320,7 @@ Module( | 17 | # Missing expression 18 | {1, x + } - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 19 | 20 | {1; 2} | @@ -330,7 +330,7 @@ Module( 18 | {1, x + } 19 | 20 | {1; 2} - | ^ Syntax Error: Expected an expression or a '}' + | ^ Syntax Error: invalid syntax 21 | 22 | [*] | @@ -340,4 +340,4 @@ Module( 20 | {1; 2} 21 | 22 | [*] - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap index f64182c196fda5..1e2ac72cd5ca62 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap @@ -460,7 +460,7 @@ Module( 1 | # For set expression, the minimum binding power of star expression is bitwise or. 2 | 3 | {(*x), y} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 4 | {*x in y, z} 5 | {*not x, z} | @@ -469,7 +469,7 @@ Module( | 3 | {(*x), y} 4 | {*x in y, z} - | ^^^^^^ Syntax Error: Comparison expression cannot be used here + | ^^^^^^ Syntax Error: comparison expression cannot be used here 5 | {*not x, z} 6 | {*x and y, z} | @@ -479,7 +479,7 @@ Module( 3 | {(*x), y} 4 | {*x in y, z} 5 | {*not x, z} - | ^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^ Syntax Error: boolean expression cannot be used here 6 | {*x and y, z} 7 | {*x or y, z} | @@ -489,7 +489,7 @@ Module( 4 | {*x in y, z} 5 | {*not x, z} 6 | {*x and y, z} - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 7 | {*x or y, z} 8 | {*x if True else y, z} | @@ -499,7 +499,7 @@ Module( 5 | {*not x, z} 6 | {*x and y, z} 7 | {*x or y, z} - | ^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^ Syntax Error: boolean expression cannot be used here 8 | {*x if True else y, z} 9 | {*lambda x: x, z} | @@ -509,7 +509,7 @@ Module( 6 | {*x and y, z} 7 | {*x or y, z} 8 | {*x if True else y, z} - | ^^^^^^^^^^^^^^^^ Syntax Error: Conditional expression cannot be used here + | ^^^^^^^^^^^^^^^^ Syntax Error: conditional expression cannot be used here 9 | {*lambda x: x, z} 10 | {*x := 2, z} | @@ -519,7 +519,7 @@ Module( 7 | {*x or y, z} 8 | {*x if True else y, z} 9 | {*lambda x: x, z} - | ^^^^^^^^^^^ Syntax Error: Lambda expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: lambda expression cannot be used here 10 | {*x := 2, z} | @@ -528,4 +528,4 @@ Module( 8 | {*x if True else y, z} 9 | {*lambda x: x, z} 10 | {*x := 2, z} - | ^^ Syntax Error: Assignment expression target must be an identifier + | ^^ Syntax Error: assignment expression target must be an identifier diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap index 4b6bc2038c6de5..1dd645cd78e943 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap @@ -291,7 +291,7 @@ Module( | 1 | x[x := 1:] - | ^^^^^^ Syntax Error: Unparenthesized named expression cannot be used here + | ^^^^^^ Syntax Error: unparenthesized named expression cannot be used here 2 | 3 | # Starred expression | @@ -300,7 +300,7 @@ Module( | 3 | # Starred expression 4 | x[*x:] - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 5 | x[:*x] 6 | x[::*x] | @@ -310,7 +310,7 @@ Module( 3 | # Starred expression 4 | x[*x:] 5 | x[:*x] - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 6 | x[::*x] | @@ -319,7 +319,7 @@ Module( 4 | x[*x:] 5 | x[:*x] 6 | x[::*x] - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 7 | 8 | # Empty slice | @@ -328,7 +328,7 @@ Module( | 8 | # Empty slice 9 | x[] - | ^ Syntax Error: Expected index or slice expression + | ^ Syntax Error: expected index or slice expression 10 | 11 | # Mixed starred expression and named expression | @@ -337,4 +337,4 @@ Module( | 11 | # Mixed starred expression and named expression 12 | x[*x := 1] - | ^^ Syntax Error: Assignment expression target must be an identifier + | ^^ Syntax Error: assignment expression target must be an identifier diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap index ce7e92061d8bc3..4f0e744f30e0ed 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap @@ -99,7 +99,7 @@ Module( 1 | x[:: 2 | 3 | def foo(): - | ^^^ Syntax Error: Expected an identifier, but found a keyword `def` that cannot be used here + | ^^^ Syntax Error: invalid syntax 4 | pass | @@ -108,7 +108,7 @@ Module( 1 | x[:: 2 | 3 | def foo(): - | ^^^ Syntax Error: Expected `]`, found identifier + | ^^^ Syntax Error: invalid syntax 4 | pass | @@ -116,7 +116,7 @@ Module( | 3 | def foo(): 4 | pass - | ^^^^ Syntax Error: Expected an identifier, but found a keyword `pass` that cannot be used here + | ^^^^ Syntax Error: invalid syntax | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap index 2a953ead2a4a8a..9405ea58b39bbb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap @@ -55,4 +55,4 @@ Module( | 1 | not x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap index b1d9de55a86912..4b35b2a8302471 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap @@ -91,7 +91,7 @@ Module( | 1 | -x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 2 | not x := 1 | @@ -99,4 +99,4 @@ Module( | 1 | -x := 1 2 | not x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap index fa342a515a33bf..ff3f77f7bb536b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_0.py.snap @@ -69,7 +69,7 @@ Module( | 1 | not - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 3 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap index db7b51e2a37842..a05a75b33117d2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__no_expression_1.py.snap @@ -69,7 +69,7 @@ Module( | 1 | + - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 3 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap index 04cd075c4e3a8a..2e890f9928c389 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__named_expression.py.snap @@ -117,7 +117,7 @@ Module( | 1 | # Unparenthesized named expressions are not allowed 2 | yield x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 3 | 4 | yield 1, x := 2, 3 | @@ -127,4 +127,4 @@ Module( 2 | yield x := 1 3 | 4 | yield 1, x := 2, 3 - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap index 7aec4c2dc78251..bb4871b6ba6483 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap @@ -115,7 +115,7 @@ Module( | 1 | # Cannot use starred expression here 2 | yield (*x) - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 3 | 4 | yield *x and y, z | @@ -125,7 +125,7 @@ Module( 2 | yield (*x) 3 | 4 | yield *x and y, z - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap index 5cfa734325bd66..a799c917cab3b9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap @@ -94,7 +94,7 @@ Module( 1 | # Yield from doesn't allow top-level starred expression unlike yield 2 | 3 | yield from *x - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 4 | yield from *x, y | @@ -102,4 +102,4 @@ Module( | 3 | yield from *x 4 | yield from *x, y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap index df2c7d670639a7..84bbfb4575e431 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__unparenthesized.py.snap @@ -158,7 +158,7 @@ Module( | 1 | # Unparenthesized named expression 2 | yield from x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 3 | 4 | # Unparenthesized tuple expression | @@ -167,7 +167,7 @@ Module( | 4 | # Unparenthesized tuple expression 5 | yield from x, y - | ^^^^ Syntax Error: Unparenthesized tuple expression cannot be used here + | ^^^^ Syntax Error: unparenthesized tuple expression cannot be used here 6 | 7 | # This is a tuple expression parsing | @@ -177,4 +177,4 @@ Module( 7 | # This is a tuple expression parsing 8 | # vvvvvvvvvvvvv 9 | yield from (x, *x and y) - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap index da0a683b4796f4..ba840d556a744a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap @@ -119,7 +119,7 @@ Module( | 1 | f"{}" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | f"{ }" | @@ -127,4 +127,4 @@ Module( | 1 | f"{}" 2 | f"{ }" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap index 1fa4777ce22beb..8028e8ae062c70 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap @@ -217,7 +217,7 @@ Module( | 1 | # Starred expression inside f-string has a minimum precedence of bitwise or. 2 | f"{*}" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | f"{*x and y}" 4 | f"{*yield x}" | @@ -227,7 +227,7 @@ Module( 1 | # Starred expression inside f-string has a minimum precedence of bitwise or. 2 | f"{*}" 3 | f"{*x and y}" - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 4 | f"{*yield x}" | @@ -236,4 +236,4 @@ Module( 2 | f"{*}" 3 | f"{*x and y}" 4 | f"{*yield x}" - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap index b39d15654ec359..02691110c17170 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap @@ -112,7 +112,7 @@ Module( | 1 | f"{lambda x: x}" - | ^^ Syntax Error: Expected an expression + | ^^ Syntax Error: invalid syntax | @@ -122,9 +122,9 @@ Module( | 1 | f"{lambda x: x}" - | ^^ Syntax Error: f-string: expecting `}` + | ^^ Syntax Error: f-string: expecting '}' | 1 | f"{lambda x: x}" - | ^ Syntax Error: Expected an element of or the end of the f-string + | ^ Syntax Error: expected an element of or the end of the f-string diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap index d7b8640bfcda9e..7a305c3bd35a63 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap @@ -275,7 +275,7 @@ Module( | 1 | f"{" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | f"{foo!r" 3 | f"{foo=" | @@ -284,7 +284,7 @@ Module( | 1 | f"{" 2 | f"{foo!r" - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' 3 | f"{foo=" 4 | f"{" | @@ -294,7 +294,7 @@ Module( 1 | f"{" 2 | f"{foo!r" 3 | f"{foo=" - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' 4 | f"{" 5 | f"""{""" | @@ -304,7 +304,7 @@ Module( 2 | f"{foo!r" 3 | f"{foo=" 4 | f"{" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 5 | f"""{""" | @@ -313,4 +313,4 @@ Module( 3 | f"{foo=" 4 | f"{" 5 | f"""{""" - | ^^^ Syntax Error: Expected an expression + | ^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap index 90620942db665c..1ed9b9adcae0e4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap @@ -153,7 +153,7 @@ Module( | 1 | f"hello {x:" - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' 2 | f"hello {x:.3f" | @@ -161,4 +161,4 @@ Module( | 1 | f"hello {x:" 2 | f"hello {x:.3f" - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_iter_unpack_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_iter_unpack_py38.py.snap index e682e6f34c80ff..7b1c6c57b8869c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_iter_unpack_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_iter_unpack_py38.py.snap @@ -231,7 +231,7 @@ Module( | 1 | # parse_options: {"target-version": "3.8"} 2 | for x in *a, b: ... - | ^^ Syntax Error: Cannot use iterable unpacking in `for` statements on Python 3.8 (syntax was added in Python 3.9) + | ^^ Syntax Error: cannot use iterable unpacking in `for` statements on Python 3.8 (syntax was added in Python 3.9) 3 | for x in a, *b: ... 4 | for x in *a, *b: ... | @@ -241,7 +241,7 @@ Module( 1 | # parse_options: {"target-version": "3.8"} 2 | for x in *a, b: ... 3 | for x in a, *b: ... - | ^^ Syntax Error: Cannot use iterable unpacking in `for` statements on Python 3.8 (syntax was added in Python 3.9) + | ^^ Syntax Error: cannot use iterable unpacking in `for` statements on Python 3.8 (syntax was added in Python 3.9) 4 | for x in *a, *b: ... | @@ -250,11 +250,11 @@ Module( 2 | for x in *a, b: ... 3 | for x in a, *b: ... 4 | for x in *a, *b: ... - | ^^ Syntax Error: Cannot use iterable unpacking in `for` statements on Python 3.8 (syntax was added in Python 3.9) + | ^^ Syntax Error: cannot use iterable unpacking in `for` statements on Python 3.8 (syntax was added in Python 3.9) | 2 | for x in *a, b: ... 3 | for x in a, *b: ... 4 | for x in *a, *b: ... - | ^^ Syntax Error: Cannot use iterable unpacking in `for` statements on Python 3.8 (syntax was added in Python 3.9) + | ^^ Syntax Error: cannot use iterable unpacking in `for` statements on Python 3.8 (syntax was added in Python 3.9) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_iter_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_iter_expr.py.snap index 36ccdbcd4f4b90..805092aeac86df 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_iter_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_iter_expr.py.snap @@ -189,7 +189,7 @@ Module( | 1 | for x in *a and b: ... - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 2 | for x in yield a: ... 3 | for target in x := 1: ... | @@ -198,7 +198,7 @@ Module( | 1 | for x in *a and b: ... 2 | for x in yield a: ... - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | for target in x := 1: ... | @@ -207,14 +207,14 @@ Module( 1 | for x in *a and b: ... 2 | for x in yield a: ... 3 | for target in x := 1: ... - | ^^ Syntax Error: Expected `:`, found `:=` + | ^^ Syntax Error: invalid syntax | 1 | for x in *a and b: ... 2 | for x in yield a: ... 3 | for target in x := 1: ... - | ^ Syntax Error: Invalid annotated assignment target + | ^ Syntax Error: illegal target for annotation ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap index 6de3dd3656ed12..4868e5900595ec 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap @@ -473,7 +473,7 @@ Module( | 1 | for 1 in x: ... - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target 2 | for "a" in x: ... 3 | for *x and y in z: ... | @@ -482,7 +482,7 @@ Module( | 1 | for 1 in x: ... 2 | for "a" in x: ... - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target 3 | for *x and y in z: ... 4 | for *x | y in z: ... | @@ -492,7 +492,7 @@ Module( 1 | for 1 in x: ... 2 | for "a" in x: ... 3 | for *x and y in z: ... - | ^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^ Syntax Error: invalid assignment target 4 | for *x | y in z: ... 5 | for await x in z: ... | @@ -502,7 +502,7 @@ Module( 2 | for "a" in x: ... 3 | for *x and y in z: ... 4 | for *x | y in z: ... - | ^^^^^ Syntax Error: Invalid assignment target + | ^^^^^ Syntax Error: invalid assignment target 5 | for await x in z: ... 6 | for yield x in y: ... | @@ -512,7 +512,7 @@ Module( 3 | for *x and y in z: ... 4 | for *x | y in z: ... 5 | for await x in z: ... - | ^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^ Syntax Error: invalid assignment target 6 | for yield x in y: ... 7 | for [x, 1, y, *["a"]] in z: ... | @@ -522,7 +522,7 @@ Module( 4 | for *x | y in z: ... 5 | for await x in z: ... 6 | for yield x in y: ... - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 7 | for [x, 1, y, *["a"]] in z: ... | @@ -531,7 +531,7 @@ Module( 4 | for *x | y in z: ... 5 | for await x in z: ... 6 | for yield x in y: ... - | ^ Syntax Error: Expected `in`, found `:` + | ^ Syntax Error: invalid syntax 7 | for [x, 1, y, *["a"]] in z: ... | @@ -540,14 +540,14 @@ Module( 5 | for await x in z: ... 6 | for yield x in y: ... 7 | for [x, 1, y, *["a"]] in z: ... - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target | 5 | for await x in z: ... 6 | for yield x in y: ... 7 | for [x, 1, y, *["a"]] in z: ... - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap index f14a69a4156281..d0142929330e98 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap @@ -358,7 +358,7 @@ Module( | 1 | for x not in y in z: ... - | ^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^ Syntax Error: invalid assignment target 2 | for x == y in z: ... 3 | for x or y in z: ... | @@ -367,7 +367,7 @@ Module( | 1 | for x not in y in z: ... 2 | for x == y in z: ... - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 3 | for x or y in z: ... 4 | for -x in y: ... | @@ -377,7 +377,7 @@ Module( 1 | for x not in y in z: ... 2 | for x == y in z: ... 3 | for x or y in z: ... - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 4 | for -x in y: ... 5 | for not x in y: ... | @@ -387,7 +387,7 @@ Module( 2 | for x == y in z: ... 3 | for x or y in z: ... 4 | for -x in y: ... - | ^^ Syntax Error: Invalid assignment target + | ^^ Syntax Error: invalid assignment target 5 | for not x in y: ... 6 | for x | y in z: ... | @@ -397,7 +397,7 @@ Module( 3 | for x or y in z: ... 4 | for -x in y: ... 5 | for not x in y: ... - | ^^^^^ Syntax Error: Invalid assignment target + | ^^^^^ Syntax Error: invalid assignment target 6 | for x | y in z: ... | @@ -406,4 +406,4 @@ Module( 4 | for -x in y: ... 5 | for not x in y: ... 6 | for x | y in z: ... - | ^^^^^ Syntax Error: Invalid assignment target + | ^^^^^ Syntax Error: invalid assignment target diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap index 730d35f2e5843e..4b3b5321714606 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap @@ -482,7 +482,7 @@ Module( | 1 | for d(x in y) in target: ... - | ^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^ Syntax Error: invalid assignment target 2 | for (x in y)() in iter: ... 3 | for (x in y) in iter: ... | @@ -491,7 +491,7 @@ Module( | 1 | for d(x in y) in target: ... 2 | for (x in y)() in iter: ... - | ^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^ Syntax Error: invalid assignment target 3 | for (x in y) in iter: ... 4 | for (x in y, z) in iter: ... | @@ -501,7 +501,7 @@ Module( 1 | for d(x in y) in target: ... 2 | for (x in y)() in iter: ... 3 | for (x in y) in iter: ... - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 4 | for (x in y, z) in iter: ... 5 | for [x in y, z] in iter: ... | @@ -511,7 +511,7 @@ Module( 2 | for (x in y)() in iter: ... 3 | for (x in y) in iter: ... 4 | for (x in y, z) in iter: ... - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 5 | for [x in y, z] in iter: ... 6 | for {x in y, z} in iter: ... | @@ -521,7 +521,7 @@ Module( 3 | for (x in y) in iter: ... 4 | for (x in y, z) in iter: ... 5 | for [x in y, z] in iter: ... - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 6 | for {x in y, z} in iter: ... | @@ -530,4 +530,4 @@ Module( 4 | for (x in y, z) in iter: ... 5 | for [x in y, z] in iter: ... 6 | for {x in y, z} in iter: ... - | ^^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^^ Syntax Error: invalid assignment target diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_in_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_in_keyword.py.snap index db26cf72a549c2..039cfba67a12af 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_in_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_in_keyword.py.snap @@ -103,7 +103,7 @@ Module( | 1 | for a b: ... - | ^ Syntax Error: Expected `in`, found identifier + | ^ Syntax Error: invalid syntax 2 | for a: ... | @@ -111,4 +111,4 @@ Module( | 1 | for a b: ... 2 | for a: ... - | ^ Syntax Error: Expected `in`, found `:` + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_iter.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_iter.py.snap index 32b2afb5276838..e3248d31de5d4f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_iter.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_iter.py.snap @@ -77,6 +77,6 @@ Module( | 1 | for x in: - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | a = 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_target.py.snap index b0f9aa79376a78..210007f9775ba0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_missing_target.py.snap @@ -61,4 +61,4 @@ Module( | 1 | for in x: ... - | ^^ Syntax Error: Expected an identifier + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_dotted_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_dotted_names.py.snap index 789c0799239e0b..187c7a05586601 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_dotted_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_dotted_names.py.snap @@ -173,7 +173,7 @@ Module( | 1 | from x import a. - | ^ Syntax Error: Expected `,`, found `.` + | ^ Syntax Error: invalid syntax 2 | from x import a.b 3 | from x import a, b.c, d, e.f, g | @@ -182,7 +182,7 @@ Module( | 1 | from x import a. 2 | from x import a.b - | ^ Syntax Error: Expected `,`, found `.` + | ^ Syntax Error: invalid syntax 3 | from x import a, b.c, d, e.f, g | @@ -191,11 +191,11 @@ Module( 1 | from x import a. 2 | from x import a.b 3 | from x import a, b.c, d, e.f, g - | ^ Syntax Error: Expected `,`, found `.` + | ^ Syntax Error: invalid syntax | 1 | from x import a. 2 | from x import a.b 3 | from x import a, b.c, d, e.f, g - | ^ Syntax Error: Expected `,`, found `.` + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_empty_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_empty_names.py.snap index 0cd4161ff65cd6..4c2000d90a4295 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_empty_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_empty_names.py.snap @@ -70,7 +70,7 @@ Module( | 1 | from x import - | ^ Syntax Error: Expected one or more symbol names after import + | ^ Syntax Error: Expected one or more names after 'import' 2 | from x import () 3 | from x import ,, | @@ -79,7 +79,7 @@ Module( | 1 | from x import 2 | from x import () - | ^ Syntax Error: Expected one or more symbol names after import + | ^ Syntax Error: Expected one or more names after 'import' 3 | from x import ,, | @@ -88,18 +88,18 @@ Module( 1 | from x import 2 | from x import () 3 | from x import ,, - | ^ Syntax Error: Expected an import name + | ^ Syntax Error: invalid syntax | 1 | from x import 2 | from x import () 3 | from x import ,, - | ^ Syntax Error: Expected an import name + | ^ Syntax Error: invalid syntax | 1 | from x import 2 | from x import () 3 | from x import ,, - | ^ Syntax Error: Expected one or more symbol names after import + | ^ Syntax Error: Expected one or more names after 'import' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_module.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_module.py.snap index 5f34bd941cbc62..733e7cf6a409de 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_module.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_module.py.snap @@ -52,7 +52,7 @@ Module( | 1 | from - | ^ Syntax Error: Expected a module name + | ^ Syntax Error: expected a module name 2 | from import x | @@ -60,4 +60,4 @@ Module( | 1 | from 2 | from import x - | ^^^^^^ Syntax Error: Expected a module name + | ^^^^^^ Syntax Error: expected a module name diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_rpar.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_rpar.py.snap index b751f55e738d98..5dbb666af6b5b5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_rpar.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_missing_rpar.py.snap @@ -157,7 +157,7 @@ Module( | 1 | from x import (a, b - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 2 | 1 + 1 3 | from x import (a, b, 4 | 2 + 2 @@ -168,6 +168,6 @@ Module( 1 | from x import (a, b 2 | 1 + 1 3 | from x import (a, b, - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 4 | 2 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_parenthesized_star.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_parenthesized_star.py.snap index 1f172cbb8b9b10..1fb83293d42b09 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_parenthesized_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_parenthesized_star.py.snap @@ -47,4 +47,4 @@ Module( | 1 | from x import (*) - | ^^ Syntax Error: Star import cannot be parenthesized + | ^^ Syntax Error: star import cannot be parenthesized diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_star_with_other_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_star_with_other_names.py.snap index ea9337bdaa1a2b..ad29e88166ca1c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_star_with_other_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_star_with_other_names.py.snap @@ -197,7 +197,7 @@ Module( | 1 | from x import *, a - | ^^^^ Syntax Error: Star import must be the only import + | ^^^^ Syntax Error: star import must be the only import 2 | from x import a, *, b 3 | from x import *, a as b | @@ -206,7 +206,7 @@ Module( | 1 | from x import *, a 2 | from x import a, *, b - | ^^^^^^^ Syntax Error: Star import must be the only import + | ^^^^^^^ Syntax Error: star import must be the only import 3 | from x import *, a as b 4 | from x import *, *, a | @@ -216,7 +216,7 @@ Module( 1 | from x import *, a 2 | from x import a, *, b 3 | from x import *, a as b - | ^^^^^^^^^ Syntax Error: Star import must be the only import + | ^^^^^^^^^ Syntax Error: star import must be the only import 4 | from x import *, *, a | @@ -225,4 +225,4 @@ Module( 2 | from x import a, *, b 3 | from x import *, a as b 4 | from x import *, *, a - | ^^^^^^^ Syntax Error: Star import must be the only import + | ^^^^^^^ Syntax Error: star import must be the only import diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_unparenthesized_trailing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_unparenthesized_trailing_comma.py.snap index f96de9c325a5b8..c0466a02bc0535 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_unparenthesized_trailing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@from_import_unparenthesized_trailing_comma.py.snap @@ -119,7 +119,7 @@ Module( | 1 | from a import b, - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses 2 | from a import b as c, 3 | from a import b, c, | @@ -128,7 +128,7 @@ Module( | 1 | from a import b, 2 | from a import b as c, - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses 3 | from a import b, c, | @@ -137,4 +137,4 @@ Module( 1 | from a import b, 2 | from a import b as c, 3 | from a import b, c, - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap index 616fe16ffd626a..77165b59c041a5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap @@ -117,7 +117,7 @@ Module( | 1 | def foo(): 2 | def foo() -> int: - | ^^^ Syntax Error: Expected an indented block after function definition + | ^^^ Syntax Error: expected an indented block after function definition 3 | x = 42 | @@ -126,4 +126,4 @@ Module( 1 | def foo(): 2 | def foo() -> int: 3 | x = 42 - | ^ Syntax Error: Expected an indented block after function definition + | ^ Syntax Error: expected an indented block after function definition diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap index 86c78504253d0b..df2fe3d7b11996 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap @@ -197,7 +197,7 @@ Module( | 1 | def foo() -> *int: ... - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | def foo() -> (*int): ... 3 | def foo() -> yield x: ... | @@ -206,7 +206,7 @@ Module( | 1 | def foo() -> *int: ... 2 | def foo() -> (*int): ... - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 3 | def foo() -> yield x: ... | @@ -215,7 +215,7 @@ Module( 1 | def foo() -> *int: ... 2 | def foo() -> (*int): ... 3 | def foo() -> yield x: ... - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_identifier.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_identifier.py.snap index 65fa7c58e6048a..a531455d8979e0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_identifier.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_identifier.py.snap @@ -114,7 +114,7 @@ Module( | 1 | def (): ... - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax 2 | def () -> int: ... | @@ -122,4 +122,4 @@ Module( | 1 | def (): ... 2 | def () -> int: ... - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_return_type.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_return_type.py.snap index 4b282afab457af..131453f3ea3c19 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_return_type.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_missing_return_type.py.snap @@ -62,4 +62,4 @@ Module( | 1 | def foo() -> : ... - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap index 8de9aa7b5dc6fb..a94f6db90f72ad 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap @@ -252,7 +252,7 @@ Module( | 1 | def foo(a: int, b: 2 | def foo(): - | ^^^ Syntax Error: Expected an expression + | ^^^ Syntax Error: invalid syntax 3 | return 42 4 | def foo(a: int, b: str | @@ -260,7 +260,7 @@ Module( | 1 | def foo(a: int, b: - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 2 | def foo(): 3 | return 42 4 | def foo(a: int, b: str @@ -270,7 +270,7 @@ Module( | 1 | def foo(a: int, b: 2 | def foo(): - | ^^^ Syntax Error: Expected an indented block after function definition + | ^^^ Syntax Error: expected an indented block after function definition 3 | return 42 4 | def foo(a: int, b: str | @@ -280,7 +280,7 @@ Module( 3 | return 42 4 | def foo(a: int, b: str 5 | x = 10 - | ^ Syntax Error: Expected `,`, found identifier + | ^ Syntax Error: invalid syntax | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap index 27102d9e05c2f7..7e5c676a0e7609 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap @@ -177,7 +177,7 @@ Module( | 1 | def foo[T1, *T2(a, b): - | ^ Syntax Error: Expected `]`, found `(` + | ^ Syntax Error: invalid syntax 2 | return a + b 3 | x = 10 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unparenthesized_return_types.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unparenthesized_return_types.py.snap index 67cd9df098b22d..abd4cec9420491 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unparenthesized_return_types.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unparenthesized_return_types.py.snap @@ -153,7 +153,7 @@ Module( | 1 | def foo() -> int,: ... - | ^^^^ Syntax Error: Multiple return types must be parenthesized + | ^^^^ Syntax Error: multiple return types must be parenthesized 2 | def foo() -> int, str: ... | @@ -161,4 +161,4 @@ Module( | 1 | def foo() -> int,: ... 2 | def foo() -> int, str: ... - | ^^^^^^^^ Syntax Error: Multiple return types must be parenthesized + | ^^^^^^^^ Syntax Error: multiple return types must be parenthesized diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_type_params_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_type_params_py311.py.snap index 769799bdd0c158..30b63a353ee38a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_type_params_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_type_params_py311.py.snap @@ -143,7 +143,7 @@ Module( | 1 | # parse_options: {"target-version": "3.11"} 2 | def foo[T](): ... - | ^^^ Syntax Error: Cannot use type parameter lists on Python 3.11 (syntax was added in Python 3.12) + | ^^^ Syntax Error: cannot use type parameter lists on Python 3.11 (syntax was added in Python 3.12) 3 | def foo[](): ... | @@ -152,4 +152,4 @@ Module( 1 | # parse_options: {"target-version": "3.11"} 2 | def foo[T](): ... 3 | def foo[](): ... - | ^^ Syntax Error: Cannot use type parameter lists on Python 3.11 (syntax was added in Python 3.12) + | ^^ Syntax Error: cannot use type parameter lists on Python 3.11 (syntax was added in Python 3.12) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_empty.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_empty.py.snap index bf9a95a1130a3e..ffe23cb0dbf152 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_empty.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_empty.py.snap @@ -26,4 +26,4 @@ Module( | 1 | global - | ^ Syntax Error: Global statement must have at least one name + | ^ Syntax Error: global statement must have at least one name diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_expression.py.snap index 708cc0eb9f0527..c547b7ebedcd65 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_expression.py.snap @@ -54,4 +54,4 @@ Module( | 1 | global x + 1 - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_trailing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_trailing_comma.py.snap index 4c57d4ab886ec2..f80fc0b4a7ee2f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_trailing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@global_stmt_trailing_comma.py.snap @@ -57,7 +57,7 @@ Module( | 1 | global , - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax 2 | global x, 3 | global x, y, | @@ -65,7 +65,7 @@ Module( | 1 | global , - | ^ Syntax Error: Global statement must have at least one name + | ^ Syntax Error: global statement must have at least one name 2 | global x, 3 | global x, y, | @@ -74,7 +74,7 @@ Module( | 1 | global , 2 | global x, - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses 3 | global x, y, | @@ -83,4 +83,4 @@ Module( 1 | global , 2 | global x, 3 | global x, y, - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_missing_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_missing_colon.py.snap index a3553f96574921..3d09168f67827f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_missing_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_missing_colon.py.snap @@ -85,7 +85,7 @@ Module( 1 | if x: 2 | pass 3 | elif y - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 4 | pass 5 | else: 6 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap index 0df7acba7d3559..d604ef52f11a8f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap @@ -67,4 +67,4 @@ Module( | 1 | if True: 2 | 1 + 1 - | ^ Syntax Error: Expected an indented block after `if` statement + | ^ Syntax Error: expected an indented block after `if` statement diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap index cbf69b260cd7ac..d49261a9f69dfd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap @@ -109,7 +109,7 @@ Module( 1 | if x: 2 | pass 3 | elif *x: - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 4 | pass 5 | elif yield x: | @@ -119,6 +119,6 @@ Module( 3 | elif *x: 4 | pass 5 | elif yield x: - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 6 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap index dd0865ba44bb95..b071542bb91859 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap @@ -130,7 +130,7 @@ Module( | 1 | if *x: ... - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | if yield x: ... 3 | if yield from x: ... | @@ -139,7 +139,7 @@ Module( | 1 | if *x: ... 2 | if yield x: ... - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | if yield from x: ... | @@ -148,4 +148,4 @@ Module( 1 | if *x: ... 2 | if yield x: ... 3 | if yield from x: ... - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap index 3f20fe86301d16..1f124f45d801e8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap @@ -88,7 +88,7 @@ Module( | 1 | if x - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 2 | if x 3 | pass 4 | a = 1 @@ -98,7 +98,7 @@ Module( | 1 | if x 2 | if x - | ^^ Syntax Error: Expected an indented block after `if` statement + | ^^ Syntax Error: expected an indented block after `if` statement 3 | pass 4 | a = 1 | @@ -107,7 +107,7 @@ Module( | 1 | if x 2 | if x - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 3 | pass 4 | a = 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_test.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_test.py.snap index 00631867e2abf7..479b6581530946 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_test.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_test.py.snap @@ -49,4 +49,4 @@ Module( | 1 | if : ... - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 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 8af41bdaf979dd..a48c3053e1e525 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 @@ -81,7 +81,7 @@ Module( 1 | if True: 2 | pass 3 | elf: - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | pass 5 | else: 6 | pass @@ -92,7 +92,7 @@ Module( 2 | pass 3 | elf: 4 | pass - | ^^^^ Syntax Error: Unexpected indentation + | ^^^^ Syntax Error: unexpected indentation 5 | else: 6 | pass | @@ -102,7 +102,7 @@ Module( 3 | elf: 4 | pass 5 | else: - | ^^^^ Syntax Error: Expected a statement + | ^^^^ Syntax Error: invalid syntax 6 | pass | @@ -111,7 +111,7 @@ Module( 3 | elf: 4 | pass 5 | else: - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 6 | pass | @@ -120,7 +120,7 @@ Module( 3 | elf: 4 | pass 5 | else: - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 6 | pass | @@ -129,4 +129,4 @@ Module( 4 | pass 5 | else: 6 | pass - | ^^^^ Syntax Error: Unexpected indentation + | ^^^^ Syntax Error: unexpected indentation diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap index f7a8949678bc65..5dc27f2c95256c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap @@ -208,6 +208,6 @@ Module( 1 | 'hello' 'world 2 | 1 + 1 3 | 'hello' f'world {x} - | ^ Syntax Error: f-string: unterminated string + | ^ Syntax Error: unterminated f-string literal 4 | 2 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap index dc1fd69e155731..237a21f958fcd0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap @@ -224,7 +224,7 @@ Module( 1 | ( 2 | 'hello' 3 | f'world {x} - | ^ Syntax Error: f-string: unterminated string + | ^ Syntax Error: unterminated f-string literal 4 | ) 5 | 1 + 1 | @@ -234,7 +234,7 @@ Module( 2 | 'hello' 3 | f'world {x} 4 | ) - | ^ Syntax Error: Expected an element of or the end of the f-string + | ^ Syntax Error: expected an element of or the end of the f-string 5 | 1 + 1 6 | ( | @@ -244,7 +244,7 @@ Module( 2 | 'hello' 3 | f'world {x} 4 | ) - | ^ Syntax Error: Expected FStringEnd, found newline + | ^ Syntax Error: invalid syntax 5 | 1 + 1 6 | ( 7 | 'first' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_missing_asname.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_missing_asname.py.snap index e0b748fdf0200f..06614b7ccee8a1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_missing_asname.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_missing_asname.py.snap @@ -38,4 +38,4 @@ Module( | 1 | import x as - | ^ Syntax Error: Expected symbol after `as` + | ^ Syntax Error: expected symbol after `as` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_from_star.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_from_star.py.snap index e2e3063cc89537..1adb80dc8d9eef 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_from_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_from_star.py.snap @@ -254,7 +254,7 @@ Module( 6 | from ..module import * 7 | def f3(): 8 | from module import *, * - | ^^^^ Syntax Error: Star import must be the only import + | ^^^^ Syntax Error: star import must be the only import ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_empty.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_empty.py.snap index a2986b03b85202..762ae895f76d30 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_empty.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_empty.py.snap @@ -27,4 +27,4 @@ Module( | 1 | import - | ^ Syntax Error: Expected one or more symbol names after import + | ^ Syntax Error: Expected one or more names after 'import' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap index d3512f493acb9f..0f3c9508589952 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap @@ -82,7 +82,7 @@ Module( | 1 | import (a) - | ^ Syntax Error: Expected one or more symbol names after import + | ^ Syntax Error: Expected one or more names after 'import' 2 | import (a, b) | @@ -90,4 +90,4 @@ Module( | 1 | import (a) 2 | import (a, b) - | ^ Syntax Error: Expected one or more symbol names after import + | ^ Syntax Error: Expected one or more names after 'import' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_star_import.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_star_import.py.snap index 449b7354d91f15..fc9b40dc0bf737 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_star_import.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_star_import.py.snap @@ -107,14 +107,14 @@ Module( | 1 | import * - | ^ Syntax Error: Expected one or more symbol names after import + | ^ Syntax Error: Expected one or more names after 'import' 2 | import x, *, y | | 1 | import * - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | import x, *, y | @@ -122,16 +122,16 @@ Module( | 1 | import * 2 | import x, *, y - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses | 1 | import * 2 | import x, *, y - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax | 1 | import * 2 | import x, *, y - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_trailing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_trailing_comma.py.snap index 98464ff72d7cde..f95221b8e9f245 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_trailing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_trailing_comma.py.snap @@ -56,14 +56,14 @@ Module( | 1 | import , - | ^ Syntax Error: Expected an import name + | ^ Syntax Error: invalid syntax 2 | import x, y, | | 1 | import , - | ^ Syntax Error: Expected one or more symbol names after import + | ^ Syntax Error: Expected one or more names after 'import' 2 | import x, y, | @@ -71,4 +71,4 @@ Module( | 1 | import , 2 | import x, y, - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@incomplete_attribute_before_for_in_delimiter.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@incomplete_attribute_before_for_in_delimiter.py.snap index 6525227c6105fc..dfa2d7347dd560 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@incomplete_attribute_before_for_in_delimiter.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@incomplete_attribute_before_for_in_delimiter.py.snap @@ -364,7 +364,7 @@ Module( | 1 | [item. for item in xs] - | ^^^ Syntax Error: Expected an identifier + | ^^^ Syntax Error: invalid syntax 2 | [item. async for item in xs] 3 | {item. for item in xs} | @@ -373,7 +373,7 @@ Module( | 1 | [item. for item in xs] 2 | [item. async for item in xs] - | ^^^^^ Syntax Error: Expected an identifier + | ^^^^^ Syntax Error: invalid syntax 3 | {item. for item in xs} 4 | (item. for item in xs) | @@ -383,7 +383,7 @@ Module( 1 | [item. for item in xs] 2 | [item. async for item in xs] 3 | {item. for item in xs} - | ^^^ Syntax Error: Expected an identifier + | ^^^ Syntax Error: invalid syntax 4 | (item. for item in xs) 5 | [item for item. in xs] | @@ -393,7 +393,7 @@ Module( 2 | [item. async for item in xs] 3 | {item. for item in xs} 4 | (item. for item in xs) - | ^^^ Syntax Error: Expected an identifier + | ^^^ Syntax Error: invalid syntax 5 | [item for item. in xs] 6 | for item. in xs: ... | @@ -403,7 +403,7 @@ Module( 3 | {item. for item in xs} 4 | (item. for item in xs) 5 | [item for item. in xs] - | ^^ Syntax Error: Expected an identifier + | ^^ Syntax Error: invalid syntax 6 | for item. in xs: ... | @@ -412,4 +412,4 @@ Module( 4 | (item. for item in xs) 5 | [item for item. in xs] 6 | for item. in xs: ... - | ^^ Syntax Error: Expected an identifier + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap index 37661615d93b8e..649c79fccae3a0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap @@ -232,7 +232,7 @@ Module( | 1 | del x + 1 - | ^^^^^ Syntax Error: Invalid delete target + | ^^^^^ Syntax Error: invalid syntax 2 | del {'x': 1} 3 | del {'x', 'y'} | @@ -241,7 +241,7 @@ Module( | 1 | del x + 1 2 | del {'x': 1} - | ^^^^^^^^ Syntax Error: Invalid delete target + | ^^^^^^^^ Syntax Error: invalid syntax 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" | @@ -251,7 +251,7 @@ Module( 1 | del x + 1 2 | del {'x': 1} 3 | del {'x', 'y'} - | ^^^^^^^^^^ Syntax Error: Invalid delete target + | ^^^^^^^^^^ Syntax Error: invalid syntax 4 | del None, True, False, 1, 1.0, "abc" | @@ -260,39 +260,39 @@ Module( 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^^ Syntax Error: Invalid delete target + | ^^^^ Syntax Error: invalid syntax | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^^ Syntax Error: Invalid delete target + | ^^^^ Syntax Error: invalid syntax | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^^^ Syntax Error: Invalid delete target + | ^^^^^ Syntax Error: invalid syntax | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^ Syntax Error: Invalid delete target + | ^ Syntax Error: invalid syntax | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^ Syntax Error: Invalid delete target + | ^^^ Syntax Error: invalid syntax | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^^^ Syntax Error: Invalid delete target + | ^^^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap index 1169358a32b9ba..1f84f46254248e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap @@ -93,7 +93,7 @@ Module( | 1 | f'hello \N{INVALID} world' - | ^^^^^^^ Syntax Error: Got unexpected unicode + | ^^^^^^^ Syntax Error: got unexpected unicode 2 | f"""hello \N{INVALID} world""" | @@ -101,4 +101,4 @@ Module( | 1 | f'hello \N{INVALID} world' 2 | f"""hello \N{INVALID} world""" - | ^^^^^^^ Syntax Error: Got unexpected unicode + | ^^^^^^^ Syntax Error: got unexpected unicode diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap index 7dadbed0e24cd7..dc18f67d032396 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap @@ -73,7 +73,7 @@ Module( | 1 | 'hello \N{INVALID} world' - | ^^^^^^^ Syntax Error: Got unexpected unicode + | ^^^^^^^ Syntax Error: got unexpected unicode 2 | """hello \N{INVALID} world""" | @@ -81,4 +81,4 @@ Module( | 1 | 'hello \N{INVALID} world' 2 | """hello \N{INVALID} world""" - | ^^^^^^^ Syntax Error: Got unexpected unicode + | ^^^^^^^ Syntax Error: got unexpected unicode diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap index 8bbfab3a506cb3..f650fd0569b089 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap @@ -67,7 +67,7 @@ Module( | 1 | # parse_options: {"mode": "ipython"} 2 | with (a, ?b) - | ^ Syntax Error: Expected `,`, found `?` + | ^ Syntax Error: invalid syntax 3 | ? | @@ -75,7 +75,7 @@ Module( | 1 | # parse_options: {"mode": "ipython"} 2 | with (a, ?b) - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 3 | ? | @@ -84,4 +84,4 @@ Module( 1 | # parse_options: {"mode": "ipython"} 2 | with (a, ?b) 3 | ? - | ^ Syntax Error: Expected an indented block after `with` statement + | ^ Syntax Error: expected an indented block after `with` statement diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap index a0af89f0ce14f9..386b42c81c9e9b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap @@ -65,7 +65,7 @@ Module( | 1 | # parse_options: {"mode": "ipython"} 2 | with (a, ?b - | ^ Syntax Error: Expected an expression or a ')' + | ^ Syntax Error: invalid syntax 3 | ? | @@ -74,7 +74,7 @@ Module( 1 | # parse_options: {"mode": "ipython"} 2 | with (a, ?b 3 | ? - | ^ Syntax Error: Expected `,`, found `?` + | ^ Syntax Error: invalid syntax | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap index f29cf1cb4b7f4e..3b5a584394e33f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap @@ -95,7 +95,7 @@ Module( | 1 | # parse_options: {"mode": "ipython"} 2 | with a, ?b - | ^ Syntax Error: Expected `,`, found `?` + | ^ Syntax Error: invalid syntax 3 | ? 4 | x = 1 | @@ -104,7 +104,7 @@ Module( | 1 | # parse_options: {"mode": "ipython"} 2 | with a, ?b - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 3 | ? 4 | x = 1 | @@ -114,6 +114,6 @@ Module( 1 | # parse_options: {"mode": "ipython"} 2 | with a, ?b 3 | ? - | ^ Syntax Error: Expected an indented block after `with` statement + | ^ Syntax Error: expected an indented block after `with` statement 4 | x = 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_return_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_return_py37.py.snap index e520c2776ce8a0..7d17ee5320c98a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_return_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_return_py37.py.snap @@ -170,4 +170,4 @@ Module( 1 | # parse_options: {"target-version": "3.7"} 2 | rest = (4, 5, 6) 3 | def f(): return 1, 2, 3, *rest - | ^^^^^ Syntax Error: Cannot use iterable unpacking in return statements on Python 3.7 (syntax was added in Python 3.8) + | ^^^^^ Syntax Error: cannot use iterable unpacking in return statements on Python 3.7 (syntax was added in Python 3.8) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_yield_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_yield_py37.py.snap index 2d2bc7bf1078b9..4a776913163f67 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_yield_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@iter_unpack_yield_py37.py.snap @@ -293,7 +293,7 @@ Module( 1 | # parse_options: {"target-version": "3.7"} 2 | rest = (4, 5, 6) 3 | def g(): yield 1, 2, 3, *rest - | ^^^^^ Syntax Error: Cannot use iterable unpacking in yield expressions on Python 3.7 (syntax was added in Python 3.8) + | ^^^^^ Syntax Error: cannot use iterable unpacking in yield expressions on Python 3.7 (syntax was added in Python 3.8) 4 | def h(): yield 1, (yield 2, *rest), 3 | @@ -302,4 +302,4 @@ Module( 2 | rest = (4, 5, 6) 3 | def g(): yield 1, 2, 3, *rest 4 | def h(): yield 1, (yield 2, *rest), 3 - | ^^^^^ Syntax Error: Cannot use iterable unpacking in yield expressions on Python 3.7 (syntax was added in Python 3.8) + | ^^^^^ Syntax Error: cannot use iterable unpacking in yield expressions on Python 3.7 (syntax was added in Python 3.8) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap index d2ae6b53889d23..fcdfca36d60b08 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap @@ -295,7 +295,7 @@ Module( | 1 | lambda x: *y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | lambda x: *y, 3 | lambda x: *y, z | @@ -304,7 +304,7 @@ Module( | 1 | lambda x: *y 2 | lambda x: *y, - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 3 | lambda x: *y, z 4 | lambda x: *y and z | @@ -314,7 +314,7 @@ Module( 1 | lambda x: *y 2 | lambda x: *y, 3 | lambda x: *y, z - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 4 | lambda x: *y and z | @@ -323,4 +323,4 @@ Module( 2 | lambda x: *y, 3 | lambda x: *y, z 4 | lambda x: *y and z - | ^^^^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_yield_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_yield_expr.py.snap index 6b3908dd8e925c..ecd8e8f7f1d6be 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_yield_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_yield_expr.py.snap @@ -133,7 +133,7 @@ Module( | 1 | lambda x: yield y - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 2 | lambda x: yield from y | @@ -141,4 +141,4 @@ Module( | 1 | lambda x: yield y 2 | lambda x: yield from y - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_stmt_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_stmt_py314.py.snap index 19f0052bca8cd3..7cdcee58bdb782 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_stmt_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lazy_import_stmt_py314.py.snap @@ -67,7 +67,7 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | lazy import foo - | ^^^^ Syntax Error: Cannot use `lazy` import statement on Python 3.14 (syntax was added in Python 3.15) + | ^^^^ Syntax Error: cannot use `lazy` import statement on Python 3.14 (syntax was added in Python 3.15) 3 | lazy from bar import baz | @@ -76,4 +76,4 @@ Module( 1 | # parse_options: {"target-version": "3.14"} 2 | lazy import foo 3 | lazy from bar import baz - | ^^^^ Syntax Error: Cannot use `lazy` import statement on Python 3.14 (syntax was added in Python 3.15) + | ^^^^ Syntax Error: cannot use `lazy` import statement on Python 3.14 (syntax was added in Python 3.15) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_before_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_before_py310.py.snap index 5b99c1ef55771e..dae32f107c7f93 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_before_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_before_py310.py.snap @@ -66,7 +66,7 @@ Module( | 1 | # parse_options: { "target-version": "3.9" } 2 | match 2: - | ^^^^^ Syntax Error: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10) + | ^^^^^ Syntax Error: cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10) 3 | case 1: 4 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword.py.snap index 4d6cc7a2164066..8bec3616191199 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword.py.snap @@ -71,6 +71,6 @@ Module( | 1 | match yield foo: - | ^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^ Syntax Error: yield expression cannot be used here 2 | case _: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap index 19cfcc59502d34..53cf09d4ca7e7c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap @@ -70,6 +70,6 @@ Module( | 1 | match *foo: # Keyword - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | case _: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_expected_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_expected_colon.py.snap index a5de0429cd3b10..b4035d9ad8c9b1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_expected_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_expected_colon.py.snap @@ -83,6 +83,6 @@ Module( | 1 | match [1, 2] - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 2 | case _: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap index 224a2f0eb0422e..3fdfdf868feb5c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap @@ -64,10 +64,10 @@ Module( | 1 | match foo: 2 | case _: ... - | ^^^^ Syntax Error: Expected an indented block after `match` statement + | ^^^^ Syntax Error: expected an indented block after `match` statement | 1 | match foo: 2 | case _: ... - | ^ Syntax Error: Expected dedent, found end of file + | ^ Syntax Error: invalid syntax 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 b703e2a0e47139..2d66f74d2e052f 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 @@ -122,7 +122,7 @@ Module( | 1 | match x: 2 | x = 1 - | ^ Syntax Error: Expected `case` block + | ^ Syntax Error: expected `case` block 3 | match x: 4 | match y: | @@ -132,7 +132,7 @@ Module( 1 | match x: 2 | x = 1 3 | match x: - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 4 | match y: 5 | case _: ... | @@ -142,7 +142,7 @@ Module( 2 | x = 1 3 | match x: 4 | match y: - | ^^^^^ Syntax Error: Expected `case` block + | ^^^^^ Syntax Error: expected `case` block 5 | case _: ... | @@ -150,4 +150,4 @@ Module( | 4 | match y: 5 | case _: ... - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap index 4c95faa939993f..0f2c38a45efe19 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap @@ -219,7 +219,7 @@ Module( | 1 | match x: 2 | case y if *a: ... - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 3 | match x: 4 | case y if (*a): ... | @@ -229,7 +229,7 @@ Module( 2 | case y if *a: ... 3 | match x: 4 | case y if (*a): ... - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 5 | match x: 6 | case y if yield x: ... | @@ -239,4 +239,4 @@ Module( 4 | case y if (*a): ... 5 | match x: 6 | case y if yield x: ... - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap index 4bcf6b2ae0f521..9714589315d3b3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap @@ -210,7 +210,7 @@ Module( | 1 | match (*x): - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | case _: ... 3 | # Starred expression precedence test | @@ -220,7 +220,7 @@ Module( 2 | case _: ... 3 | # Starred expression precedence test 4 | match *x and y, z: - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 5 | case _: ... 6 | match yield x: | @@ -230,6 +230,6 @@ Module( 4 | match *x and y, z: 5 | case _: ... 6 | match yield x: - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 7 | case _: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_guard_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_guard_expr.py.snap index 1811e4ac029f3c..020e4440d06d45 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_guard_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_guard_expr.py.snap @@ -70,4 +70,4 @@ Module( | 1 | match x: 2 | case y if: ... - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_pattern.py.snap index 21ad0c756fccba..d4d1c3acb54164 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_missing_pattern.py.snap @@ -70,4 +70,4 @@ Module( | 1 | match x: 2 | case : ... - | ^ Syntax Error: Expected a pattern + | ^ Syntax Error: expected a pattern diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap index 351ea8f58f296f..e3a342e08aaaf9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_no_newline_before_case.py.snap @@ -63,9 +63,9 @@ Module( | 1 | match foo: case _: ... - | ^^^^ Syntax Error: Expected newline, found `case` + | ^^^^ Syntax Error: invalid syntax | 1 | match foo: case _: ... - | ^ Syntax Error: Expected dedent, found end of file + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap index 77e685967e0de9..f7713f4bded99c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap @@ -70,6 +70,6 @@ Module( | 1 | match *foo: - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | case _: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_bytes_and_non_bytes_literals.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_bytes_and_non_bytes_literals.py.snap index 684f44de2adb07..5109dddc7e06b8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_bytes_and_non_bytes_literals.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_bytes_and_non_bytes_literals.py.snap @@ -183,7 +183,7 @@ Module( | 1 | 'first' b'second' - | ^^^^^^^^^^^^^^^^^ Syntax Error: Bytes literal cannot be mixed with non-bytes literals + | ^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix bytes and nonbytes literals 2 | f'first' b'second' 3 | 'first' f'second' b'third' | @@ -192,7 +192,7 @@ Module( | 1 | 'first' b'second' 2 | f'first' b'second' - | ^^^^^^^^^^^^^^^^^^ Syntax Error: Bytes literal cannot be mixed with non-bytes literals + | ^^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix bytes and nonbytes literals 3 | 'first' f'second' b'third' | @@ -201,4 +201,4 @@ Module( 1 | 'first' b'second' 2 | f'first' b'second' 3 | 'first' f'second' b'third' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Bytes literal cannot be mixed with non-bytes literals + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix bytes and nonbytes literals diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_tstring_and_bytes_literals.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_tstring_and_bytes_literals.py.snap index 75cc2961841fa0..4a9920e29b517c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_tstring_and_bytes_literals.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@mixed_tstring_and_bytes_literals.py.snap @@ -414,7 +414,7 @@ Module( | 1 | t'first' b'second' - | ^^^^^^^^^^^^^^^^^^ Syntax Error: Cannot mix t-string literals with string or bytes literals + | ^^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix t-string literals with string or bytes literals 2 | b'first' t'second' 3 | t'first' br'second' | @@ -423,7 +423,7 @@ Module( | 1 | t'first' b'second' 2 | b'first' t'second' - | ^^^^^^^^^^^^^^^^^^ Syntax Error: Cannot mix t-string literals with string or bytes literals + | ^^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix t-string literals with string or bytes literals 3 | t'first' br'second' 4 | 'first' b'second' t'third' | @@ -433,7 +433,7 @@ Module( 1 | t'first' b'second' 2 | b'first' t'second' 3 | t'first' br'second' - | ^^^^^^^^^^^^^^^^^^^ Syntax Error: Cannot mix t-string literals with string or bytes literals + | ^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix t-string literals with string or bytes literals 4 | 'first' b'second' t'third' 5 | b'first' 'second' t'third' | @@ -443,7 +443,7 @@ Module( 2 | b'first' t'second' 3 | t'first' br'second' 4 | 'first' b'second' t'third' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Bytes literal cannot be mixed with non-bytes literals + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix bytes and nonbytes literals 5 | b'first' 'second' t'third' 6 | 'first' t'second' 'third' b'fourth' | @@ -453,7 +453,7 @@ Module( 3 | t'first' br'second' 4 | 'first' b'second' t'third' 5 | b'first' 'second' t'third' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Bytes literal cannot be mixed with non-bytes literals + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix bytes and nonbytes literals 6 | 'first' t'second' 'third' b'fourth' 7 | b'first' t'second' f'third' | @@ -463,7 +463,7 @@ Module( 4 | 'first' b'second' t'third' 5 | b'first' 'second' t'third' 6 | 'first' t'second' 'third' b'fourth' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Cannot mix t-string literals with string or bytes literals + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix t-string literals with string or bytes literals 7 | b'first' t'second' f'third' | @@ -472,4 +472,4 @@ Module( 5 | b'first' 'second' t'third' 6 | 'first' t'second' 'third' b'fourth' 7 | b'first' t'second' f'third' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Cannot mix t-string literals with string or bytes literals + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot mix t-string literals with string or bytes literals diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_clauses_on_same_line.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_clauses_on_same_line.py.snap index cfbcd7ca1904ed..0003eb96161b45 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_clauses_on_same_line.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@multiple_clauses_on_same_line.py.snap @@ -355,7 +355,7 @@ Module( | 1 | if True: pass elif False: pass else: pass - | ^^^^ Syntax Error: Expected newline, found `elif` + | ^^^^ Syntax Error: invalid syntax 2 | if True: pass; elif False: pass; else: pass 3 | for x in iter: break else: pass | @@ -363,7 +363,7 @@ Module( | 1 | if True: pass elif False: pass else: pass - | ^^^^ Syntax Error: Expected newline, found `else` + | ^^^^ Syntax Error: invalid syntax 2 | if True: pass; elif False: pass; else: pass 3 | for x in iter: break else: pass | @@ -372,7 +372,7 @@ Module( | 1 | if True: pass elif False: pass else: pass 2 | if True: pass; elif False: pass; else: pass - | ^^^^ Syntax Error: Expected newline, found `elif` + | ^^^^ Syntax Error: invalid syntax 3 | for x in iter: break else: pass 4 | for x in iter: break; else: pass | @@ -381,7 +381,7 @@ Module( | 1 | if True: pass elif False: pass else: pass 2 | if True: pass; elif False: pass; else: pass - | ^^^^ Syntax Error: Expected newline, found `else` + | ^^^^ Syntax Error: invalid syntax 3 | for x in iter: break else: pass 4 | for x in iter: break; else: pass | @@ -391,7 +391,7 @@ Module( 1 | if True: pass elif False: pass else: pass 2 | if True: pass; elif False: pass; else: pass 3 | for x in iter: break else: pass - | ^^^^ Syntax Error: Expected newline, found `else` + | ^^^^ Syntax Error: invalid syntax 4 | for x in iter: break; else: pass 5 | try: pass except exc: pass else: pass finally: pass | @@ -401,7 +401,7 @@ Module( 2 | if True: pass; elif False: pass; else: pass 3 | for x in iter: break else: pass 4 | for x in iter: break; else: pass - | ^^^^ Syntax Error: Expected newline, found `else` + | ^^^^ Syntax Error: invalid syntax 5 | try: pass except exc: pass else: pass finally: pass 6 | try: pass; except exc: pass; else: pass; finally: pass | @@ -411,7 +411,7 @@ Module( 3 | for x in iter: break else: pass 4 | for x in iter: break; else: pass 5 | try: pass except exc: pass else: pass finally: pass - | ^^^^^^ Syntax Error: Expected newline, found `except` + | ^^^^^^ Syntax Error: invalid syntax 6 | try: pass; except exc: pass; else: pass; finally: pass | @@ -420,7 +420,7 @@ Module( 3 | for x in iter: break else: pass 4 | for x in iter: break; else: pass 5 | try: pass except exc: pass else: pass finally: pass - | ^^^^ Syntax Error: Expected newline, found `else` + | ^^^^ Syntax Error: invalid syntax 6 | try: pass; except exc: pass; else: pass; finally: pass | @@ -429,7 +429,7 @@ Module( 3 | for x in iter: break else: pass 4 | for x in iter: break; else: pass 5 | try: pass except exc: pass else: pass finally: pass - | ^^^^^^^ Syntax Error: Expected newline, found `finally` + | ^^^^^^^ Syntax Error: invalid syntax 6 | try: pass; except exc: pass; else: pass; finally: pass | @@ -438,18 +438,18 @@ Module( 4 | for x in iter: break; else: pass 5 | try: pass except exc: pass else: pass finally: pass 6 | try: pass; except exc: pass; else: pass; finally: pass - | ^^^^^^ Syntax Error: Expected newline, found `except` + | ^^^^^^ Syntax Error: invalid syntax | 4 | for x in iter: break; else: pass 5 | try: pass except exc: pass else: pass finally: pass 6 | try: pass; except exc: pass; else: pass; finally: pass - | ^^^^ Syntax Error: Expected newline, found `else` + | ^^^^ Syntax Error: invalid syntax | 4 | for x in iter: break; else: pass 5 | try: pass except exc: pass else: pass finally: pass 6 | try: pass; except exc: pass; else: pass; finally: pass - | ^^^^^^^ Syntax Error: Expected newline, found `finally` + | ^^^^^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap index 857c1506f2a379..b2b17a32922c35 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap @@ -229,7 +229,7 @@ Module( | 1 | # even after 3.9, an unparenthesized named expression is not allowed in a slice 2 | lst[x:=1:-1] - | ^^^^ Syntax Error: Unparenthesized named expression cannot be used here + | ^^^^ Syntax Error: unparenthesized named expression cannot be used here 3 | lst[1:x:=1] 4 | lst[1:3:x:=1] | @@ -239,7 +239,7 @@ Module( 1 | # even after 3.9, an unparenthesized named expression is not allowed in a slice 2 | lst[x:=1:-1] 3 | lst[1:x:=1] - | ^^ Syntax Error: Expected `]`, found `:=` + | ^^ Syntax Error: invalid syntax 4 | lst[1:3:x:=1] | @@ -248,7 +248,7 @@ Module( 1 | # even after 3.9, an unparenthesized named expression is not allowed in a slice 2 | lst[x:=1:-1] 3 | lst[1:x:=1] - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 4 | lst[1:3:x:=1] | @@ -257,7 +257,7 @@ Module( 1 | # even after 3.9, an unparenthesized named expression is not allowed in a slice 2 | lst[x:=1:-1] 3 | lst[1:x:=1] - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 4 | lst[1:3:x:=1] | @@ -266,18 +266,18 @@ Module( 2 | lst[x:=1:-1] 3 | lst[1:x:=1] 4 | lst[1:3:x:=1] - | ^^ Syntax Error: Expected `]`, found `:=` + | ^^ Syntax Error: invalid syntax | 2 | lst[x:=1:-1] 3 | lst[1:x:=1] 4 | lst[1:3:x:=1] - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax | 2 | lst[x:=1:-1] 3 | lst[1:x:=1] 4 | lst[1:3:x:=1] - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice_parse_error.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice_parse_error.py.snap index ee314ad800c151..c0b8ff79392860 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice_parse_error.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice_parse_error.py.snap @@ -92,4 +92,4 @@ Module( 1 | # parse_options: {"target-version": "3.8"} 2 | # before 3.9, only emit the parse error, not the unsupported syntax error 3 | lst[x:=1:-1] - | ^^^^ Syntax Error: Unparenthesized named expression cannot be used here + | ^^^^ Syntax Error: unparenthesized named expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap index 10a79a047d5b7b..ae067fe019c94b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap @@ -94,4 +94,4 @@ Module( | 1 | # parse_options: {"target-version": "3.12"} 2 | f"{1:""}" # this is a ParseError on all versions - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap index 2b0126feb98d0b..5aa49c618ce1c8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@node_range_with_gaps.py.snap @@ -122,7 +122,7 @@ Module( | 1 | def foo # comment - | ^ Syntax Error: Expected `(`, found newline + | ^ Syntax Error: expected '(' 2 | def bar(): ... 3 | def baz | @@ -131,7 +131,7 @@ Module( | 1 | def foo # comment 2 | def bar(): ... - | ^^^ Syntax Error: Expected `)`, found `def` + | ^^^ Syntax Error: invalid syntax 3 | def baz | @@ -140,10 +140,10 @@ Module( 1 | def foo # comment 2 | def bar(): ... 3 | def baz - | ^ Syntax Error: Expected `(`, found newline + | ^ Syntax Error: expected '(' | 2 | def bar(): ... 3 | def baz - | ^ Syntax Error: Expected `)`, found end of file + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_empty.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_empty.py.snap index e84c7c699b9e7a..de44a0abd06f73 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_empty.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_empty.py.snap @@ -58,4 +58,4 @@ Module( | 1 | def _(): 2 | nonlocal - | ^ Syntax Error: Nonlocal statement must have at least one name + | ^ Syntax Error: nonlocal statement must have at least one name diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_expression.py.snap index f86a3f496439bc..c449eb3ce5c1c8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_expression.py.snap @@ -86,4 +86,4 @@ Module( | 1 | def _(): 2 | nonlocal x + 1 - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_trailing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_trailing_comma.py.snap index 5c1d8eb4ee1c66..88bb13b4bff45d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_trailing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nonlocal_stmt_trailing_comma.py.snap @@ -89,7 +89,7 @@ Module( | 1 | def _(): 2 | nonlocal , - | ^ Syntax Error: Expected an identifier + | ^ Syntax Error: invalid syntax 3 | nonlocal x, 4 | nonlocal x, y, | @@ -98,7 +98,7 @@ Module( | 1 | def _(): 2 | nonlocal , - | ^ Syntax Error: Nonlocal statement must have at least one name + | ^ Syntax Error: nonlocal statement must have at least one name 3 | nonlocal x, 4 | nonlocal x, y, | @@ -108,7 +108,7 @@ Module( 1 | def _(): 2 | nonlocal , 3 | nonlocal x, - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses 4 | nonlocal x, y, | @@ -117,4 +117,4 @@ Module( 2 | nonlocal , 3 | nonlocal x, 4 | nonlocal x, y, - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_annotation.py.snap index aac0e2c33b0463..4ff3ddd45f9b2c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_annotation.py.snap @@ -141,7 +141,7 @@ Module( | 1 | def foo(x:): ... - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | def foo(x:,): ... | @@ -149,4 +149,4 @@ Module( | 1 | def foo(x:): ... 2 | def foo(x:,): ... - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap index 9d9f1f2f783ed6..c61c0414417458 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap @@ -150,7 +150,7 @@ Module( | 1 | def foo(x=): ... - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | def foo(x: int = ): ... | @@ -158,4 +158,4 @@ Module( | 1 | def foo(x=): ... 2 | def foo(x: int = ): ... - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap index ecb74d5dd83b7d..3d20ac065f164d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap @@ -261,7 +261,7 @@ Module( | 1 | def foo(arg: *int): ... - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | def foo(arg: yield int): ... 3 | def foo(arg: x := int): ... | @@ -270,7 +270,7 @@ Module( | 1 | def foo(arg: *int): ... 2 | def foo(arg: yield int): ... - | ^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^ Syntax Error: yield expression cannot be used here 3 | def foo(arg: x := int): ... | @@ -279,7 +279,7 @@ Module( 1 | def foo(arg: *int): ... 2 | def foo(arg: yield int): ... 3 | def foo(arg: x := int): ... - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap index d75d2635ba3eb0..48c82f18ecc37b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap @@ -251,7 +251,7 @@ Module( | 1 | def foo(x=*int): ... - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | def foo(x=(*int)): ... 3 | def foo(x=yield y): ... | @@ -260,7 +260,7 @@ Module( | 1 | def foo(x=*int): ... 2 | def foo(x=(*int)): ... - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 3 | def foo(x=yield y): ... | @@ -269,4 +269,4 @@ Module( 1 | def foo(x=*int): ... 2 | def foo(x=(*int)): ... 3 | def foo(x=yield y): ... - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap index 5f936bc6da220e..b4766118cb5456 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap @@ -348,7 +348,7 @@ Module( | 1 | def foo(*args: *): ... - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | def foo(*args: (*tuple[int])): ... 3 | def foo(*args: *int or str): ... | @@ -357,7 +357,7 @@ Module( | 1 | def foo(*args: *): ... 2 | def foo(*args: (*tuple[int])): ... - | ^^^^^^^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: invalid syntax 3 | def foo(*args: *int or str): ... 4 | def foo(*args: *yield x): ... | @@ -367,7 +367,7 @@ Module( 1 | def foo(*args: *): ... 2 | def foo(*args: (*tuple[int])): ... 3 | def foo(*args: *int or str): ... - | ^^^^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^^^^ Syntax Error: boolean expression cannot be used here 4 | def foo(*args: *yield x): ... 5 | # def foo(*args: **int): ... | @@ -377,7 +377,7 @@ Module( 2 | def foo(*args: (*tuple[int])): ... 3 | def foo(*args: *int or str): ... 4 | def foo(*args: *yield x): ... - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 5 | # def foo(*args: **int): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_star_annotation_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_star_annotation_py310.py.snap index 353def8ade66ab..89f32aab782a4d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_star_annotation_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_star_annotation_py310.py.snap @@ -92,4 +92,4 @@ Module( | 1 | # parse_options: {"target-version": "3.10"} 2 | def foo(*args: *Ts): ... - | ^^^ Syntax Error: Cannot use star annotation on Python 3.10 (syntax was added in Python 3.11) + | ^^^ Syntax Error: cannot use star annotation on Python 3.10 (syntax was added in Python 3.11) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap index 8d801462efec94..042452802cbe58 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap @@ -283,7 +283,7 @@ Module( | 1 | def foo(*): ... - | ^ Syntax Error: Expected one or more keyword parameter after `*` separator + | ^ Syntax Error: named arguments must follow bare * 2 | def foo(*,): ... 3 | def foo(a, *): ... | @@ -292,7 +292,7 @@ Module( | 1 | def foo(*): ... 2 | def foo(*,): ... - | ^ Syntax Error: Expected one or more keyword parameter after `*` separator + | ^ Syntax Error: named arguments must follow bare * 3 | def foo(a, *): ... 4 | def foo(a, *,): ... | @@ -302,7 +302,7 @@ Module( 1 | def foo(*): ... 2 | def foo(*,): ... 3 | def foo(a, *): ... - | ^ Syntax Error: Expected one or more keyword parameter after `*` separator + | ^ Syntax Error: named arguments must follow bare * 4 | def foo(a, *,): ... 5 | def foo(*, **kwargs): ... | @@ -312,7 +312,7 @@ Module( 2 | def foo(*,): ... 3 | def foo(a, *): ... 4 | def foo(a, *,): ... - | ^ Syntax Error: Expected one or more keyword parameter after `*` separator + | ^ Syntax Error: named arguments must follow bare * 5 | def foo(*, **kwargs): ... | @@ -321,4 +321,4 @@ Module( 3 | def foo(a, *): ... 4 | def foo(a, *,): ... 5 | def foo(*, **kwargs): ... - | ^^^^^^^^ Syntax Error: Expected one or more keyword parameter after `*` separator + | ^^^^^^^^ Syntax Error: named arguments must follow bare * diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_follows_var_keyword_param.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_follows_var_keyword_param.py.snap index b3e3d9cea03afc..1de5be6107bdde 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_follows_var_keyword_param.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_follows_var_keyword_param.py.snap @@ -134,24 +134,24 @@ Module( | 1 | def foo(**kwargs, a, /, b=10, *, *args): ... - | ^ Syntax Error: Parameter cannot follow var-keyword parameter + | ^ Syntax Error: arguments cannot follow var-keyword argument | 1 | def foo(**kwargs, a, /, b=10, *, *args): ... - | ^ Syntax Error: Parameter cannot follow var-keyword parameter + | ^ Syntax Error: arguments cannot follow var-keyword argument | 1 | def foo(**kwargs, a, /, b=10, *, *args): ... - | ^ Syntax Error: Parameter cannot follow var-keyword parameter + | ^ Syntax Error: arguments cannot follow var-keyword argument | 1 | def foo(**kwargs, a, /, b=10, *, *args): ... - | ^ Syntax Error: Parameter cannot follow var-keyword parameter + | ^ Syntax Error: arguments cannot follow var-keyword argument | 1 | def foo(**kwargs, a, /, b=10, *, *args): ... - | ^ Syntax Error: Parameter cannot follow var-keyword parameter + | ^ Syntax Error: arguments cannot follow var-keyword argument diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap index 5f34b03a915a10..c7da40158fd6b5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap @@ -75,4 +75,4 @@ Module( | 1 | def foo(*, **kwargs): ... - | ^^^^^^^^ Syntax Error: Expected one or more keyword parameter after `*` separator + | ^^^^^^^^ Syntax Error: named arguments must follow bare * diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_kwargs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_kwargs.py.snap index dade5a383d2377..0e368d1126d174 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_kwargs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_kwargs.py.snap @@ -93,4 +93,4 @@ Module( | 1 | def foo(a, **kwargs1, **kwargs2): ... - | ^^ Syntax Error: Parameter cannot follow var-keyword parameter + | ^^ Syntax Error: arguments cannot follow var-keyword argument diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_slash_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_slash_separator.py.snap index b9f8edb1f52574..9b080f60afcfdd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_slash_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_slash_separator.py.snap @@ -194,7 +194,7 @@ Module( | 1 | def foo(a, /, /, b): ... - | ^ Syntax Error: Only one '/' separator allowed + | ^ Syntax Error: / may appear only once 2 | def foo(a, /, b, c, /): ... | @@ -202,4 +202,4 @@ Module( | 1 | def foo(a, /, /, b): ... 2 | def foo(a, /, b, c, /): ... - | ^ Syntax Error: Only one '/' separator allowed + | ^ Syntax Error: / may appear only once diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap index 82329a8d652109..8e14cf8368bd46 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap @@ -194,7 +194,7 @@ Module( | 1 | def foo(a, *, *, b): ... - | ^ Syntax Error: Only one '*' separator allowed + | ^ Syntax Error: only one '*' separator allowed 2 | def foo(a, *, b, c, *): ... | @@ -202,4 +202,4 @@ Module( | 1 | def foo(a, *, *, b): ... 2 | def foo(a, *, b, c, *): ... - | ^ Syntax Error: Only one '*' separator allowed + | ^ Syntax Error: only one '*' separator allowed diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap index 900fd154b06a78..18e892330561d5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap @@ -312,7 +312,7 @@ Module( | 1 | def foo(a, *, *args, b): ... - | ^^^^^ Syntax Error: Only one '*' parameter allowed + | ^^^^^ Syntax Error: * argument may appear only once 2 | # def foo(a, *, b, c, *args): ... 3 | def foo(a, *args1, *args2, b): ... | @@ -322,7 +322,7 @@ Module( 1 | def foo(a, *, *args, b): ... 2 | # def foo(a, *, b, c, *args): ... 3 | def foo(a, *args1, *args2, b): ... - | ^^^^^^ Syntax Error: Only one '*' parameter allowed + | ^^^^^^ Syntax Error: * argument may appear only once 4 | def foo(a, *args1, b, c, *args2): ... | @@ -331,4 +331,4 @@ Module( 2 | # def foo(a, *, b, c, *args): ... 3 | def foo(a, *args1, *args2, b): ... 4 | def foo(a, *args1, b, c, *args2): ... - | ^^^^^^ Syntax Error: Only one '*' parameter allowed + | ^^^^^^ Syntax Error: * argument may appear only once diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_no_arg_before_slash.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_no_arg_before_slash.py.snap index a0f59c4fd8ca9c..f7fa1f1799244a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_no_arg_before_slash.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_no_arg_before_slash.py.snap @@ -123,7 +123,7 @@ Module( | 1 | def foo(/): ... - | ^ Syntax Error: Position-only parameter separator not allowed as first parameter + | ^ Syntax Error: at least one argument must precede / 2 | def foo(/, a): ... | @@ -131,4 +131,4 @@ Module( | 1 | def foo(/): ... 2 | def foo(/, a): ... - | ^ Syntax Error: Position-only parameter separator not allowed as first parameter + | ^ Syntax Error: at least one argument must precede / diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_non_default_after_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_non_default_after_default.py.snap index 78d1c46a7121ec..e86291262e9b18 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_non_default_after_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_non_default_after_default.py.snap @@ -133,9 +133,9 @@ Module( | 1 | def foo(a=10, b, c: int): ... - | ^ Syntax Error: Parameter without a default cannot follow a parameter with a default + | ^ Syntax Error: parameter without a default follows parameter with a default | 1 | def foo(a=10, b, c: int): ... - | ^^^^^^ Syntax Error: Parameter without a default cannot follow a parameter with a default + | ^^^^^^ Syntax Error: parameter without a default follows parameter with a default diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash.py.snap index 44244c86bd7043..4409c593451df8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash.py.snap @@ -359,7 +359,7 @@ Module( | 1 | def foo(*a, /): ... - | ^ Syntax Error: '/' parameter must appear before '*' parameter + | ^ Syntax Error: / must be ahead of * 2 | def foo(a, *args, b, /): ... 3 | def foo(a, *, /, b): ... | @@ -368,7 +368,7 @@ Module( | 1 | def foo(*a, /): ... 2 | def foo(a, *args, b, /): ... - | ^ Syntax Error: '/' parameter must appear before '*' parameter + | ^ Syntax Error: / must be ahead of * 3 | def foo(a, *, /, b): ... 4 | def foo(a, *, b, c, /, d): ... | @@ -378,7 +378,7 @@ Module( 1 | def foo(*a, /): ... 2 | def foo(a, *args, b, /): ... 3 | def foo(a, *, /, b): ... - | ^ Syntax Error: '/' parameter must appear before '*' parameter + | ^ Syntax Error: / must be ahead of * 4 | def foo(a, *, b, c, /, d): ... | @@ -387,4 +387,4 @@ Module( 2 | def foo(a, *args, b, /): ... 3 | def foo(a, *, /, b): ... 4 | def foo(a, *, b, c, /, d): ... - | ^ Syntax Error: '/' parameter must appear before '*' parameter + | ^ Syntax Error: / must be ahead of * diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap index 0785b1d74cb745..f2595929b94341 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap @@ -220,7 +220,7 @@ Module( | 1 | def foo(a, *args, *, b): ... - | ^ Syntax Error: Keyword-only parameter separator not allowed after '*' parameter + | ^ Syntax Error: keyword-only parameter separator not allowed after '*' parameter 2 | def foo(a, *args, b, c, *): ... | @@ -228,4 +228,4 @@ Module( | 1 | def foo(a, *args, *, b): ... 2 | def foo(a, *args, b, c, *): ... - | ^ Syntax Error: Keyword-only parameter separator not allowed after '*' parameter + | ^ Syntax Error: keyword-only parameter separator not allowed after '*' parameter diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap index 6b3a911b9f407e..5db35c1ac1588a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap @@ -176,19 +176,19 @@ Module( | 1 | def foo(a, **kwargs={'b': 1, 'c': 2}): ... - | ^ Syntax Error: Parameter with `*` or `**` cannot have default value + | ^ Syntax Error: var-positional argument cannot have default value | 1 | def foo(a, **kwargs={'b': 1, 'c': 2}): ... - | ^ Syntax Error: Expected `)`, found `{` + | ^ Syntax Error: invalid syntax | 1 | def foo(a, **kwargs={'b': 1, 'c': 2}): ... - | ^ Syntax Error: Expected newline, found `)` + | ^ Syntax Error: invalid syntax | 1 | def foo(a, **kwargs={'b': 1, 'c': 2}): ... - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap index fb48e19b0faa52..7aafdcd9639327 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap @@ -128,19 +128,19 @@ Module( | 1 | def foo(a, *args=(1, 2)): ... - | ^ Syntax Error: Parameter with `*` or `**` cannot have default value + | ^ Syntax Error: var-positional argument cannot have default value | 1 | def foo(a, *args=(1, 2)): ... - | ^ Syntax Error: Expected `)`, found `(` + | ^ Syntax Error: invalid syntax | 1 | def foo(a, *args=(1, 2)): ... - | ^ Syntax Error: Expected newline, found `)` + | ^ Syntax Error: invalid syntax | 1 | def foo(a, *args=(1, 2)): ... - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_context_manager_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_context_manager_py38.py.snap index 8dd3613320e5be..5b0376b93d1206 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_context_manager_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_context_manager_py38.py.snap @@ -212,7 +212,7 @@ Module( | 1 | # parse_options: {"target-version": "3.8"} 2 | with (foo as x, bar as y): ... - | ^ Syntax Error: Cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) + | ^ Syntax Error: cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) 3 | with (foo, bar as y): ... 4 | with (foo as x, bar): ... | @@ -222,7 +222,7 @@ Module( 1 | # parse_options: {"target-version": "3.8"} 2 | with (foo as x, bar as y): ... 3 | with (foo, bar as y): ... - | ^ Syntax Error: Cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) + | ^ Syntax Error: cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) 4 | with (foo as x, bar): ... | @@ -231,4 +231,4 @@ Module( 2 | with (foo as x, bar as y): ... 3 | with (foo, bar as y): ... 4 | with (foo as x, bar): ... - | ^ Syntax Error: Cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) + | ^ Syntax Error: cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap index ee66a16af15c1d..37d650beb442f4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap @@ -167,7 +167,7 @@ Module( | 1 | # parse_options: {"target-version": "3.8"} 2 | f((a)=1) - | ^^^ Syntax Error: Cannot use parenthesized keyword argument name on Python 3.8 (syntax was removed in Python 3.8) + | ^^^ Syntax Error: cannot use parenthesized keyword argument name on Python 3.8 (syntax was removed in Python 3.8) 3 | f((a) = 1) 4 | f( ( a ) = 1) | @@ -177,7 +177,7 @@ Module( 1 | # parse_options: {"target-version": "3.8"} 2 | f((a)=1) 3 | f((a) = 1) - | ^^^ Syntax Error: Cannot use parenthesized keyword argument name on Python 3.8 (syntax was removed in Python 3.8) + | ^^^ Syntax Error: cannot use parenthesized keyword argument name on Python 3.8 (syntax was removed in Python 3.8) 4 | f( ( a ) = 1) | @@ -186,4 +186,4 @@ Module( 2 | f((a)=1) 3 | f((a) = 1) 4 | f( ( a ) = 1) - | ^^^^^ Syntax Error: Cannot use parenthesized keyword argument name on Python 3.8 (syntax was removed in Python 3.8) + | ^^^^^ Syntax Error: cannot use parenthesized keyword argument name on Python 3.8 (syntax was removed in Python 3.8) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_f_string_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_f_string_py311.py.snap index 46fd9495bab6d6..1b147d94ce408b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_f_string_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_f_string_py311.py.snap @@ -1012,7 +1012,7 @@ Module( | 1 | # parse_options: {"target-version": "3.11"} 2 | f'Magic wand: { bag['wand'] }' # nested quotes - | ^ Syntax Error: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) 3 | f"{'\n'.join(a)}" # escape sequence 4 | f'''A complex trick: { | @@ -1022,7 +1022,7 @@ Module( 1 | # parse_options: {"target-version": "3.11"} 2 | f'Magic wand: { bag['wand'] }' # nested quotes 3 | f"{'\n'.join(a)}" # escape sequence - | ^ Syntax Error: Cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) 4 | f'''A complex trick: { 5 | bag['bag'] # comment | @@ -1032,7 +1032,7 @@ Module( 3 | f"{'\n'.join(a)}" # escape sequence 4 | f'''A complex trick: { 5 | bag['bag'] # comment - | ^^^^^^^^^ Syntax Error: Cannot use comments in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^^^^^^^^^ Syntax Error: cannot use comments in f-strings on Python 3.11 (syntax was added in Python 3.12) 6 | }''' 7 | f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}" # arbitrary nesting | @@ -1042,7 +1042,7 @@ Module( 5 | bag['bag'] # comment 6 | }''' 7 | f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}" # arbitrary nesting - | ^ Syntax Error: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) 8 | f"{f'''{"nested"} inner'''} outer" # nested (triple) quotes 9 | f"{ | @@ -1052,7 +1052,7 @@ Module( 5 | bag['bag'] # comment 6 | }''' 7 | f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}" # arbitrary nesting - | ^ Syntax Error: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) 8 | f"{f'''{"nested"} inner'''} outer" # nested (triple) quotes 9 | f"{ | @@ -1062,7 +1062,7 @@ Module( 5 | bag['bag'] # comment 6 | }''' 7 | f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}" # arbitrary nesting - | ^ Syntax Error: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) 8 | f"{f'''{"nested"} inner'''} outer" # nested (triple) quotes 9 | f"{ | @@ -1072,7 +1072,7 @@ Module( 5 | bag['bag'] # comment 6 | }''' 7 | f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}" # arbitrary nesting - | ^ Syntax Error: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) 8 | f"{f'''{"nested"} inner'''} outer" # nested (triple) quotes 9 | f"{ | @@ -1082,7 +1082,7 @@ Module( 5 | bag['bag'] # comment 6 | }''' 7 | f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}" # arbitrary nesting - | ^ Syntax Error: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) 8 | f"{f'''{"nested"} inner'''} outer" # nested (triple) quotes 9 | f"{ | @@ -1092,7 +1092,7 @@ Module( 6 | }''' 7 | f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}" # arbitrary nesting 8 | f"{f'''{"nested"} inner'''} outer" # nested (triple) quotes - | ^ Syntax Error: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) 9 | f"{ 10 | 1 | @@ -1102,7 +1102,7 @@ Module( 7 | f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}" # arbitrary nesting 8 | f"{f'''{"nested"} inner'''} outer" # nested (triple) quotes 9 | f"{ - | ^ Syntax Error: Cannot use line breaks in non-triple-quoted f-string replacement fields on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot use line breaks in non-triple-quoted f-string replacement fields on Python 3.11 (syntax was added in Python 3.12) 10 | 1 11 | }" | @@ -1112,7 +1112,7 @@ Module( 10 | 1 11 | }" 12 | f"test {a \ - | ^ Syntax Error: Cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) 13 | } more" # line continuation 14 | f"""{f"""{x}"""}""" # mark the whole triple quote | @@ -1122,7 +1122,7 @@ Module( 12 | f"test {a \ 13 | } more" # line continuation 14 | f"""{f"""{x}"""}""" # mark the whole triple quote - | ^^^ Syntax Error: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^^^ Syntax Error: cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) 15 | f"{'\n'.join(['\t', '\v', '\r'])}" # multiple escape sequences, multiple errors | @@ -1131,25 +1131,25 @@ Module( 13 | } more" # line continuation 14 | f"""{f"""{x}"""}""" # mark the whole triple quote 15 | f"{'\n'.join(['\t', '\v', '\r'])}" # multiple escape sequences, multiple errors - | ^ Syntax Error: Cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) | 13 | } more" # line continuation 14 | f"""{f"""{x}"""}""" # mark the whole triple quote 15 | f"{'\n'.join(['\t', '\v', '\r'])}" # multiple escape sequences, multiple errors - | ^ Syntax Error: Cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) | 13 | } more" # line continuation 14 | f"""{f"""{x}"""}""" # mark the whole triple quote 15 | f"{'\n'.join(['\t', '\v', '\r'])}" # multiple escape sequences, multiple errors - | ^ Syntax Error: Cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) | 13 | } more" # line continuation 14 | f"""{f"""{x}"""}""" # mark the whole triple quote 15 | f"{'\n'.join(['\t', '\v', '\r'])}" # multiple escape sequences, multiple errors - | ^ Syntax Error: Cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_nested_interpolation_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_nested_interpolation_py311.py.snap index a76779f70588c7..ab5ab50c2149f9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_nested_interpolation_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep701_nested_interpolation_py311.py.snap @@ -231,7 +231,7 @@ Module( 1 | # parse_options: {"target-version": "3.11"} 2 | # nested interpolations also need to be checked 3 | f'{1: abcd "{'aa'}" }' - | ^ Syntax Error: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12) 4 | f'{1: abcd "{"\n"}" }' | @@ -240,4 +240,4 @@ Module( 2 | # nested interpolations also need to be checked 3 | f'{1: abcd "{'aa'}" }' 4 | f'{1: abcd "{"\n"}" }' - | ^ Syntax Error: Cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) + | ^ Syntax Error: cannot use an escape sequence (backslash) in f-strings on Python 3.11 (syntax was added in Python 3.12) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap index bb9346329d8bf4..cc6d0a2c720037 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap @@ -334,7 +334,7 @@ Module( | 1 | # parse_options: {"target-version": "3.15"} 2 | {*k: v for k, v in items} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 3 | {k: *v for k, v in items} 4 | {**k: v for k, v in items} | @@ -344,7 +344,7 @@ Module( 1 | # parse_options: {"target-version": "3.15"} 2 | {*k: v for k, v in items} 3 | {k: *v for k, v in items} - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 4 | {**k: v for k, v in items} 5 | {k: **v for k, v in items} | @@ -354,7 +354,7 @@ Module( 2 | {*k: v for k, v in items} 3 | {k: *v for k, v in items} 4 | {**k: v for k, v in items} - | ^^^ Syntax Error: Starred expression cannot be used here + | ^^^ Syntax Error: invalid syntax 5 | {k: **v for k, v in items} | @@ -363,4 +363,4 @@ Module( 3 | {k: *v for k, v in items} 4 | {**k: v for k, v in items} 5 | {k: **v for k, v in items} - | ^^^ Syntax Error: Starred expression cannot be used here + | ^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_unpacking_comprehensions_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_unpacking_comprehensions_py314.py.snap index 685b5d10c7fddf..1a2876f517a1ef 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_unpacking_comprehensions_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_unpacking_comprehensions_py314.py.snap @@ -304,7 +304,7 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | [*x for x in y] - | ^^ Syntax Error: Cannot use iterable unpacking in a list comprehension on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: cannot use iterable unpacking in a list comprehension on Python 3.14 (syntax was added in Python 3.15) 3 | {*x for x in y} 4 | {**x for x in y} | @@ -314,7 +314,7 @@ Module( 1 | # parse_options: {"target-version": "3.14"} 2 | [*x for x in y] 3 | {*x for x in y} - | ^^ Syntax Error: Cannot use iterable unpacking in a set comprehension on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: cannot use iterable unpacking in a set comprehension on Python 3.14 (syntax was added in Python 3.15) 4 | {**x for x in y} 5 | (*x for x in y) | @@ -324,7 +324,7 @@ Module( 2 | [*x for x in y] 3 | {*x for x in y} 4 | {**x for x in y} - | ^^^ Syntax Error: Cannot use dictionary unpacking in a dict comprehension on Python 3.14 (syntax was added in Python 3.15) + | ^^^ Syntax Error: cannot use dictionary unpacking in a dict comprehension on Python 3.14 (syntax was added in Python 3.15) 5 | (*x for x in y) 6 | f(*x for x in y) | @@ -334,7 +334,7 @@ Module( 3 | {*x for x in y} 4 | {**x for x in y} 5 | (*x for x in y) - | ^^ Syntax Error: Cannot use iterable unpacking in a generator expression on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: cannot use iterable unpacking in a generator expression on Python 3.14 (syntax was added in Python 3.15) 6 | f(*x for x in y) | @@ -343,4 +343,4 @@ Module( 4 | {**x for x in y} 5 | (*x for x in y) 6 | f(*x for x in y) - | ^^ Syntax Error: Cannot use iterable unpacking in a generator expression on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: cannot use iterable unpacking in a generator expression on Python 3.14 (syntax was added in Python 3.15) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pos_only_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pos_only_py37.py.snap index bcd4fdc4ac4a9e..9aa2861f25824a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pos_only_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pos_only_py37.py.snap @@ -314,7 +314,7 @@ Module( 1 | # parse_options: {"target-version": "3.7"} 2 | def foo(a, /): ... 3 | def foo(a, /, b, /): ... - | ^ Syntax Error: Only one '/' separator allowed + | ^ Syntax Error: / may appear only once 4 | def foo(a, *args, /, b): ... 5 | def foo(a, //): ... | @@ -324,7 +324,7 @@ Module( 2 | def foo(a, /): ... 3 | def foo(a, /, b, /): ... 4 | def foo(a, *args, /, b): ... - | ^ Syntax Error: '/' parameter must appear before '*' parameter + | ^ Syntax Error: / must be ahead of * 5 | def foo(a, //): ... | @@ -333,7 +333,7 @@ Module( 3 | def foo(a, /, b, /): ... 4 | def foo(a, *args, /, b): ... 5 | def foo(a, //): ... - | ^^ Syntax Error: Expected `,`, found `//` + | ^^ Syntax Error: invalid syntax ## Unsupported Syntax Errors @@ -341,7 +341,7 @@ Module( | 1 | # parse_options: {"target-version": "3.7"} 2 | def foo(a, /): ... - | ^ Syntax Error: Cannot use positional-only parameter separator on Python 3.7 (syntax was added in Python 3.8) + | ^ Syntax Error: cannot use positional-only parameter separator on Python 3.7 (syntax was added in Python 3.8) 3 | def foo(a, /, b, /): ... 4 | def foo(a, *args, /, b): ... | @@ -351,7 +351,7 @@ Module( 1 | # parse_options: {"target-version": "3.7"} 2 | def foo(a, /): ... 3 | def foo(a, /, b, /): ... - | ^ Syntax Error: Cannot use positional-only parameter separator on Python 3.7 (syntax was added in Python 3.8) + | ^ Syntax Error: cannot use positional-only parameter separator on Python 3.7 (syntax was added in Python 3.8) 4 | def foo(a, *args, /, b): ... 5 | def foo(a, //): ... | @@ -361,6 +361,6 @@ Module( 2 | def foo(a, /): ... 3 | def foo(a, /, b, /): ... 4 | def foo(a, *args, /, b): ... - | ^ Syntax Error: Cannot use positional-only parameter separator on Python 3.7 (syntax was added in Python 3.8) + | ^ Syntax Error: cannot use positional-only parameter separator on Python 3.7 (syntax was added in Python 3.8) 5 | def foo(a, //): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_from_without_exc.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_from_without_exc.py.snap index 25dbed536eb8f5..616816bbbec35e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_from_without_exc.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_from_without_exc.py.snap @@ -51,7 +51,7 @@ Module( | 1 | raise from exc - | ^^^^ Syntax Error: Exception missing in `raise` statement with cause + | ^^^^ Syntax Error: exception missing in `raise` statement with cause 2 | raise from None | @@ -59,4 +59,4 @@ Module( | 1 | raise from exc 2 | raise from None - | ^^^^ Syntax Error: Exception missing in `raise` statement with cause + | ^^^^ Syntax Error: exception missing in `raise` statement with cause diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap index 0004e204f3df51..475308da0cb8be 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap @@ -127,7 +127,7 @@ Module( | 1 | raise x from *y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | raise x from yield y 3 | raise x from y := 1 | @@ -136,7 +136,7 @@ Module( | 1 | raise x from *y 2 | raise x from yield y - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | raise x from y := 1 | @@ -145,4 +145,4 @@ Module( 1 | raise x from *y 2 | raise x from yield y 3 | raise x from y := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap index c8bd421fae5eb4..e39bed4c4196fe 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap @@ -100,7 +100,7 @@ Module( | 1 | raise *x - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | raise yield x 3 | raise x := 1 | @@ -109,7 +109,7 @@ Module( | 1 | raise *x 2 | raise yield x - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | raise x := 1 | @@ -118,4 +118,4 @@ Module( 1 | raise *x 2 | raise yield x 3 | raise x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_cause.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_cause.py.snap index 4b6c7c78664a9f..2b21e1d39eae5c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_cause.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_cause.py.snap @@ -101,7 +101,7 @@ Module( | 1 | raise x from y, - | ^^ Syntax Error: Unparenthesized tuple expression cannot be used here + | ^^ Syntax Error: unparenthesized tuple expression cannot be used here 2 | raise x from y, z | @@ -109,4 +109,4 @@ Module( | 1 | raise x from y, 2 | raise x from y, z - | ^^^^ Syntax Error: Unparenthesized tuple expression cannot be used here + | ^^^^ Syntax Error: unparenthesized tuple expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_exc.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_exc.py.snap index 0a0e28b80d6e5a..bc8a17974abc7f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_exc.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_unparenthesized_tuple_exc.py.snap @@ -128,7 +128,7 @@ Module( | 1 | raise x, - | ^^ Syntax Error: Unparenthesized tuple expression cannot be used here + | ^^ Syntax Error: unparenthesized tuple expression cannot be used here 2 | raise x, y 3 | raise x, y from z | @@ -137,7 +137,7 @@ Module( | 1 | raise x, 2 | raise x, y - | ^^^^ Syntax Error: Unparenthesized tuple expression cannot be used here + | ^^^^ Syntax Error: unparenthesized tuple expression cannot be used here 3 | raise x, y from z | @@ -146,4 +146,4 @@ Module( 1 | raise x, 2 | raise x, y 3 | raise x, y from z - | ^^^^ Syntax Error: Unparenthesized tuple expression cannot be used here + | ^^^^ Syntax Error: unparenthesized tuple expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap index 867b19667e5671..63bf85a52d87cb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap @@ -864,7 +864,7 @@ Module( | 1 | # No indentation before the function definition 2 | if call(foo - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 3 | def bar(): 4 | pass | @@ -874,7 +874,7 @@ Module( 1 | # No indentation before the function definition 2 | if call(foo 3 | def bar(): - | ^^^ Syntax Error: Expected an indented block after `if` statement + | ^^^ Syntax Error: expected an indented block after `if` statement 4 | pass | @@ -882,7 +882,7 @@ Module( | 7 | # Indented function definition 8 | if call(foo - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 9 | def bar(): 10 | pass | @@ -891,7 +891,7 @@ Module( | 13 | # There are multiple non-logical newlines (blank lines) in the `if` body 14 | if call(foo - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 15 | 16 | 17 | def bar(): @@ -901,7 +901,7 @@ Module( | 21 | # There are trailing whitespaces in the blank line inside the `if` body 22 | if call(foo - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 23 | 24 | def bar(): 25 | pass @@ -912,7 +912,7 @@ Module( 28 | # The lexer is nested with multiple levels of parentheses 29 | if call(foo, [a, b 30 | def bar(): - | ^^^ Syntax Error: Expected `]`, found `def` + | ^^^ Syntax Error: invalid syntax 31 | pass | @@ -920,7 +920,7 @@ Module( | 28 | # The lexer is nested with multiple levels of parentheses 29 | if call(foo, [a, b - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 30 | def bar(): 31 | pass | @@ -929,7 +929,7 @@ Module( | 34 | # The outer parenthesis is closed but the inner bracket isn't 35 | if call(foo, [a, b) - | ^ Syntax Error: Expected `]`, found `)` + | ^ Syntax Error: invalid syntax 36 | def bar(): 37 | pass | @@ -938,7 +938,7 @@ Module( | 34 | # The outer parenthesis is closed but the inner bracket isn't 35 | if call(foo, [a, b) - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 36 | def bar(): 37 | pass | @@ -948,7 +948,7 @@ Module( 42 | if call(foo, [a, 43 | b 44 | ) - | ^ Syntax Error: Expected `]`, found `)` + | ^ Syntax Error: invalid syntax 45 | def bar(): 46 | pass | @@ -958,7 +958,7 @@ Module( 42 | if call(foo, [a, 43 | b 44 | ) - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 45 | def bar(): 46 | pass | @@ -967,7 +967,7 @@ Module( | 49 | # F-strings uses normal list parsing, so test those as well 50 | if call(f"hello {x - | ^ Syntax Error: f-string: unterminated string + | ^ Syntax Error: unterminated f-string literal 51 | def bar(): 52 | pass | @@ -977,7 +977,7 @@ Module( 49 | # F-strings uses normal list parsing, so test those as well 50 | if call(f"hello {x 51 | def bar(): - | ^^^ Syntax Error: f-string: expecting `}` + | ^^^ Syntax Error: f-string: expecting '}' 52 | pass | @@ -985,7 +985,7 @@ Module( | 49 | # F-strings uses normal list parsing, so test those as well 50 | if call(f"hello {x - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 51 | def bar(): 52 | pass | @@ -993,7 +993,7 @@ Module( | 55 | if call(f"hello - | ^^^^^ Syntax Error: f-string: unterminated string + | ^^^^^ Syntax Error: unterminated f-string literal 56 | def bar(): 57 | pass | @@ -1001,7 +1001,7 @@ Module( | 55 | if call(f"hello - | ^ Syntax Error: Expected FStringEnd, found newline + | ^ Syntax Error: invalid syntax 56 | def bar(): 57 | pass | @@ -1010,7 +1010,7 @@ Module( | 55 | if call(f"hello 56 | def bar(): - | ^^^^ Syntax Error: Expected `,`, found indent + | ^^^^ Syntax Error: invalid syntax 57 | pass | @@ -1018,7 +1018,7 @@ Module( | 55 | if call(f"hello 56 | def bar(): - | ^^^ Syntax Error: Expected `)`, found `def` + | ^^^ Syntax Error: invalid syntax 57 | pass | @@ -1027,4 +1027,4 @@ Module( 55 | if call(f"hello 56 | def bar(): 57 | pass - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap index f36dc38c283c4e..2db1802b133718 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap @@ -123,9 +123,9 @@ Module( | 1 | if call(foo, [a, b␍ def bar():␍ pass - | ^^^ Syntax Error: Expected `]`, found `def` + | ^^^ Syntax Error: invalid syntax | 1 | if call(foo, [a, b␍ def bar():␍ pass - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 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 7c76ad9460d286..2ec258b09d25c0 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 @@ -124,14 +124,14 @@ Module( | 1 | if call(foo, [a, b 2 | def bar(): - | ^^^ Syntax Error: Expected `]`, found `def` + | ^^^ Syntax Error: invalid syntax 3 | pass | | 1 | if call(foo, [a, b - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 2 | def bar(): 3 | pass | 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 20aee3537321f9..86ed30ea320d5f 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 @@ -409,7 +409,7 @@ Module( | 5 | f'middle {'string':\ 6 | 'format spec'} - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' 7 | 8 | f'middle {'string':\\ | @@ -418,7 +418,7 @@ Module( | 5 | f'middle {'string':\ 6 | 'format spec'} - | ^^^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^^^^ Syntax Error: invalid syntax 7 | 8 | f'middle {'string':\\ | @@ -427,7 +427,7 @@ Module( | 5 | f'middle {'string':\ 6 | 'format spec'} - | ^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^^ Syntax Error: invalid syntax 7 | 8 | f'middle {'string':\\ | @@ -455,7 +455,7 @@ Module( 6 | 'format spec'} 7 | 8 | f'middle {'string':\\ - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' 9 | 'format spec'} 10 | 11 | f'middle {'string':\\\ @@ -465,7 +465,7 @@ Module( | 8 | f'middle {'string':\\ 9 | 'format spec'} - | ^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^ Syntax Error: unexpected indentation 10 | 11 | f'middle {'string':\\\ | @@ -474,7 +474,7 @@ Module( | 8 | f'middle {'string':\\ 9 | 'format spec'} - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 10 | 11 | f'middle {'string':\\\ | @@ -483,7 +483,7 @@ Module( | 8 | f'middle {'string':\\ 9 | 'format spec'} - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 10 | 11 | f'middle {'string':\\\ 12 | 'format spec'} @@ -493,19 +493,19 @@ Module( | 11 | f'middle {'string':\\\ 12 | 'format spec'} - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' | 11 | f'middle {'string':\\\ 12 | 'format spec'} - | ^^^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^^^^ Syntax Error: invalid syntax | 11 | f'middle {'string':\\\ 12 | 'format spec'} - | ^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^^ Syntax Error: invalid syntax | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap index 6a79b668c85b17..77889c58598368 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap @@ -101,7 +101,7 @@ Module( | 1 | call(a, b, \\\ - | ^ Syntax Error: Expected a newline after line continuation character + | ^ Syntax Error: unexpected character after line continuation character 2 | 3 | def bar(): | @@ -109,7 +109,7 @@ Module( | 1 | call(a, b, \\\ - | ^ Syntax Error: Expected a newline after line continuation character + | ^ Syntax Error: unexpected character after line continuation character 2 | 3 | def bar(): | @@ -118,7 +118,7 @@ Module( | 1 | call(a, b, \\\ 2 | - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 3 | def bar(): 4 | 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 0c3a297dc330d7..c3006ebefd645f 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 @@ -101,7 +101,7 @@ Module( | 1 | call(a, b, # comment \ - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 2 | 3 | def bar(): 4 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap index 9d4c2018c57d7f..6cc40a19b4130b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap @@ -80,13 +80,13 @@ Module( 5 | f"""hello {x # comment | ___________________________^ 6 | | y = 1 - | |_____^ Syntax Error: f-string: unterminated triple-quoted string + | |_____^ Syntax Error: unterminated triple-quoted f-string literal | 5 | f"""hello {x # comment 6 | y = 1 - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' | @@ -95,10 +95,10 @@ Module( 5 | f"""hello {x # comment | ___________________________^ 6 | | y = 1 - | |_____^ Syntax Error: Expected FStringEnd, found FStringMiddle + | |_____^ Syntax Error: invalid syntax | 5 | f"""hello {x # comment 6 | y = 1 - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap index ac68f7b38e14f4..83eaf07feed0ac 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap @@ -84,4 +84,4 @@ Module( | 5 | f'''{foo:.3f 6 | ''' - | ^^^ Syntax Error: f-string: expecting `}` + | ^^^ Syntax Error: f-string: expecting '}' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap index 8cd206b47205ee..4086dd7b0c940c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap @@ -117,7 +117,7 @@ Module( | 5 | if call(f'''{x:.3f 6 | ''' - | ^^^ Syntax Error: f-string: expecting `}` + | ^^^ Syntax Error: f-string: expecting '}' 7 | pass | @@ -125,6 +125,6 @@ Module( | 5 | if call(f'''{x:.3f 6 | ''' - | ^ Syntax Error: Expected `)`, found newline + | ^ Syntax Error: invalid syntax 7 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap index 8445afab405776..a426d014f3c635 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap @@ -163,7 +163,7 @@ Module( | 1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 2 | (c: int = 1,f"""{d=[ - | ^ Syntax Error: Expected `)`, found `:` + | ^ Syntax Error: invalid syntax 3 | def a( 4 | class A: | @@ -172,7 +172,7 @@ Module( | 1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 2 | (c: int = 1,f"""{d=[ - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' 3 | def a( 4 | class A: | @@ -182,7 +182,7 @@ Module( 1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 2 | (c: int = 1,f"""{d=[ 3 | def a( - | ^^^ Syntax Error: Expected `:`, found `def` + | ^^^ Syntax Error: invalid syntax 4 | class A: 5 | pass | @@ -192,7 +192,7 @@ Module( 1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 2 | (c: int = 1,f"""{d=[ 3 | def a( - | ^ Syntax Error: Expected `]`, found identifier + | ^ Syntax Error: invalid syntax 4 | class A: 5 | pass | @@ -205,14 +205,14 @@ Module( | _______^ 4 | | class A: 5 | | pass - | |_________^ Syntax Error: f-string: unterminated triple-quoted string + | |_________^ Syntax Error: unterminated triple-quoted f-string literal | 2 | (c: int = 1,f"""{d=[ 3 | def a( 4 | class A: - | ^^^^^ Syntax Error: Expected `)`, found `class` + | ^^^^^ Syntax Error: invalid syntax 5 | pass | @@ -224,7 +224,7 @@ Module( | _______^ 4 | | class A: 5 | | pass - | |_________^ Syntax Error: Expected a statement + | |_________^ Syntax Error: invalid syntax | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@return_stmt_invalid_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@return_stmt_invalid_expr.py.snap index 21b18794d6d674..45cd345532ed1c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@return_stmt_invalid_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@return_stmt_invalid_expr.py.snap @@ -160,7 +160,7 @@ Module( | 1 | return * - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | return yield x 3 | return yield from x 4 | return x := 1 @@ -170,7 +170,7 @@ Module( | 1 | return * 2 | return yield x - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | return yield from x 4 | return x := 1 | @@ -180,7 +180,7 @@ Module( 1 | return * 2 | return yield x 3 | return yield from x - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 4 | return x := 1 5 | return *x and y | @@ -190,7 +190,7 @@ Module( 2 | return yield x 3 | return yield from x 4 | return x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax 5 | return *x and y | @@ -199,7 +199,7 @@ Module( 3 | return yield from x 4 | return x := 1 5 | return *x and y - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@signed_pattern_non_literal_operand.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@signed_pattern_non_literal_operand.py.snap index e28ab89d2ec62b..cfa1fe52502c4c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@signed_pattern_non_literal_operand.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@signed_pattern_non_literal_operand.py.snap @@ -336,7 +336,7 @@ Module( 1 | # parse_options: {"target-version": "3.15"} 2 | match value: 3 | case -1**2: ... - | ^^^^ Syntax Error: Expected a numeric literal after unary operator + | ^^^^ Syntax Error: expected a numeric literal after unary operator 4 | case -1 .real: ... 5 | case -1[0]: ... | @@ -346,7 +346,7 @@ Module( 2 | match value: 3 | case -1**2: ... 4 | case -1 .real: ... - | ^^^^^^^ Syntax Error: Expected a numeric literal after unary operator + | ^^^^^^^ Syntax Error: expected a numeric literal after unary operator 5 | case -1[0]: ... 6 | case -1(): ... | @@ -356,7 +356,7 @@ Module( 3 | case -1**2: ... 4 | case -1 .real: ... 5 | case -1[0]: ... - | ^^^^ Syntax Error: Expected a numeric literal after unary operator + | ^^^^ Syntax Error: expected a numeric literal after unary operator 6 | case -1(): ... 7 | case {+1**2: _}: ... | @@ -366,7 +366,7 @@ Module( 4 | case -1 .real: ... 5 | case -1[0]: ... 6 | case -1(): ... - | ^^^ Syntax Error: Expected a numeric literal after unary operator + | ^^^ Syntax Error: expected a numeric literal after unary operator 7 | case {+1**2: _}: ... | @@ -375,4 +375,4 @@ Module( 5 | case -1[0]: ... 6 | case -1(): ... 7 | case {+1**2: _}: ... - | ^^^^ Syntax Error: Expected a numeric literal after unary operator + | ^^^^ Syntax Error: expected a numeric literal after unary operator diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line.py.snap index ebcc879bdb24e2..0155838542a2f3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line.py.snap @@ -71,4 +71,4 @@ Module( | 1 | a; if b: pass; b - | ^^ Syntax Error: Compound statements are not allowed on the same line as simple statements + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line_in_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line_in_block.py.snap index 6b363da4909e4c..eefe02c49ace70 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line_in_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_and_compound_stmt_on_same_line_in_block.py.snap @@ -111,7 +111,7 @@ Module( | 1 | if True: pass if False: pass - | ^^ Syntax Error: Compound statements are not allowed on the same line as simple statements + | ^^ Syntax Error: invalid syntax 2 | if True: pass; if False: pass | @@ -119,4 +119,4 @@ Module( | 1 | if True: pass if False: pass 2 | if True: pass; if False: pass - | ^^ Syntax Error: Compound statements are not allowed on the same line as simple statements + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line.py.snap index 81ed3b3b79d332..7220b7168254cc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line.py.snap @@ -135,7 +135,7 @@ Module( | 1 | a b - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax 2 | a + b c + d 3 | break; continue pass; continue break | @@ -144,7 +144,7 @@ Module( | 1 | a b 2 | a + b c + d - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax 3 | break; continue pass; continue break | @@ -153,11 +153,11 @@ Module( 1 | a b 2 | a + b c + d 3 | break; continue pass; continue break - | ^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^^ Syntax Error: invalid syntax | 1 | a b 2 | a + b c + d 3 | break; continue pass; continue break - | ^^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line_in_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line_in_block.py.snap index dc6ac8fdac2dfc..306203013212ef 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line_in_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@simple_stmts_on_same_line_in_block.py.snap @@ -66,9 +66,9 @@ Module( | 1 | if True: break; continue pass; continue break - | ^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^^ Syntax Error: invalid syntax | 1 | if True: break; continue pass; continue break - | ^^^^^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^^^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_index_py310.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_index_py310.py.snap index cbc20af3501c7d..201b5067f913fa 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_index_py310.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_index_py310.py.snap @@ -420,7 +420,7 @@ Module( | 1 | # parse_options: {"target-version": "3.10"} 2 | lst[*index] # simple index - | ^^^^^^ Syntax Error: Cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) + | ^^^^^^ Syntax Error: cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) 3 | class Array(Generic[DType, *Shape]): ... # motivating example from the PEP 4 | lst[a, *b, c] # different positions | @@ -430,7 +430,7 @@ Module( 1 | # parse_options: {"target-version": "3.10"} 2 | lst[*index] # simple index 3 | class Array(Generic[DType, *Shape]): ... # motivating example from the PEP - | ^^^^^^ Syntax Error: Cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) + | ^^^^^^ Syntax Error: cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) 4 | lst[a, *b, c] # different positions 5 | lst[a, b, *c] # different positions | @@ -440,7 +440,7 @@ Module( 2 | lst[*index] # simple index 3 | class Array(Generic[DType, *Shape]): ... # motivating example from the PEP 4 | lst[a, *b, c] # different positions - | ^^ Syntax Error: Cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) + | ^^ Syntax Error: cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) 5 | lst[a, b, *c] # different positions 6 | lst[*a, *b] # multiple unpacks | @@ -450,7 +450,7 @@ Module( 3 | class Array(Generic[DType, *Shape]): ... # motivating example from the PEP 4 | lst[a, *b, c] # different positions 5 | lst[a, b, *c] # different positions - | ^^ Syntax Error: Cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) + | ^^ Syntax Error: cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) 6 | lst[*a, *b] # multiple unpacks 7 | array[3:5, *idxs] # mixed with slices | @@ -460,7 +460,7 @@ Module( 4 | lst[a, *b, c] # different positions 5 | lst[a, b, *c] # different positions 6 | lst[*a, *b] # multiple unpacks - | ^^ Syntax Error: Cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) + | ^^ Syntax Error: cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) 7 | array[3:5, *idxs] # mixed with slices | @@ -469,7 +469,7 @@ Module( 4 | lst[a, *b, c] # different positions 5 | lst[a, b, *c] # different positions 6 | lst[*a, *b] # multiple unpacks - | ^^ Syntax Error: Cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) + | ^^ Syntax Error: cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) 7 | array[3:5, *idxs] # mixed with slices | @@ -478,4 +478,4 @@ Module( 5 | lst[a, b, *c] # different positions 6 | lst[*a, *b] # multiple unpacks 7 | array[3:5, *idxs] # mixed with slices - | ^^^^^ Syntax Error: Cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) + | ^^^^^ Syntax Error: cannot use star expression in index on Python 3.10 (syntax was added in Python 3.11) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap index bca9fc105705e4..395a1d065e726c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap @@ -81,9 +81,9 @@ Module( | 1 | array[*start:*end] - | ^^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^^ Syntax Error: invalid syntax | 1 | array[*start:*end] - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_list_comp_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_list_comp_py314.py.snap index c790e4ca93584e..53fd930bfcb9e3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_list_comp_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_list_comp_py314.py.snap @@ -73,4 +73,4 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | [*x for x in y] - | ^^ Syntax Error: Cannot use iterable unpacking in a list comprehension on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: cannot use iterable unpacking in a list comprehension on Python 3.14 (syntax was added in Python 3.15) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap index 19ceddd7b52e1c..78aa115c891c97 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap @@ -124,7 +124,7 @@ Module( | 1 | print(* 2 | *[]) - | ^^^ Syntax Error: Starred expression cannot be used here + | ^^^ Syntax Error: invalid syntax 3 | print(* *[]) | @@ -133,4 +133,4 @@ Module( 1 | print(* 2 | *[]) 3 | print(* *[]) - | ^^^ Syntax Error: Starred expression cannot be used here + | ^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap index ae49cdad1e0c8e..39f380c008f38b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap @@ -408,7 +408,7 @@ Module( 9 | # on following lines. 10 | 11 | def keyword[A, await](): ... - | ^^^^^ Syntax Error: Expected an identifier, but found a keyword `await` that cannot be used here + | ^^^^^ Syntax Error: invalid syntax 12 | 13 | def not_a_type_param[A, |, B](): ... | @@ -418,7 +418,7 @@ Module( 11 | def keyword[A, await](): ... 12 | 13 | def not_a_type_param[A, |, B](): ... - | ^ Syntax Error: Expected `,`, found `|` + | ^ Syntax Error: invalid syntax 14 | 15 | def multiple_commas[A,,B](): ... | @@ -428,7 +428,7 @@ Module( 11 | def keyword[A, await](): ... 12 | 13 | def not_a_type_param[A, |, B](): ... - | ^ Syntax Error: Expected a type parameter or the end of the type parameter list + | ^ Syntax Error: invalid syntax 14 | 15 | def multiple_commas[A,,B](): ... | @@ -438,7 +438,7 @@ Module( 13 | def not_a_type_param[A, |, B](): ... 14 | 15 | def multiple_commas[A,,B](): ... - | ^ Syntax Error: Expected a type parameter or the end of the type parameter list + | ^ Syntax Error: invalid syntax 16 | 17 | def multiple_trailing_commas[A,,](): ... | @@ -448,7 +448,7 @@ Module( 15 | def multiple_commas[A,,B](): ... 16 | 17 | def multiple_trailing_commas[A,,](): ... - | ^ Syntax Error: Expected a type parameter or the end of the type parameter list + | ^ Syntax Error: invalid syntax 18 | 19 | def multiple_commas_and_recovery[A,,100](): ... | @@ -458,25 +458,25 @@ Module( 17 | def multiple_trailing_commas[A,,](): ... 18 | 19 | def multiple_commas_and_recovery[A,,100](): ... - | ^ Syntax Error: Expected a type parameter or the end of the type parameter list + | ^ Syntax Error: invalid syntax | 17 | def multiple_trailing_commas[A,,](): ... 18 | 19 | def multiple_commas_and_recovery[A,,100](): ... - | ^^^ Syntax Error: Expected `]`, found int + | ^^^ Syntax Error: invalid syntax | 17 | def multiple_trailing_commas[A,,](): ... 18 | 19 | def multiple_commas_and_recovery[A,,100](): ... - | ^ Syntax Error: Expected newline, found `]` + | ^ Syntax Error: invalid syntax | 17 | def multiple_trailing_commas[A,,](): ... 18 | 19 | def multiple_commas_and_recovery[A,,100](): ... - | ^^ Syntax Error: Only single target (not tuple) can be annotated + | ^^ Syntax Error: only single target (not tuple) can be annotated diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap index bb6b49885b8bb4..1b482bcd9ae00b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap @@ -42,7 +42,7 @@ Module( | 1 | # FIXME(micha): This creates two syntax errors instead of just one (and overlapping ones) 2 | if True)): - | ^ Syntax Error: Expected `:`, found `)` + | ^ Syntax Error: invalid syntax 3 | pass | @@ -50,7 +50,7 @@ Module( | 1 | # FIXME(micha): This creates two syntax errors instead of just one (and overlapping ones) 2 | if True)): - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 3 | pass | @@ -58,7 +58,7 @@ Module( | 1 | # FIXME(micha): This creates two syntax errors instead of just one (and overlapping ones) 2 | if True)): - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 3 | pass | @@ -66,7 +66,7 @@ Module( | 1 | # FIXME(micha): This creates two syntax errors instead of just one (and overlapping ones) 2 | if True)): - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 3 | pass | @@ -75,4 +75,4 @@ Module( 1 | # FIXME(micha): This creates two syntax errors instead of just one (and overlapping ones) 2 | if True)): 3 | pass - | ^^^^ Syntax Error: Unexpected indentation + | ^^^^ Syntax Error: unexpected indentation 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 fc62c64abc4d62..5c1e64db6f56f0 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 @@ -532,7 +532,7 @@ Module( 2 | if True: 3 | pass 4 | a + b - | ^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^ Syntax Error: unexpected indentation 5 | 6 | pass | @@ -542,7 +542,7 @@ Module( 11 | if True: 12 | before_nested 13 | first_nested - | ^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^ Syntax Error: unexpected indentation 14 | second_nested 15 | after_nested | @@ -552,7 +552,7 @@ Module( 12 | before_nested 13 | first_nested 14 | second_nested - | ^^^^^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^^^^^ Syntax Error: unexpected indentation 15 | after_nested | @@ -561,7 +561,7 @@ Module( 20 | if True: 21 | before_compound 22 | if condition: - | ^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^ Syntax Error: unexpected indentation 23 | nested_compound 24 | recovered_compound | @@ -571,7 +571,7 @@ Module( 30 | if True: 31 | before_regions 32 | first_region - | ^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^ Syntax Error: unexpected indentation 33 | middle_region 34 | second_region | @@ -581,7 +581,7 @@ Module( 32 | first_region 33 | middle_region 34 | second_region - | ^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^ Syntax Error: unexpected indentation 35 | after_region | @@ -590,7 +590,7 @@ Module( 40 | if True: 41 | before_error 42 | broken(,) - | ^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^ Syntax Error: unexpected indentation 43 | after_error | @@ -599,7 +599,7 @@ Module( 40 | if True: 41 | before_error 42 | broken(,) - | ^ Syntax Error: Expected an expression or a ')' + | ^ Syntax Error: invalid syntax 43 | after_error | @@ -608,4 +608,4 @@ Module( 48 | if True: 49 | before_eof 50 | final_eof - | ^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^ Syntax Error: unexpected indentation diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap index 37feba6153ab1d..40b653667d7d19 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap @@ -1715,7 +1715,7 @@ Module( 3 | # rejected by the parser. e.g., `5 = 3`, `5 += 3`, `(5): int = 3`. 4 | 5 | 5 = 3 - | ^ Syntax Error: Invalid assignment target + | ^ Syntax Error: invalid assignment target 6 | 7 | 5 += 3 | @@ -1725,7 +1725,7 @@ Module( 5 | 5 = 3 6 | 7 | 5 += 3 - | ^ Syntax Error: Invalid augmented assignment target + | ^ Syntax Error: invalid augmented assignment target 8 | 9 | (5): int = 3 | @@ -1735,7 +1735,7 @@ Module( 7 | 5 += 3 8 | 9 | (5): int = 3 - | ^ Syntax Error: Invalid annotated assignment target + | ^ Syntax Error: illegal target for annotation 10 | 11 | # Now we exhaustively test all possible cases where assignment can fail. | @@ -1744,7 +1744,7 @@ Module( | 11 | # Now we exhaustively test all possible cases where assignment can fail. 12 | x or y = 42 - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 13 | (x := 5) = 42 14 | x + y = 42 | @@ -1754,7 +1754,7 @@ Module( 11 | # Now we exhaustively test all possible cases where assignment can fail. 12 | x or y = 42 13 | (x := 5) = 42 - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 14 | x + y = 42 15 | -x = 42 | @@ -1764,7 +1764,7 @@ Module( 12 | x or y = 42 13 | (x := 5) = 42 14 | x + y = 42 - | ^^^^^ Syntax Error: Invalid assignment target + | ^^^^^ Syntax Error: invalid assignment target 15 | -x = 42 16 | (lambda _: 1) = 42 | @@ -1774,7 +1774,7 @@ Module( 13 | (x := 5) = 42 14 | x + y = 42 15 | -x = 42 - | ^^ Syntax Error: Invalid assignment target + | ^^ Syntax Error: invalid assignment target 16 | (lambda _: 1) = 42 17 | a if b else c = 42 | @@ -1784,7 +1784,7 @@ Module( 14 | x + y = 42 15 | -x = 42 16 | (lambda _: 1) = 42 - | ^^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^^ Syntax Error: invalid assignment target 17 | a if b else c = 42 18 | {"a": 5} = 42 | @@ -1794,7 +1794,7 @@ Module( 15 | -x = 42 16 | (lambda _: 1) = 42 17 | a if b else c = 42 - | ^^^^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^^^^ Syntax Error: invalid assignment target 18 | {"a": 5} = 42 19 | {a} = 42 | @@ -1804,7 +1804,7 @@ Module( 16 | (lambda _: 1) = 42 17 | a if b else c = 42 18 | {"a": 5} = 42 - | ^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^ Syntax Error: invalid assignment target 19 | {a} = 42 20 | [x for x in xs] = 42 | @@ -1814,7 +1814,7 @@ Module( 17 | a if b else c = 42 18 | {"a": 5} = 42 19 | {a} = 42 - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target 20 | [x for x in xs] = 42 21 | {x for x in xs} = 42 | @@ -1824,7 +1824,7 @@ Module( 18 | {"a": 5} = 42 19 | {a} = 42 20 | [x for x in xs] = 42 - | ^^^^^^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target 21 | {x for x in xs} = 42 22 | {x: x * 2 for x in xs} = 42 | @@ -1834,7 +1834,7 @@ Module( 19 | {a} = 42 20 | [x for x in xs] = 42 21 | {x for x in xs} = 42 - | ^^^^^^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target 22 | {x: x * 2 for x in xs} = 42 23 | (x for x in xs) = 42 | @@ -1844,7 +1844,7 @@ Module( 20 | [x for x in xs] = 42 21 | {x for x in xs} = 42 22 | {x: x * 2 for x in xs} = 42 - | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target 23 | (x for x in xs) = 42 24 | await x = 42 | @@ -1854,7 +1854,7 @@ Module( 21 | {x for x in xs} = 42 22 | {x: x * 2 for x in xs} = 42 23 | (x for x in xs) = 42 - | ^^^^^^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target 24 | await x = 42 25 | (yield x) = 42 | @@ -1864,7 +1864,7 @@ Module( 22 | {x: x * 2 for x in xs} = 42 23 | (x for x in xs) = 42 24 | await x = 42 - | ^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^ Syntax Error: invalid assignment target 25 | (yield x) = 42 26 | (yield from xs) = 42 | @@ -1874,7 +1874,7 @@ Module( 23 | (x for x in xs) = 42 24 | await x = 42 25 | (yield x) = 42 - | ^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^ Syntax Error: invalid assignment target 26 | (yield from xs) = 42 27 | a < b < c = 42 | @@ -1884,7 +1884,7 @@ Module( 24 | await x = 42 25 | (yield x) = 42 26 | (yield from xs) = 42 - | ^^^^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^^^^ Syntax Error: invalid assignment target 27 | a < b < c = 42 28 | foo() = 42 | @@ -1894,7 +1894,7 @@ Module( 25 | (yield x) = 42 26 | (yield from xs) = 42 27 | a < b < c = 42 - | ^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^ Syntax Error: invalid assignment target 28 | foo() = 42 | @@ -1903,7 +1903,7 @@ Module( 26 | (yield from xs) = 42 27 | a < b < c = 42 28 | foo() = 42 - | ^^^^^ Syntax Error: Invalid assignment target + | ^^^^^ Syntax Error: invalid assignment target 29 | 30 | f"{quux}" = 42 | @@ -1913,7 +1913,7 @@ Module( 28 | foo() = 42 29 | 30 | f"{quux}" = 42 - | ^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^ Syntax Error: invalid assignment target 31 | f"{foo} and {bar}" = 42 | @@ -1921,7 +1921,7 @@ Module( | 30 | f"{quux}" = 42 31 | f"{foo} and {bar}" = 42 - | ^^^^^^^^^^^^^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target 32 | 33 | "foo" = 42 | @@ -1931,7 +1931,7 @@ Module( 31 | f"{foo} and {bar}" = 42 32 | 33 | "foo" = 42 - | ^^^^^ Syntax Error: Invalid assignment target + | ^^^^^ Syntax Error: invalid assignment target 34 | b"foo" = 42 35 | 123 = 42 | @@ -1940,7 +1940,7 @@ Module( | 33 | "foo" = 42 34 | b"foo" = 42 - | ^^^^^^ Syntax Error: Invalid assignment target + | ^^^^^^ Syntax Error: invalid assignment target 35 | 123 = 42 36 | True = 42 | @@ -1950,7 +1950,7 @@ Module( 33 | "foo" = 42 34 | b"foo" = 42 35 | 123 = 42 - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target 36 | True = 42 37 | None = 42 | @@ -1960,7 +1960,7 @@ Module( 34 | b"foo" = 42 35 | 123 = 42 36 | True = 42 - | ^^^^ Syntax Error: Invalid assignment target + | ^^^^ Syntax Error: invalid assignment target 37 | None = 42 38 | ... = 42 | @@ -1970,7 +1970,7 @@ Module( 35 | 123 = 42 36 | True = 42 37 | None = 42 - | ^^^^ Syntax Error: Invalid assignment target + | ^^^^ Syntax Error: invalid assignment target 38 | ... = 42 39 | *foo() = 42 | @@ -1980,7 +1980,7 @@ Module( 36 | True = 42 37 | None = 42 38 | ... = 42 - | ^^^ Syntax Error: Invalid assignment target + | ^^^ Syntax Error: invalid assignment target 39 | *foo() = 42 40 | [x, foo(), y] = [42, 42, 42] | @@ -1990,7 +1990,7 @@ Module( 37 | None = 42 38 | ... = 42 39 | *foo() = 42 - | ^^^^^ Syntax Error: Invalid assignment target + | ^^^^^ Syntax Error: invalid assignment target 40 | [x, foo(), y] = [42, 42, 42] 41 | [[a, b], [[42]], d] = [[1, 2], [[3]], 4] | @@ -2000,7 +2000,7 @@ Module( 38 | ... = 42 39 | *foo() = 42 40 | [x, foo(), y] = [42, 42, 42] - | ^^^^^ Syntax Error: Invalid assignment target + | ^^^^^ Syntax Error: invalid assignment target 41 | [[a, b], [[42]], d] = [[1, 2], [[3]], 4] 42 | (x, foo(), y) = (42, 42, 42) | @@ -2010,7 +2010,7 @@ Module( 39 | *foo() = 42 40 | [x, foo(), y] = [42, 42, 42] 41 | [[a, b], [[42]], d] = [[1, 2], [[3]], 4] - | ^^ Syntax Error: Invalid assignment target + | ^^ Syntax Error: invalid assignment target 42 | (x, foo(), y) = (42, 42, 42) | @@ -2019,7 +2019,7 @@ Module( 40 | [x, foo(), y] = [42, 42, 42] 41 | [[a, b], [[42]], d] = [[1, 2], [[3]], 4] 42 | (x, foo(), y) = (42, 42, 42) - | ^^^^^ Syntax Error: Invalid assignment target + | ^^^^^ Syntax Error: invalid assignment target ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap index 4e29acdc0ff81c..6ce032a501f159 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap @@ -1509,7 +1509,7 @@ Module( 2 | # assignment targets. 3 | 4 | x or y += 42 - | ^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^ Syntax Error: invalid augmented assignment target 5 | (x := 5) += 42 6 | x + y += 42 | @@ -1518,7 +1518,7 @@ Module( | 4 | x or y += 42 5 | (x := 5) += 42 - | ^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^ Syntax Error: invalid augmented assignment target 6 | x + y += 42 7 | -x += 42 | @@ -1528,7 +1528,7 @@ Module( 4 | x or y += 42 5 | (x := 5) += 42 6 | x + y += 42 - | ^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^ Syntax Error: invalid augmented assignment target 7 | -x += 42 8 | (lambda _: 1) += 42 | @@ -1538,7 +1538,7 @@ Module( 5 | (x := 5) += 42 6 | x + y += 42 7 | -x += 42 - | ^^ Syntax Error: Invalid augmented assignment target + | ^^ Syntax Error: invalid augmented assignment target 8 | (lambda _: 1) += 42 9 | a if b else c += 42 | @@ -1548,7 +1548,7 @@ Module( 6 | x + y += 42 7 | -x += 42 8 | (lambda _: 1) += 42 - | ^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 9 | a if b else c += 42 10 | {"a": 5} += 42 | @@ -1558,7 +1558,7 @@ Module( 7 | -x += 42 8 | (lambda _: 1) += 42 9 | a if b else c += 42 - | ^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 10 | {"a": 5} += 42 11 | {a} += 42 | @@ -1568,7 +1568,7 @@ Module( 8 | (lambda _: 1) += 42 9 | a if b else c += 42 10 | {"a": 5} += 42 - | ^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^ Syntax Error: invalid augmented assignment target 11 | {a} += 42 12 | [x for x in xs] += 42 | @@ -1578,7 +1578,7 @@ Module( 9 | a if b else c += 42 10 | {"a": 5} += 42 11 | {a} += 42 - | ^^^ Syntax Error: Invalid augmented assignment target + | ^^^ Syntax Error: invalid augmented assignment target 12 | [x for x in xs] += 42 13 | {x for x in xs} += 42 | @@ -1588,7 +1588,7 @@ Module( 10 | {"a": 5} += 42 11 | {a} += 42 12 | [x for x in xs] += 42 - | ^^^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 13 | {x for x in xs} += 42 14 | {x: x * 2 for x in xs} += 42 | @@ -1598,7 +1598,7 @@ Module( 11 | {a} += 42 12 | [x for x in xs] += 42 13 | {x for x in xs} += 42 - | ^^^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 14 | {x: x * 2 for x in xs} += 42 15 | (x for x in xs) += 42 | @@ -1608,7 +1608,7 @@ Module( 12 | [x for x in xs] += 42 13 | {x for x in xs} += 42 14 | {x: x * 2 for x in xs} += 42 - | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 15 | (x for x in xs) += 42 16 | await x += 42 | @@ -1618,7 +1618,7 @@ Module( 13 | {x for x in xs} += 42 14 | {x: x * 2 for x in xs} += 42 15 | (x for x in xs) += 42 - | ^^^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 16 | await x += 42 17 | (yield x) += 42 | @@ -1628,7 +1628,7 @@ Module( 14 | {x: x * 2 for x in xs} += 42 15 | (x for x in xs) += 42 16 | await x += 42 - | ^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^ Syntax Error: invalid augmented assignment target 17 | (yield x) += 42 18 | (yield from xs) += 42 | @@ -1638,7 +1638,7 @@ Module( 15 | (x for x in xs) += 42 16 | await x += 42 17 | (yield x) += 42 - | ^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^ Syntax Error: invalid augmented assignment target 18 | (yield from xs) += 42 19 | a < b < c += 42 | @@ -1648,7 +1648,7 @@ Module( 16 | await x += 42 17 | (yield x) += 42 18 | (yield from xs) += 42 - | ^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 19 | a < b < c += 42 20 | foo() += 42 | @@ -1658,7 +1658,7 @@ Module( 17 | (yield x) += 42 18 | (yield from xs) += 42 19 | a < b < c += 42 - | ^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^ Syntax Error: invalid augmented assignment target 20 | foo() += 42 | @@ -1667,7 +1667,7 @@ Module( 18 | (yield from xs) += 42 19 | a < b < c += 42 20 | foo() += 42 - | ^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^ Syntax Error: invalid augmented assignment target 21 | 22 | f"{quux}" += 42 | @@ -1677,7 +1677,7 @@ Module( 20 | foo() += 42 21 | 22 | f"{quux}" += 42 - | ^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^ Syntax Error: invalid augmented assignment target 23 | f"{foo} and {bar}" += 42 | @@ -1685,7 +1685,7 @@ Module( | 22 | f"{quux}" += 42 23 | f"{foo} and {bar}" += 42 - | ^^^^^^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 24 | 25 | "foo" += 42 | @@ -1695,7 +1695,7 @@ Module( 23 | f"{foo} and {bar}" += 42 24 | 25 | "foo" += 42 - | ^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^ Syntax Error: invalid augmented assignment target 26 | b"foo" += 42 27 | 123 += 42 | @@ -1704,7 +1704,7 @@ Module( | 25 | "foo" += 42 26 | b"foo" += 42 - | ^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^ Syntax Error: invalid augmented assignment target 27 | 123 += 42 28 | True += 42 | @@ -1714,7 +1714,7 @@ Module( 25 | "foo" += 42 26 | b"foo" += 42 27 | 123 += 42 - | ^^^ Syntax Error: Invalid augmented assignment target + | ^^^ Syntax Error: invalid augmented assignment target 28 | True += 42 29 | None += 42 | @@ -1724,7 +1724,7 @@ Module( 26 | b"foo" += 42 27 | 123 += 42 28 | True += 42 - | ^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^ Syntax Error: invalid augmented assignment target 29 | None += 42 30 | ... += 42 | @@ -1734,7 +1734,7 @@ Module( 27 | 123 += 42 28 | True += 42 29 | None += 42 - | ^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^ Syntax Error: invalid augmented assignment target 30 | ... += 42 31 | *foo() += 42 | @@ -1744,7 +1744,7 @@ Module( 28 | True += 42 29 | None += 42 30 | ... += 42 - | ^^^ Syntax Error: Invalid augmented assignment target + | ^^^ Syntax Error: invalid augmented assignment target 31 | *foo() += 42 32 | [x, foo(), y] += [42, 42, 42] | @@ -1754,7 +1754,7 @@ Module( 29 | None += 42 30 | ... += 42 31 | *foo() += 42 - | ^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^ Syntax Error: invalid augmented assignment target 32 | [x, foo(), y] += [42, 42, 42] 33 | [[a, b], [[42]], d] += [[1, 2], [[3]], 4] | @@ -1764,7 +1764,7 @@ Module( 30 | ... += 42 31 | *foo() += 42 32 | [x, foo(), y] += [42, 42, 42] - | ^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 33 | [[a, b], [[42]], d] += [[1, 2], [[3]], 4] 34 | (x, foo(), y) += (42, 42, 42) | @@ -1774,7 +1774,7 @@ Module( 31 | *foo() += 42 32 | [x, foo(), y] += [42, 42, 42] 33 | [[a, b], [[42]], d] += [[1, 2], [[3]], 4] - | ^^^^^^^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target 34 | (x, foo(), y) += (42, 42, 42) | @@ -1783,4 +1783,4 @@ Module( 32 | [x, foo(), y] += [42, 42, 42] 33 | [[a, b], [[42]], d] += [[1, 2], [[3]], 4] 34 | (x, foo(), y) += (42, 42, 42) - | ^^^^^^^^^^^^^ Syntax Error: Invalid augmented assignment target + | ^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_0.py.snap index 619fc9ac27d832..a036510f621dd3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_0.py.snap @@ -103,7 +103,7 @@ Module( 3 | # class pattern 4 | # v 5 | case (x as y)(a, b): - | ^^^^^^ Syntax Error: Invalid value for a class pattern + | ^^^^^^ Syntax Error: invalid value for a class pattern 6 | # ^^^^^^ 7 | # as-pattern | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_1.py.snap index db17c3b6bb29c3..7598089f70fe9e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_1.py.snap @@ -82,7 +82,7 @@ Module( 3 | # complex literal pattern 4 | # v 5 | case (x as y) + 1j: - | ^^^^^^ Syntax Error: Expected a real number in complex literal pattern + | ^^^^^^ Syntax Error: expected a real number in complex literal pattern 6 | # ^^^^^^ 7 | # as-pattern | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap index 615d4cacb75130..b2d25f13ada262 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_2.py.snap @@ -114,7 +114,7 @@ Module( 2 | # This `as` pattern is unparenthesied so the parser never takes the path 3 | # where it might be confused as a complex literal pattern. 4 | case x as y + 1j: - | ^ Syntax Error: Expected `:`, found `+` + | ^ Syntax Error: invalid syntax 5 | pass | @@ -123,7 +123,7 @@ Module( 2 | # This `as` pattern is unparenthesied so the parser never takes the path 3 | # where it might be confused as a complex literal pattern. 4 | case x as y + 1j: - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 5 | pass | @@ -132,10 +132,10 @@ Module( 3 | # where it might be confused as a complex literal pattern. 4 | case x as y + 1j: 5 | pass - | ^^^^^^^^ Syntax Error: Expected dedent, found indent + | ^^^^^^^^ Syntax Error: invalid syntax | 4 | case x as y + 1j: 5 | pass - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap index 2a663ffb3cce66..f64f6e8fadbdc7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap @@ -119,7 +119,7 @@ Module( 2 | # Not in the mapping start token set, so the list parsing bails 3 | # v 4 | case {(x as y): 1}: - | ^ Syntax Error: Expected `}`, found `(` + | ^ Syntax Error: invalid syntax 5 | pass | @@ -128,7 +128,7 @@ Module( 2 | # Not in the mapping start token set, so the list parsing bails 3 | # v 4 | case {(x as y): 1}: - | ^ Syntax Error: Invalid value for a class pattern + | ^ Syntax Error: invalid value for a class pattern 5 | pass | @@ -137,7 +137,7 @@ Module( 2 | # Not in the mapping start token set, so the list parsing bails 3 | # v 4 | case {(x as y): 1}: - | ^ Syntax Error: Expected newline, found `}` + | ^ Syntax Error: invalid syntax 5 | pass | @@ -146,7 +146,7 @@ Module( 2 | # Not in the mapping start token set, so the list parsing bails 3 | # v 4 | case {(x as y): 1}: - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 5 | pass | @@ -155,7 +155,7 @@ Module( 2 | # Not in the mapping start token set, so the list parsing bails 3 | # v 4 | case {(x as y): 1}: - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 5 | pass | @@ -164,10 +164,10 @@ Module( 3 | # v 4 | case {(x as y): 1}: 5 | pass - | ^^^^^^^^ Syntax Error: Unexpected indentation + | ^^^^^^^^ Syntax Error: unexpected indentation | 4 | case {(x as y): 1}: 5 | pass - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_4.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_4.py.snap index cd5a8cb61267b9..215e2b543e0b4d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_4.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_4.py.snap @@ -109,7 +109,7 @@ Module( 2 | # This `as` pattern is unparenthesized so the parser never takes the path 3 | # where it might be confused as a mapping key pattern. 4 | case {x as y: 1}: - | ^ Syntax Error: Invalid mapping pattern key + | ^ Syntax Error: invalid mapping pattern key 5 | pass | @@ -118,7 +118,7 @@ Module( 2 | # This `as` pattern is unparenthesized so the parser never takes the path 3 | # where it might be confused as a mapping key pattern. 4 | case {x as y: 1}: - | ^^ Syntax Error: Expected `:`, found `as` + | ^^ Syntax Error: invalid syntax 5 | pass | @@ -127,6 +127,6 @@ Module( 2 | # This `as` pattern is unparenthesized so the parser never takes the path 3 | # where it might be confused as a mapping key pattern. 4 | case {x as y: 1}: - | ^ Syntax Error: Expected `,`, found identifier + | ^ Syntax Error: invalid syntax 5 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap index 900b37114fe59d..4b4a5d457dbe2a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap @@ -409,7 +409,7 @@ Module( 1 | # Invalid keyword pattern in class argument 2 | match subject: 3 | case Foo(x as y = 1): - | ^^^^^^ Syntax Error: Expected an identifier for the keyword pattern + | ^^^^^^ Syntax Error: invalid syntax 4 | pass 5 | case Foo(x | y = 1): | @@ -419,7 +419,7 @@ Module( 3 | case Foo(x as y = 1): 4 | pass 5 | case Foo(x | y = 1): - | ^^^^^ Syntax Error: Expected an identifier for the keyword pattern + | ^^^^^ Syntax Error: invalid syntax 6 | pass 7 | case Foo([x, y] = 1): | @@ -429,7 +429,7 @@ Module( 5 | case Foo(x | y = 1): 6 | pass 7 | case Foo([x, y] = 1): - | ^^^^^^ Syntax Error: Expected an identifier for the keyword pattern + | ^^^^^^ Syntax Error: invalid syntax 8 | pass 9 | case Foo({False: 0} = 1): | @@ -439,7 +439,7 @@ Module( 7 | case Foo([x, y] = 1): 8 | pass 9 | case Foo({False: 0} = 1): - | ^^^^^^^^^^ Syntax Error: Expected an identifier for the keyword pattern + | ^^^^^^^^^^ Syntax Error: invalid syntax 10 | pass 11 | case Foo(1=1): | @@ -449,7 +449,7 @@ Module( 9 | case Foo({False: 0} = 1): 10 | pass 11 | case Foo(1=1): - | ^ Syntax Error: Expected an identifier for the keyword pattern + | ^ Syntax Error: invalid syntax 12 | pass 13 | case Foo(Bar()=1): | @@ -459,7 +459,7 @@ Module( 11 | case Foo(1=1): 12 | pass 13 | case Foo(Bar()=1): - | ^^^^^ Syntax Error: Expected an identifier for the keyword pattern + | ^^^^^ Syntax Error: invalid syntax 14 | pass 15 | # Positional pattern cannot follow keyword pattern | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_lhs_or_rhs_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_lhs_or_rhs_pattern.py.snap index ba01fabf0a05e1..e407cb5ed52854 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_lhs_or_rhs_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_lhs_or_rhs_pattern.py.snap @@ -1098,7 +1098,7 @@ Module( | 1 | match invalid_lhs_pattern: 2 | case Foo() + 1j: - | ^^^^^ Syntax Error: Expected a real number in complex literal pattern + | ^^^^^ Syntax Error: expected a real number in complex literal pattern 3 | pass 4 | case x + 2j: | @@ -1108,7 +1108,7 @@ Module( 2 | case Foo() + 1j: 3 | pass 4 | case x + 2j: - | ^ Syntax Error: Expected a real number in complex literal pattern + | ^ Syntax Error: expected a real number in complex literal pattern 5 | pass 6 | case _ + 3j: | @@ -1118,7 +1118,7 @@ Module( 4 | case x + 2j: 5 | pass 6 | case _ + 3j: - | ^ Syntax Error: Expected a real number in complex literal pattern + | ^ Syntax Error: expected a real number in complex literal pattern 7 | pass 8 | case (1 | 2) + 4j: | @@ -1128,7 +1128,7 @@ Module( 6 | case _ + 3j: 7 | pass 8 | case (1 | 2) + 4j: - | ^^^^^ Syntax Error: Expected a real number in complex literal pattern + | ^^^^^ Syntax Error: expected a real number in complex literal pattern 9 | pass 10 | case [1, 2] + 5j: | @@ -1138,7 +1138,7 @@ Module( 8 | case (1 | 2) + 4j: 9 | pass 10 | case [1, 2] + 5j: - | ^^^^^^ Syntax Error: Expected a real number in complex literal pattern + | ^^^^^^ Syntax Error: expected a real number in complex literal pattern 11 | pass 12 | case {True: 1} + 6j: | @@ -1148,7 +1148,7 @@ Module( 10 | case [1, 2] + 5j: 11 | pass 12 | case {True: 1} + 6j: - | ^^^^^^^^^ Syntax Error: Expected a real number in complex literal pattern + | ^^^^^^^^^ Syntax Error: expected a real number in complex literal pattern 13 | pass 14 | case 1j + 2j: | @@ -1158,7 +1158,7 @@ Module( 12 | case {True: 1} + 6j: 13 | pass 14 | case 1j + 2j: - | ^^ Syntax Error: Expected a real number in complex literal pattern + | ^^ Syntax Error: expected a real number in complex literal pattern 15 | pass 16 | case -1j + 2j: | @@ -1168,7 +1168,7 @@ Module( 14 | case 1j + 2j: 15 | pass 16 | case -1j + 2j: - | ^^^ Syntax Error: Expected a real number in complex literal pattern + | ^^^ Syntax Error: expected a real number in complex literal pattern 17 | pass 18 | case Foo(a as b) + 1j: | @@ -1178,7 +1178,7 @@ Module( 16 | case -1j + 2j: 17 | pass 18 | case Foo(a as b) + 1j: - | ^^^^^^^^^^^ Syntax Error: Expected a real number in complex literal pattern + | ^^^^^^^^^^^ Syntax Error: expected a real number in complex literal pattern 19 | pass | @@ -1186,7 +1186,7 @@ Module( | 21 | match invalid_rhs_pattern: 22 | case 1 + Foo(): - | ^^^^^ Syntax Error: Expected an imaginary number in complex literal pattern + | ^^^^^ Syntax Error: expected an imaginary number in complex literal pattern 23 | pass 24 | case 2 + x: | @@ -1196,7 +1196,7 @@ Module( 22 | case 1 + Foo(): 23 | pass 24 | case 2 + x: - | ^ Syntax Error: Expected an imaginary number in complex literal pattern + | ^ Syntax Error: expected an imaginary number in complex literal pattern 25 | pass 26 | case 3 + _: | @@ -1206,7 +1206,7 @@ Module( 24 | case 2 + x: 25 | pass 26 | case 3 + _: - | ^ Syntax Error: Expected an imaginary number in complex literal pattern + | ^ Syntax Error: expected an imaginary number in complex literal pattern 27 | pass 28 | case 4 + (1 | 2): | @@ -1216,7 +1216,7 @@ Module( 26 | case 3 + _: 27 | pass 28 | case 4 + (1 | 2): - | ^^^^^ Syntax Error: Expected an imaginary number in complex literal pattern + | ^^^^^ Syntax Error: expected an imaginary number in complex literal pattern 29 | pass 30 | case 5 + [1, 2]: | @@ -1226,7 +1226,7 @@ Module( 28 | case 4 + (1 | 2): 29 | pass 30 | case 5 + [1, 2]: - | ^^^^^^ Syntax Error: Expected an imaginary number in complex literal pattern + | ^^^^^^ Syntax Error: expected an imaginary number in complex literal pattern 31 | pass 32 | case 6 + {True: 1}: | @@ -1236,7 +1236,7 @@ Module( 30 | case 5 + [1, 2]: 31 | pass 32 | case 6 + {True: 1}: - | ^^^^^^^^^ Syntax Error: Expected an imaginary number in complex literal pattern + | ^^^^^^^^^ Syntax Error: expected an imaginary number in complex literal pattern 33 | pass 34 | case 1 + 2: | @@ -1246,7 +1246,7 @@ Module( 32 | case 6 + {True: 1}: 33 | pass 34 | case 1 + 2: - | ^ Syntax Error: Expected an imaginary number in complex literal pattern + | ^ Syntax Error: expected an imaginary number in complex literal pattern 35 | pass 36 | case 1 + Foo(a as b): | @@ -1256,7 +1256,7 @@ Module( 34 | case 1 + 2: 35 | pass 36 | case 1 + Foo(a as b): - | ^^^^^^^^^^^ Syntax Error: Expected an imaginary number in complex literal pattern + | ^^^^^^^^^^^ Syntax Error: expected an imaginary number in complex literal pattern 37 | pass | @@ -1264,7 +1264,7 @@ Module( | 39 | match invalid_lhs_rhs_pattern: 40 | case Foo() + Bar(): - | ^^^^^ Syntax Error: Expected a real number in complex literal pattern + | ^^^^^ Syntax Error: expected a real number in complex literal pattern 41 | pass | @@ -1272,6 +1272,6 @@ Module( | 39 | match invalid_lhs_rhs_pattern: 40 | case Foo() + Bar(): - | ^^^^^ Syntax Error: Expected an imaginary number in complex literal pattern + | ^^^^^ Syntax Error: expected an imaginary number in complex literal pattern 41 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap index 7ba9ec9072c488..a91072687799be 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap @@ -557,7 +557,7 @@ Module( 1 | # Starred expression is not allowed as a mapping pattern key 2 | match subject: 3 | case {*key}: - | ^^^^ Syntax Error: Star pattern cannot be used here + | ^^^^ Syntax Error: cannot use starred expression here 4 | pass 5 | case {*key: 1}: | @@ -567,7 +567,7 @@ Module( 1 | # Starred expression is not allowed as a mapping pattern key 2 | match subject: 3 | case {*key}: - | ^ Syntax Error: Expected `:`, found `}` + | ^ Syntax Error: invalid syntax 4 | pass 5 | case {*key: 1}: | @@ -577,7 +577,7 @@ Module( 3 | case {*key}: 4 | pass 5 | case {*key: 1}: - | ^^^^ Syntax Error: Star pattern cannot be used here + | ^^^^ Syntax Error: cannot use starred expression here 6 | pass 7 | case {*key 1}: | @@ -587,7 +587,7 @@ Module( 5 | case {*key: 1}: 6 | pass 7 | case {*key 1}: - | ^^^^ Syntax Error: Star pattern cannot be used here + | ^^^^ Syntax Error: cannot use starred expression here 8 | pass 9 | case {*key, None: 1}: | @@ -597,7 +597,7 @@ Module( 5 | case {*key: 1}: 6 | pass 7 | case {*key 1}: - | ^ Syntax Error: Expected `:`, found int + | ^ Syntax Error: invalid syntax 8 | pass 9 | case {*key, None: 1}: | @@ -607,7 +607,7 @@ Module( 7 | case {*key 1}: 8 | pass 9 | case {*key, None: 1}: - | ^^^^ Syntax Error: Star pattern cannot be used here + | ^^^^ Syntax Error: cannot use starred expression here 10 | pass | @@ -616,7 +616,7 @@ Module( 7 | case {*key 1}: 8 | pass 9 | case {*key, None: 1}: - | ^ Syntax Error: Expected `:`, found `,` + | ^ Syntax Error: invalid syntax 10 | pass | @@ -625,7 +625,7 @@ Module( 13 | # Multiple double star patterns are not allowed 14 | match subject: 15 | case {**rest, None: 1}: - | ^^^^^^^ Syntax Error: Pattern cannot follow a double star pattern + | ^^^^^^^ Syntax Error: pattern cannot follow a double star pattern 16 | pass 17 | case {**rest1, **rest2, None: 1}: | @@ -635,7 +635,7 @@ Module( 15 | case {**rest, None: 1}: 16 | pass 17 | case {**rest1, **rest2, None: 1}: - | ^^^^^^^ Syntax Error: Only one double star pattern is allowed + | ^^^^^^^ Syntax Error: only one double star pattern is allowed 18 | pass 19 | case {**rest1, None: 1, **rest2}: | @@ -645,7 +645,7 @@ Module( 15 | case {**rest, None: 1}: 16 | pass 17 | case {**rest1, **rest2, None: 1}: - | ^^^^^^^ Syntax Error: Pattern cannot follow a double star pattern + | ^^^^^^^ Syntax Error: pattern cannot follow a double star pattern 18 | pass 19 | case {**rest1, None: 1, **rest2}: | @@ -655,7 +655,7 @@ Module( 17 | case {**rest1, **rest2, None: 1}: 18 | pass 19 | case {**rest1, None: 1, **rest2}: - | ^^^^^^^ Syntax Error: Pattern cannot follow a double star pattern + | ^^^^^^^ Syntax Error: pattern cannot follow a double star pattern 20 | pass | @@ -664,7 +664,7 @@ Module( 17 | case {**rest1, **rest2, None: 1}: 18 | pass 19 | case {**rest1, None: 1, **rest2}: - | ^^^^^^^ Syntax Error: Only one double star pattern is allowed + | ^^^^^^^ Syntax Error: only one double star pattern is allowed 20 | pass | @@ -672,4 +672,4 @@ Module( | 22 | match subject: 23 | case {Foo(a as b): 1}: ... - | ^^^^^^^^^^^ Syntax Error: Invalid mapping pattern key + | ^^^^^^^^^^^ Syntax Error: invalid mapping pattern key diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap index 0854b2275ed79a..ef901f062ad453 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap @@ -605,7 +605,7 @@ Module( 1 | # Star pattern is only allowed inside a sequence pattern 2 | match subject: 3 | case *_: - | ^^ Syntax Error: Star pattern cannot be used here + | ^^ Syntax Error: cannot use starred expression here 4 | pass 5 | case *_ as x: | @@ -615,7 +615,7 @@ Module( 3 | case *_: 4 | pass 5 | case *_ as x: - | ^^ Syntax Error: Star pattern cannot be used here + | ^^ Syntax Error: cannot use starred expression here 6 | pass 7 | case *foo: | @@ -625,7 +625,7 @@ Module( 5 | case *_ as x: 6 | pass 7 | case *foo: - | ^^^^ Syntax Error: Star pattern cannot be used here + | ^^^^ Syntax Error: cannot use starred expression here 8 | pass 9 | case *foo | 1: | @@ -635,7 +635,7 @@ Module( 7 | case *foo: 8 | pass 9 | case *foo | 1: - | ^^^^ Syntax Error: Star pattern cannot be used here + | ^^^^ Syntax Error: cannot use starred expression here 10 | pass 11 | case 1 | *foo: | @@ -645,7 +645,7 @@ Module( 9 | case *foo | 1: 10 | pass 11 | case 1 | *foo: - | ^^^^ Syntax Error: Star pattern cannot be used here + | ^^^^ Syntax Error: cannot use starred expression here 12 | pass 13 | case Foo(*_): | @@ -655,7 +655,7 @@ Module( 11 | case 1 | *foo: 12 | pass 13 | case Foo(*_): - | ^^ Syntax Error: Star pattern cannot be used here + | ^^ Syntax Error: cannot use starred expression here 14 | pass 15 | case Foo(x=*_): | @@ -665,7 +665,7 @@ Module( 13 | case Foo(*_): 14 | pass 15 | case Foo(x=*_): - | ^^ Syntax Error: Star pattern cannot be used here + | ^^ Syntax Error: cannot use starred expression here 16 | pass 17 | case {*_}: | @@ -675,7 +675,7 @@ Module( 15 | case Foo(x=*_): 16 | pass 17 | case {*_}: - | ^^ Syntax Error: Star pattern cannot be used here + | ^^ Syntax Error: cannot use starred expression here 18 | pass 19 | case {*_: 1}: | @@ -685,7 +685,7 @@ Module( 15 | case Foo(x=*_): 16 | pass 17 | case {*_}: - | ^ Syntax Error: Expected `:`, found `}` + | ^ Syntax Error: invalid syntax 18 | pass 19 | case {*_: 1}: | @@ -695,7 +695,7 @@ Module( 17 | case {*_}: 18 | pass 19 | case {*_: 1}: - | ^^ Syntax Error: Star pattern cannot be used here + | ^^ Syntax Error: cannot use starred expression here 20 | pass 21 | case {None: *_}: | @@ -705,7 +705,7 @@ Module( 19 | case {*_: 1}: 20 | pass 21 | case {None: *_}: - | ^^ Syntax Error: Star pattern cannot be used here + | ^^ Syntax Error: cannot use starred expression here 22 | pass 23 | case 1 + *_: | @@ -715,7 +715,7 @@ Module( 21 | case {None: *_}: 22 | pass 23 | case 1 + *_: - | ^^ Syntax Error: Star pattern cannot be used here + | ^^ Syntax Error: cannot use starred expression here 24 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__unary_add_usage.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__unary_add_usage.py.snap index 297c045622e79b..148fe1bfa68798 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__unary_add_usage.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__unary_add_usage.py.snap @@ -422,7 +422,7 @@ Module( 1 | # Unary addition isn't allowed before Python 3.15. 2 | match subject: 3 | case +1: - | ^^ Syntax Error: Unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) 4 | pass 5 | case 1 | +2 | -3: | @@ -432,7 +432,7 @@ Module( 3 | case +1: 4 | pass 5 | case 1 | +2 | -3: - | ^^ Syntax Error: Unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) 6 | pass 7 | case [1, +2, -3]: | @@ -442,7 +442,7 @@ Module( 5 | case 1 | +2 | -3: 6 | pass 7 | case [1, +2, -3]: - | ^^ Syntax Error: Unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) 8 | pass 9 | case Foo(x=+1, y=-2): | @@ -452,7 +452,7 @@ Module( 7 | case [1, +2, -3]: 8 | pass 9 | case Foo(x=+1, y=-2): - | ^^ Syntax Error: Unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) 10 | pass 11 | case {True: +1, False: -2}: | @@ -462,6 +462,6 @@ Module( 9 | case Foo(x=+1, y=-2): 10 | pass 11 | case {True: +1, False: -2}: - | ^^ Syntax Error: Unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) 12 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap index 849ef085449a7d..9d6fb221fb52f9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap @@ -1672,7 +1672,7 @@ Module( 2 | # These cases should raise the correct syntax error and recover properly. 3 | 4 | with (item1, item2),: ... - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses 5 | with (item1, item2), as f: ... 6 | with (item1, item2), item3,: ... | @@ -1681,7 +1681,7 @@ Module( | 4 | with (item1, item2),: ... 5 | with (item1, item2), as f: ... - | ^^ Syntax Error: Expected `,`, found `as` + | ^^ Syntax Error: invalid syntax 6 | with (item1, item2), item3,: ... 7 | with (*item): ... | @@ -1691,7 +1691,7 @@ Module( 4 | with (item1, item2),: ... 5 | with (item1, item2), as f: ... 6 | with (item1, item2), item3,: ... - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses 7 | with (*item): ... 8 | with (*item) as f: ... | @@ -1701,7 +1701,7 @@ Module( 5 | with (item1, item2), as f: ... 6 | with (item1, item2), item3,: ... 7 | with (*item): ... - | ^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^ Syntax Error: invalid syntax 8 | with (*item) as f: ... 9 | with (item := 10 as f): ... | @@ -1711,7 +1711,7 @@ Module( 6 | with (item1, item2), item3,: ... 7 | with (*item): ... 8 | with (*item) as f: ... - | ^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^ Syntax Error: invalid syntax 9 | with (item := 10 as f): ... 10 | with (item1, item2 := 10 as f): ... | @@ -1721,7 +1721,7 @@ Module( 7 | with (*item): ... 8 | with (*item) as f: ... 9 | with (item := 10 as f): ... - | ^^^^^^^^^^ Syntax Error: Unparenthesized named expression cannot be used here + | ^^^^^^^^^^ Syntax Error: unparenthesized named expression cannot be used here 10 | with (item1, item2 := 10 as f): ... 11 | with (x for x in range(10), item): ... | @@ -1731,7 +1731,7 @@ Module( 8 | with (*item) as f: ... 9 | with (item := 10 as f): ... 10 | with (item1, item2 := 10 as f): ... - | ^^^^^^^^^^^ Syntax Error: Unparenthesized named expression cannot be used here + | ^^^^^^^^^^^ Syntax Error: unparenthesized named expression cannot be used here 11 | with (x for x in range(10), item): ... 12 | with (item, x for x in range(10)): ... | @@ -1741,7 +1741,7 @@ Module( 9 | with (item := 10 as f): ... 10 | with (item1, item2 := 10 as f): ... 11 | with (x for x in range(10), item): ... - | ^ Syntax Error: Expected `)`, found `,` + | ^ Syntax Error: invalid syntax 12 | with (item, x for x in range(10)): ... | @@ -1750,7 +1750,7 @@ Module( 9 | with (item := 10 as f): ... 10 | with (item1, item2 := 10 as f): ... 11 | with (x for x in range(10), item): ... - | ^ Syntax Error: Expected `,`, found `)` + | ^ Syntax Error: invalid syntax 12 | with (item, x for x in range(10)): ... | @@ -1759,7 +1759,7 @@ Module( 10 | with (item1, item2 := 10 as f): ... 11 | with (x for x in range(10), item): ... 12 | with (item, x for x in range(10)): ... - | ^^^ Syntax Error: Expected `)`, found `for` + | ^^^ Syntax Error: invalid syntax 13 | 14 | # Make sure the parser doesn't report the same error twice | @@ -1769,7 +1769,7 @@ Module( 10 | with (item1, item2 := 10 as f): ... 11 | with (x for x in range(10), item): ... 12 | with (item, x for x in range(10)): ... - | ^ Syntax Error: Expected `:`, found `)` + | ^ Syntax Error: invalid syntax 13 | 14 | # Make sure the parser doesn't report the same error twice | @@ -1779,7 +1779,7 @@ Module( 10 | with (item1, item2 := 10 as f): ... 11 | with (x for x in range(10), item): ... 12 | with (item, x for x in range(10)): ... - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 13 | 14 | # Make sure the parser doesn't report the same error twice | @@ -1788,7 +1788,7 @@ Module( | 14 | # Make sure the parser doesn't report the same error twice 15 | with ((*item)): ... - | ^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^ Syntax Error: invalid syntax 16 | 17 | with (*x for x in iter, item): ... | @@ -1798,7 +1798,7 @@ Module( 15 | with ((*item)): ... 16 | 17 | with (*x for x in iter, item): ... - | ^ Syntax Error: Expected `)`, found `,` + | ^ Syntax Error: invalid syntax 18 | with (item1, *x for x in iter, item2): ... 19 | with (x as f, *y): ... | @@ -1808,7 +1808,7 @@ Module( 15 | with ((*item)): ... 16 | 17 | with (*x for x in iter, item): ... - | ^ Syntax Error: Expected `,`, found `)` + | ^ Syntax Error: invalid syntax 18 | with (item1, *x for x in iter, item2): ... 19 | with (x as f, *y): ... | @@ -1817,7 +1817,7 @@ Module( | 17 | with (*x for x in iter, item): ... 18 | with (item1, *x for x in iter, item2): ... - | ^^^ Syntax Error: Expected `)`, found `for` + | ^^^ Syntax Error: invalid syntax 19 | with (x as f, *y): ... 20 | with (*x, y as f): ... | @@ -1826,7 +1826,7 @@ Module( | 17 | with (*x for x in iter, item): ... 18 | with (item1, *x for x in iter, item2): ... - | ^ Syntax Error: Expected `:`, found `)` + | ^ Syntax Error: invalid syntax 19 | with (x as f, *y): ... 20 | with (*x, y as f): ... | @@ -1835,7 +1835,7 @@ Module( | 17 | with (*x for x in iter, item): ... 18 | with (item1, *x for x in iter, item2): ... - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 19 | with (x as f, *y): ... 20 | with (*x, y as f): ... | @@ -1845,7 +1845,7 @@ Module( 17 | with (*x for x in iter, item): ... 18 | with (item1, *x for x in iter, item2): ... 19 | with (x as f, *y): ... - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 20 | with (*x, y as f): ... 21 | with (x, yield y): ... | @@ -1855,7 +1855,7 @@ Module( 18 | with (item1, *x for x in iter, item2): ... 19 | with (x as f, *y): ... 20 | with (*x, y as f): ... - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 21 | with (x, yield y): ... 22 | with (x, yield y, z): ... | @@ -1865,7 +1865,7 @@ Module( 19 | with (x as f, *y): ... 20 | with (*x, y as f): ... 21 | with (x, yield y): ... - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 22 | with (x, yield y, z): ... 23 | with (x, yield from y): ... | @@ -1875,7 +1875,7 @@ Module( 20 | with (*x, y as f): ... 21 | with (x, yield y): ... 22 | with (x, yield y, z): ... - | ^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^ Syntax Error: yield expression cannot be used here 23 | with (x, yield from y): ... 24 | with (x as f, y) as f: ... | @@ -1885,7 +1885,7 @@ Module( 21 | with (x, yield y): ... 22 | with (x, yield y, z): ... 23 | with (x, yield from y): ... - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 24 | with (x as f, y) as f: ... 25 | with (x for x in iter as y): ... | @@ -1895,7 +1895,7 @@ Module( 22 | with (x, yield y, z): ... 23 | with (x, yield from y): ... 24 | with (x as f, y) as f: ... - | ^^ Syntax Error: Expected `:`, found `as` + | ^^ Syntax Error: invalid syntax 25 | with (x for x in iter as y): ... | @@ -1904,7 +1904,7 @@ Module( 23 | with (x, yield from y): ... 24 | with (x as f, y) as f: ... 25 | with (x for x in iter as y): ... - | ^^ Syntax Error: Expected `)`, found `as` + | ^^ Syntax Error: invalid syntax 26 | 27 | # The inner `(...)` is parsed as parenthesized expression | @@ -1914,7 +1914,7 @@ Module( 23 | with (x, yield from y): ... 24 | with (x as f, y) as f: ... 25 | with (x for x in iter as y): ... - | ^ Syntax Error: Expected `,`, found `)` + | ^ Syntax Error: invalid syntax 26 | 27 | # The inner `(...)` is parsed as parenthesized expression | @@ -1923,7 +1923,7 @@ Module( | 27 | # The inner `(...)` is parsed as parenthesized expression 28 | with ((item as f)): ... - | ^^ Syntax Error: Expected `)`, found `as` + | ^^ Syntax Error: invalid syntax 29 | 30 | with (item as f), x: ... | @@ -1932,7 +1932,7 @@ Module( | 27 | # The inner `(...)` is parsed as parenthesized expression 28 | with ((item as f)): ... - | ^ Syntax Error: Expected `:`, found `)` + | ^ Syntax Error: invalid syntax 29 | 30 | with (item as f), x: ... | @@ -1941,7 +1941,7 @@ Module( | 27 | # The inner `(...)` is parsed as parenthesized expression 28 | with ((item as f)): ... - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 29 | 30 | with (item as f), x: ... | @@ -1951,7 +1951,7 @@ Module( 28 | with ((item as f)): ... 29 | 30 | with (item as f), x: ... - | ^ Syntax Error: Expected `:`, found `,` + | ^ Syntax Error: invalid syntax 31 | with (item as f1) as f2: ... 32 | with (item1 as f, item2 := 0): ... | @@ -1960,7 +1960,7 @@ Module( | 30 | with (item as f), x: ... 31 | with (item as f1) as f2: ... - | ^^ Syntax Error: Expected `:`, found `as` + | ^^ Syntax Error: invalid syntax 32 | with (item1 as f, item2 := 0): ... | @@ -1969,7 +1969,7 @@ Module( 30 | with (item as f), x: ... 31 | with (item as f1) as f2: ... 32 | with (item1 as f, item2 := 0): ... - | ^^^^^^^^^^ Syntax Error: Unparenthesized named expression cannot be used here + | ^^^^^^^^^^ Syntax Error: unparenthesized named expression cannot be used here ## Unsupported Syntax Errors @@ -1978,7 +1978,7 @@ Module( 15 | with ((*item)): ... 16 | 17 | with (*x for x in iter, item): ... - | ^^ Syntax Error: Cannot use iterable unpacking in a generator expression on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: cannot use iterable unpacking in a generator expression on Python 3.14 (syntax was added in Python 3.15) 18 | with (item1, *x for x in iter, item2): ... 19 | with (x as f, *y): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap index 90788327da591d..11f216a0db7c4e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__empty_with_items.py.snap @@ -75,7 +75,7 @@ Module( 2 | # The parser should recover from this syntax error. 3 | 4 | with : ... - | ^ Syntax Error: Expected the start of an expression after `with` keyword + | ^ Syntax Error: expected the start of an expression after `with` keyword 5 | 6 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap index c682d058a43010..5953861fe55db7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap @@ -75,7 +75,7 @@ Module( | 1 | with (: - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | 3 | x + y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap index eb6936881a9c4b..3edbdea2bf05d2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap @@ -365,7 +365,7 @@ Module( 1 | # For parenthesized with items test cases, refer to `./ambiguous_lpar_with_items.py` 2 | 3 | with item,: pass - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses 4 | with item as x,: pass 5 | with *item: pass | @@ -374,7 +374,7 @@ Module( | 3 | with item,: pass 4 | with item as x,: pass - | ^ Syntax Error: Trailing comma not allowed + | ^ Syntax Error: trailing comma not allowed without surrounding parentheses 5 | with *item: pass 6 | with *item as x: pass | @@ -384,7 +384,7 @@ Module( 3 | with item,: pass 4 | with item as x,: pass 5 | with *item: pass - | ^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^ Syntax Error: invalid syntax 6 | with *item as x: pass 7 | with *item1, item2 as f: pass | @@ -394,7 +394,7 @@ Module( 4 | with item as x,: pass 5 | with *item: pass 6 | with *item as x: pass - | ^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^ Syntax Error: invalid syntax 7 | with *item1, item2 as f: pass 8 | with item1 as f, *item2: pass | @@ -404,7 +404,7 @@ Module( 5 | with *item: pass 6 | with *item as x: pass 7 | with *item1, item2 as f: pass - | ^^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^^ Syntax Error: invalid syntax 8 | with item1 as f, *item2: pass 9 | with item := 0 as f: pass | @@ -414,7 +414,7 @@ Module( 6 | with *item as x: pass 7 | with *item1, item2 as f: pass 8 | with item1 as f, *item2: pass - | ^^^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^^^ Syntax Error: invalid syntax 9 | with item := 0 as f: pass | @@ -423,4 +423,4 @@ Module( 7 | with *item1, item2 as f: pass 8 | with item1 as f, *item2: pass 9 | with item := 0 as f: pass - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap index b138de089a545d..e85b2a2b431738 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap @@ -120,7 +120,7 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{}" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | t"{ }" | @@ -129,4 +129,4 @@ Module( 1 | # parse_options: {"target-version": "3.14"} 2 | t"{}" 3 | t"{ }" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap index f3c92736014517..41986a4f100d6e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap @@ -218,7 +218,7 @@ Module( 1 | # parse_options: {"target-version": "3.14"} 2 | # Starred expression inside t-string has a minimum precedence of bitwise or. 3 | t"{*}" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | t"{*x and y}" 5 | t"{*yield x}" | @@ -228,7 +228,7 @@ Module( 2 | # Starred expression inside t-string has a minimum precedence of bitwise or. 3 | t"{*}" 4 | t"{*x and y}" - | ^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^ Syntax Error: boolean expression cannot be used here 5 | t"{*yield x}" | @@ -237,4 +237,4 @@ Module( 3 | t"{*}" 4 | t"{*x and y}" 5 | t"{*yield x}" - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap index 58295a06342f33..39f9843333b4bb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap @@ -113,7 +113,7 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{lambda x: x}" - | ^^ Syntax Error: Expected an expression + | ^^ Syntax Error: invalid syntax | @@ -125,10 +125,10 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{lambda x: x}" - | ^^ Syntax Error: t-string: expecting `}` + | ^^ Syntax Error: t-string: expecting '}' | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{lambda x: x}" - | ^ Syntax Error: Expected an element of or the end of the t-string + | ^ Syntax Error: expected an element of or the end of the t-string diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap index 537d55c71ce186..93b4726089e99f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap @@ -276,7 +276,7 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | t"{foo!r" 4 | t"{foo=" | @@ -286,7 +286,7 @@ Module( 1 | # parse_options: {"target-version": "3.14"} 2 | t"{" 3 | t"{foo!r" - | ^ Syntax Error: t-string: expecting `}` + | ^ Syntax Error: t-string: expecting '}' 4 | t"{foo=" 5 | t"{" | @@ -296,7 +296,7 @@ Module( 2 | t"{" 3 | t"{foo!r" 4 | t"{foo=" - | ^ Syntax Error: t-string: expecting `}` + | ^ Syntax Error: t-string: expecting '}' 5 | t"{" 6 | t"""{""" | @@ -306,7 +306,7 @@ Module( 3 | t"{foo!r" 4 | t"{foo=" 5 | t"{" - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 6 | t"""{""" | @@ -315,4 +315,4 @@ Module( 4 | t"{foo=" 5 | t"{" 6 | t"""{""" - | ^^^ Syntax Error: Expected an expression + | ^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap index e03d8fd7a80fc3..108c8a1b2626d8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap @@ -154,7 +154,7 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | t"hello {x:" - | ^ Syntax Error: t-string: expecting `}` + | ^ Syntax Error: t-string: expecting '}' 3 | t"hello {x:.3f" | @@ -163,4 +163,4 @@ Module( 1 | # parse_options: {"target-version": "3.14"} 2 | t"hello {x:" 3 | t"hello {x:.3f" - | ^ Syntax Error: t-string: expecting `}` + | ^ Syntax Error: t-string: expecting '}' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@template_strings_py313.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@template_strings_py313.py.snap index 71a16208b62b55..0057e63eaae679 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@template_strings_py313.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@template_strings_py313.py.snap @@ -157,7 +157,7 @@ Module( | 1 | # parse_options: {"target-version": "3.13"} 2 | t"{hey}" - | ^^^^^^^^ Syntax Error: Cannot use t-strings on Python 3.13 (syntax was added in Python 3.14) + | ^^^^^^^^ Syntax Error: cannot use t-strings on Python 3.13 (syntax was added in Python 3.14) 3 | t'{there}' 4 | t"""what's | @@ -167,7 +167,7 @@ Module( 1 | # parse_options: {"target-version": "3.13"} 2 | t"{hey}" 3 | t'{there}' - | ^^^^^^^^^^ Syntax Error: Cannot use t-strings on Python 3.13 (syntax was added in Python 3.14) + | ^^^^^^^^^^ Syntax Error: cannot use t-strings on Python 3.13 (syntax was added in Python 3.14) 4 | t"""what's 5 | happening?""" | @@ -178,4 +178,4 @@ Module( 3 | t'{there}' 4 | / t"""what's 5 | | happening?""" - | |_____________^ Syntax Error: Cannot use t-strings on Python 3.13 (syntax was added in Python 3.14) + | |_____________^ Syntax Error: cannot use t-strings on Python 3.13 (syntax was added in Python 3.14) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap index 29a0b9d0424c84..5bdd7806fe646a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap @@ -65,7 +65,7 @@ Module( 3 | finally: 4 | pass 5 | else: - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 6 | pass | @@ -74,7 +74,7 @@ Module( 3 | finally: 4 | pass 5 | else: - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 6 | pass | @@ -83,4 +83,4 @@ Module( 4 | pass 5 | else: 6 | pass - | ^^^^ Syntax Error: Unexpected indentation + | ^^^^ Syntax Error: unexpected indentation diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap index 796dc5b05160e0..30a78f23d4cc9c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_missing_except_finally.py.snap @@ -72,7 +72,7 @@ Module( 1 | try: 2 | pass 3 | try: - | ^^^ Syntax Error: Expected `except` or `finally` after `try` block + | ^^^ Syntax Error: expected 'except' or 'finally' block 4 | pass 5 | else: | @@ -81,4 +81,4 @@ Module( | 5 | else: 6 | pass - | ^ Syntax Error: Expected `except` or `finally` after `try` block + | ^ Syntax Error: expected 'except' or 'finally' block 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 e47df6f48a6b2f..2d4d0f0d9578f6 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 @@ -207,7 +207,7 @@ Module( 1 | try: 2 | pass 3 | exept: # spellchecker:disable-line - | ^^^^^ Syntax Error: Expected `except` or `finally` after `try` block + | ^^^^^ Syntax Error: expected 'except' or 'finally' block 4 | pass 5 | finally: | @@ -217,7 +217,7 @@ Module( 1 | try: 2 | pass 3 | exept: # spellchecker:disable-line - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 4 | pass 5 | finally: 6 | pass @@ -228,7 +228,7 @@ Module( 2 | pass 3 | exept: # spellchecker:disable-line 4 | pass - | ^^^^ Syntax Error: Unexpected indentation + | ^^^^ Syntax Error: unexpected indentation 5 | finally: 6 | pass | @@ -238,7 +238,7 @@ Module( 3 | exept: # spellchecker:disable-line 4 | pass 5 | finally: - | ^^^^^^^ Syntax Error: Expected a statement + | ^^^^^^^ Syntax Error: invalid syntax 6 | pass 7 | a = 1 | @@ -248,7 +248,7 @@ Module( 3 | exept: # spellchecker:disable-line 4 | pass 5 | finally: - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 6 | pass 7 | a = 1 | @@ -258,7 +258,7 @@ Module( 3 | exept: # spellchecker:disable-line 4 | pass 5 | finally: - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax 6 | pass 7 | a = 1 8 | try: @@ -269,7 +269,7 @@ Module( 4 | pass 5 | finally: 6 | pass - | ^^^^ Syntax Error: Unexpected indentation + | ^^^^ Syntax Error: unexpected indentation 7 | a = 1 8 | try: | @@ -279,7 +279,7 @@ Module( 10 | except: 11 | pass 12 | exept: # spellchecker:disable-line - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 13 | pass 14 | b = 1 | @@ -289,6 +289,6 @@ Module( 11 | pass 12 | exept: # spellchecker:disable-line 13 | pass - | ^^^^ Syntax Error: Unexpected indentation + | ^^^^ Syntax Error: unexpected indentation 14 | b = 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap index 7b4ed7c1d41cee..ea4fb660b76b45 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap @@ -263,7 +263,7 @@ Module( 4 | pass 5 | / except* ExceptionGroup: 6 | | pass - | |________^ Syntax Error: Cannot have both 'except' and 'except*' on the same 'try' + | |________^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' 7 | try: 8 | pass | @@ -274,7 +274,7 @@ Module( 10 | pass 11 | / except: 12 | | pass - | |________^ Syntax Error: Cannot have both 'except' and 'except*' on the same 'try' + | |________^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' 13 | try: 14 | pass | @@ -285,7 +285,7 @@ Module( 18 | pass 19 | / except* ExceptionGroup: 20 | | pass - | |________^ Syntax Error: Cannot have both 'except' and 'except*' on the same 'try' + | |________^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' 21 | except* ExceptionGroup: 22 | pass | @@ -296,4 +296,4 @@ Module( 20 | pass 21 | / except* ExceptionGroup: 22 | | pass - | |________^ Syntax Error: Cannot have both 'except' and 'except*' on the same 'try' + | |________^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@tuple_context_manager_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@tuple_context_manager_py38.py.snap index 1789f423bc3177..a1c1b2cf1cfd2e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@tuple_context_manager_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@tuple_context_manager_py38.py.snap @@ -177,7 +177,7 @@ Module( 3 | # is parsed as a tuple, but this will always cause a runtime error, so we flag it 4 | # anyway 5 | with (foo, bar): ... - | ^ Syntax Error: Cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) + | ^ Syntax Error: cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) 6 | with ( 7 | foo, | @@ -187,7 +187,7 @@ Module( 4 | # anyway 5 | with (foo, bar): ... 6 | with ( - | ^ Syntax Error: Cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) + | ^ Syntax Error: cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) 7 | foo, 8 | bar, | @@ -197,4 +197,4 @@ Module( 9 | baz, 10 | ): ... 11 | with (foo,): ... - | ^ Syntax Error: Cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) + | ^ Syntax Error: cannot use parentheses within a `with` statement on Python 3.8 (syntax was added in Python 3.9) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_incomplete_stmt.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_incomplete_stmt.py.snap index 5cf9ea4c23dc70..10a95030c036ec 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_incomplete_stmt.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_incomplete_stmt.py.snap @@ -85,7 +85,7 @@ Module( | 1 | type 2 | type x - | ^ Syntax Error: Simple statements must be separated by newlines or semicolons + | ^ Syntax Error: invalid syntax 3 | type x = | @@ -94,4 +94,4 @@ Module( 1 | type 2 | type x 3 | type x = - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap index 302d83f26ab43d..2b09be956bcd8f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap @@ -147,7 +147,7 @@ Module( | 1 | type x = *y - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | type x = yield y 3 | type x = yield from y | @@ -156,7 +156,7 @@ Module( | 1 | type x = *y 2 | type x = yield y - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | type x = yield from y 4 | type x = x := 1 | @@ -166,7 +166,7 @@ Module( 1 | type x = *y 2 | type x = yield y 3 | type x = yield from y - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 4 | type x = x := 1 | @@ -175,7 +175,7 @@ Module( 2 | type x = yield y 3 | type x = yield from y 4 | type x = x := 1 - | ^^ Syntax Error: Expected a statement + | ^^ Syntax Error: invalid syntax ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_default_py312.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_default_py312.py.snap index 8e630eef9a60ff..30a205299a7170 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_default_py312.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_default_py312.py.snap @@ -319,7 +319,7 @@ Module( | 1 | # parse_options: {"target-version": "3.12"} 2 | type X[T = int] = int - | ^^^^^ Syntax Error: Cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) + | ^^^^^ Syntax Error: cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) 3 | def f[T = int](): ... 4 | class C[T = int](): ... | @@ -329,7 +329,7 @@ Module( 1 | # parse_options: {"target-version": "3.12"} 2 | type X[T = int] = int 3 | def f[T = int](): ... - | ^^^^^ Syntax Error: Cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) + | ^^^^^ Syntax Error: cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) 4 | class C[T = int](): ... 5 | class D[S, T = int, U = uint](): ... | @@ -339,7 +339,7 @@ Module( 2 | type X[T = int] = int 3 | def f[T = int](): ... 4 | class C[T = int](): ... - | ^^^^^ Syntax Error: Cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) + | ^^^^^ Syntax Error: cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) 5 | class D[S, T = int, U = uint](): ... | @@ -348,11 +348,11 @@ Module( 3 | def f[T = int](): ... 4 | class C[T = int](): ... 5 | class D[S, T = int, U = uint](): ... - | ^^^^^ Syntax Error: Cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) + | ^^^^^ Syntax Error: cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) | 3 | def f[T = int](): ... 4 | class C[T = int](): ... 5 | class D[S, T = int, U = uint](): ... - | ^^^^^^ Syntax Error: Cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) + | ^^^^^^ Syntax Error: cannot set default type for a type parameter on Python 3.12 (syntax was added in Python 3.13) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap index 7ec11225128792..3a73f9342946ff 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap @@ -265,7 +265,7 @@ Module( | 1 | type X[T: *int] = int - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | type X[T: yield x] = int 3 | type X[T: yield from x] = int | @@ -274,7 +274,7 @@ Module( | 1 | type X[T: *int] = int 2 | type X[T: yield x] = int - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | type X[T: yield from x] = int 4 | type X[T: x := int] = int | @@ -284,7 +284,7 @@ Module( 1 | type X[T: *int] = int 2 | type X[T: yield x] = int 3 | type X[T: yield from x] = int - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 4 | type X[T: x := int] = int | @@ -293,7 +293,7 @@ Module( 2 | type X[T: yield x] = int 3 | type X[T: yield from x] = int 4 | type X[T: x := int] = int - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_missing_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_missing_bound.py.snap index 3bd6e7b34d27ac..ddef708e42c2a4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_missing_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_missing_bound.py.snap @@ -120,7 +120,7 @@ Module( | 1 | type X[T: ] = int - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | type X[T1: , T2] = int | @@ -128,4 +128,4 @@ Module( | 1 | type X[T: ] = int 2 | type X[T1: , T2] = int - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap index 670dbc560125cb..3e32e5024e0d75 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap @@ -90,14 +90,14 @@ Module( | 1 | type X[**T: int] = int - | ^ Syntax Error: Expected `]`, found `:` + | ^ Syntax Error: invalid syntax | 1 | type X[**T: int] = int - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax | 1 | type X[**T: int] = int - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap index fea0747299472e..65da3fc9ffae79 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap @@ -320,7 +320,7 @@ Module( | 1 | type X[**P = *int] = int - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | type X[**P = yield x] = int 3 | type X[**P = yield from x] = int | @@ -329,7 +329,7 @@ Module( | 1 | type X[**P = *int] = int 2 | type X[**P = yield x] = int - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | type X[**P = yield from x] = int 4 | type X[**P = x := int] = int | @@ -339,7 +339,7 @@ Module( 1 | type X[**P = *int] = int 2 | type X[**P = yield x] = int 3 | type X[**P = yield from x] = int - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 4 | type X[**P = x := int] = int 5 | type X[**P = *int] = int | @@ -349,7 +349,7 @@ Module( 2 | type X[**P = yield x] = int 3 | type X[**P = yield from x] = int 4 | type X[**P = x := int] = int - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax 5 | type X[**P = *int] = int | @@ -358,7 +358,7 @@ Module( 3 | type X[**P = yield from x] = int 4 | type X[**P = x := int] = int 5 | type X[**P = *int] = int - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_missing_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_missing_default.py.snap index a98c4db657d70f..0816d27e5cc73a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_missing_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_missing_default.py.snap @@ -118,7 +118,7 @@ Module( | 1 | type X[**P =] = int - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | type X[**P =, T2] = int | @@ -126,4 +126,4 @@ Module( | 1 | type X[**P =] = int 2 | type X[**P =, T2] = int - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap index f091bb8470c599..7ac76453f879d3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap @@ -395,7 +395,7 @@ Module( | 1 | type X[T = *int] = int - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax 2 | type X[T = yield x] = int 3 | type X[T = (yield x)] = int | @@ -404,7 +404,7 @@ Module( | 1 | type X[T = *int] = int 2 | type X[T = yield x] = int - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | type X[T = (yield x)] = int 4 | type X[T = yield from x] = int | @@ -414,7 +414,7 @@ Module( 2 | type X[T = yield x] = int 3 | type X[T = (yield x)] = int 4 | type X[T = yield from x] = int - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 5 | type X[T = x := int] = int 6 | type X[T: int = *int] = int | @@ -424,7 +424,7 @@ Module( 3 | type X[T = (yield x)] = int 4 | type X[T = yield from x] = int 5 | type X[T = x := int] = int - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax 6 | type X[T: int = *int] = int | @@ -433,7 +433,7 @@ Module( 4 | type X[T = yield from x] = int 5 | type X[T = x := int] = int 6 | type X[T: int = *int] = int - | ^^^^ Syntax Error: Starred expression cannot be used here + | ^^^^ Syntax Error: invalid syntax ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_missing_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_missing_default.py.snap index b8955671641f8b..6e5a73174a3cd3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_missing_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_missing_default.py.snap @@ -173,7 +173,7 @@ Module( | 1 | type X[T =] = int - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | type X[T: int =] = int 3 | type X[T1 =, T2] = int | @@ -182,7 +182,7 @@ Module( | 1 | type X[T =] = int 2 | type X[T: int =] = int - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | type X[T1 =, T2] = int | @@ -191,4 +191,4 @@ Module( 1 | type X[T =] = int 2 | type X[T: int =] = int 3 | type X[T1 =, T2] = int - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap index fc3e1910bc06ff..22bcd6034e84f2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap @@ -90,14 +90,14 @@ Module( | 1 | type X[*T: int] = int - | ^ Syntax Error: Expected `]`, found `:` + | ^ Syntax Error: invalid syntax | 1 | type X[*T: int] = int - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax | 1 | type X[*T: int] = int - | ^ Syntax Error: Expected a statement + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_invalid_default_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_invalid_default_expr.py.snap index 27b9a9e9be2794..92f4aedccb9182 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_invalid_default_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_invalid_default_expr.py.snap @@ -339,7 +339,7 @@ Module( | 1 | type X[*Ts = *int] = int 2 | type X[*Ts = *int or str] = int - | ^^^^^^^^^^ Syntax Error: Boolean expression cannot be used here + | ^^^^^^^^^^ Syntax Error: boolean expression cannot be used here 3 | type X[*Ts = yield x] = int 4 | type X[*Ts = yield from x] = int | @@ -349,7 +349,7 @@ Module( 1 | type X[*Ts = *int] = int 2 | type X[*Ts = *int or str] = int 3 | type X[*Ts = yield x] = int - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 4 | type X[*Ts = yield from x] = int 5 | type X[*Ts = x := int] = int | @@ -359,7 +359,7 @@ Module( 2 | type X[*Ts = *int or str] = int 3 | type X[*Ts = yield x] = int 4 | type X[*Ts = yield from x] = int - | ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here 5 | type X[*Ts = x := int] = int | @@ -368,7 +368,7 @@ Module( 3 | type X[*Ts = yield x] = int 4 | type X[*Ts = yield from x] = int 5 | type X[*Ts = x := int] = int - | ^^ Syntax Error: Expected `,`, found `:=` + | ^^ Syntax Error: invalid syntax ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_missing_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_missing_default.py.snap index 5154228ced2b90..36cd85871dbd6f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_missing_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_missing_default.py.snap @@ -118,7 +118,7 @@ Module( | 1 | type X[*Ts =] = int - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | type X[*Ts =, T2] = int | @@ -126,4 +126,4 @@ Module( | 1 | type X[*Ts =] = int 2 | type X[*Ts =, T2] = int - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_stmt_py311.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_stmt_py311.py.snap index 254f5836b8055c..0078e0f1432598 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_stmt_py311.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_stmt_py311.py.snap @@ -43,4 +43,4 @@ Module( | 1 | # parse_options: {"target-version": "3.11"} 2 | type x = int - | ^^^^ Syntax Error: Cannot use `type` alias statement on Python 3.11 (syntax was added in Python 3.12) + | ^^^^ Syntax Error: cannot use `type` alias statement on Python 3.11 (syntax was added in Python 3.12) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unary_plus_py314.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unary_plus_py314.py.snap index 3f068733eddc1e..416357a4c4f9ae 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unary_plus_py314.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unary_plus_py314.py.snap @@ -143,7 +143,7 @@ Module( 1 | # parse_options: {"target-version": "3.14"} 2 | match foo: 3 | case +1: ... - | ^^ Syntax Error: Unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) 4 | case {+1: 2}: ... | @@ -152,4 +152,4 @@ Module( 2 | match foo: 3 | case +1: ... 4 | case {+1: 2}: ... - | ^^ Syntax Error: Unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) + | ^^ Syntax Error: unary '+' is not allowed in a literal pattern on Python 3.14 (syntax was added in Python 3.15) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_index_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_index_py38.py.snap index 4dcf2f8ae09694..f474feeb47a5a4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_index_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_index_py38.py.snap @@ -64,4 +64,4 @@ Module( | 1 | # parse_options: {"target-version": "3.8"} 2 | lst[x:=1] - | ^^^^ Syntax Error: Cannot use unparenthesized assignment expression in a sequence index on Python 3.8 (syntax was added in Python 3.9) + | ^^^^ Syntax Error: cannot use unparenthesized assignment expression in a sequence index on Python 3.8 (syntax was added in Python 3.9) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_comp_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_comp_py38.py.snap index 050eb729b95435..c3e9fe4bd9ee1d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_comp_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_comp_py38.py.snap @@ -104,4 +104,4 @@ Module( | 1 | # parse_options: {"target-version": "3.8"} 2 | {last := x for x in range(3)} - | ^^^^^^^^^ Syntax Error: Cannot use unparenthesized assignment expression as an element in a set comprehension on Python 3.8 (syntax was added in Python 3.9) + | ^^^^^^^^^ Syntax Error: cannot use unparenthesized assignment expression as an element in a set comprehension on Python 3.8 (syntax was added in Python 3.9) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_literal_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_literal_py38.py.snap index b64439fa5aaceb..276420db990268 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_literal_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unparenthesized_named_expr_set_literal_py38.py.snap @@ -188,7 +188,7 @@ Module( | 1 | # parse_options: {"target-version": "3.8"} 2 | {x := 1, 2, 3} - | ^^^^^^ Syntax Error: Cannot use unparenthesized assignment expression as an element in a set literal on Python 3.8 (syntax was added in Python 3.9) + | ^^^^^^ Syntax Error: cannot use unparenthesized assignment expression as an element in a set literal on Python 3.8 (syntax was added in Python 3.9) 3 | {1, x := 2, 3} 4 | {1, 2, x := 3} | @@ -198,7 +198,7 @@ Module( 1 | # parse_options: {"target-version": "3.8"} 2 | {x := 1, 2, 3} 3 | {1, x := 2, 3} - | ^^^^^^ Syntax Error: Cannot use unparenthesized assignment expression as an element in a set literal on Python 3.8 (syntax was added in Python 3.9) + | ^^^^^^ Syntax Error: cannot use unparenthesized assignment expression as an element in a set literal on Python 3.8 (syntax was added in Python 3.9) 4 | {1, 2, x := 3} | @@ -207,4 +207,4 @@ Module( 2 | {x := 1, 2, 3} 3 | {1, x := 2, 3} 4 | {1, 2, x := 3} - | ^^^^^^ Syntax Error: Cannot use unparenthesized assignment expression as an element in a set literal on Python 3.8 (syntax was added in Python 3.9) + | ^^^^^^ Syntax Error: cannot use unparenthesized assignment expression as an element in a set literal on Python 3.8 (syntax was added in Python 3.9) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap index dded102f0065f8..f2e687b13c648a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap @@ -357,7 +357,7 @@ Module( | 1 | f"hello - | ^^^^^ Syntax Error: f-string: unterminated string + | ^^^^^ Syntax Error: unterminated f-string literal 2 | 1 + 1 3 | f"hello {x | @@ -365,7 +365,7 @@ Module( | 1 | f"hello - | ^ Syntax Error: Expected FStringEnd, found newline + | ^ Syntax Error: invalid syntax 2 | 1 + 1 3 | f"hello {x 4 | 2 + 2 @@ -376,7 +376,7 @@ Module( 1 | f"hello 2 | 1 + 1 3 | f"hello {x - | ^ Syntax Error: f-string: unterminated string + | ^ Syntax Error: unterminated f-string literal 4 | 2 + 2 5 | f"hello {x: | @@ -386,7 +386,7 @@ Module( 2 | 1 + 1 3 | f"hello {x 4 | 2 + 2 - | ^ Syntax Error: f-string: expecting `}` + | ^ Syntax Error: f-string: expecting '}' 5 | f"hello {x: 6 | 3 + 3 | @@ -396,7 +396,7 @@ Module( 1 | f"hello 2 | 1 + 1 3 | f"hello {x - | ^ Syntax Error: Expected FStringEnd, found newline + | ^ Syntax Error: invalid syntax 4 | 2 + 2 5 | f"hello {x: 6 | 3 + 3 @@ -417,6 +417,6 @@ Module( 5 | f"hello {x: 6 | 3 + 3 7 | f"hello {x} - | ^ Syntax Error: f-string: unterminated string + | ^ Syntax Error: unterminated f-string literal 8 | 4 + 4 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@walrus_py37.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@walrus_py37.py.snap index fe893f88a023b0..8f8536a85c5b8b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@walrus_py37.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@walrus_py37.py.snap @@ -49,4 +49,4 @@ Module( | 1 | # parse_options: { "target-version": "3.7" } 2 | (x := 1) - | ^^^^^^ Syntax Error: Cannot use named assignment expression (`:=`) on Python 3.7 (syntax was added in Python 3.8) + | ^^^^^^ Syntax Error: cannot use named assignment expression (`:=`) on Python 3.7 (syntax was added in Python 3.8) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap index 910fe8fa7b20df..2e72d5e1f59a83 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap @@ -193,7 +193,7 @@ Module( | 1 | while *x: ... - | ^^ Syntax Error: Starred expression cannot be used here + | ^^ Syntax Error: invalid syntax 2 | while yield x: ... 3 | while a, b: ... | @@ -202,7 +202,7 @@ Module( | 1 | while *x: ... 2 | while yield x: ... - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here 3 | while a, b: ... 4 | while a := 1, b: ... | @@ -212,7 +212,7 @@ Module( 1 | while *x: ... 2 | while yield x: ... 3 | while a, b: ... - | ^ Syntax Error: Expected `:`, found `,` + | ^ Syntax Error: invalid syntax 4 | while a := 1, b: ... | @@ -221,4 +221,4 @@ Module( 2 | while yield x: ... 3 | while a, b: ... 4 | while a := 1, b: ... - | ^ Syntax Error: Expected `:`, found `,` + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_colon.py.snap index 8b72ed23ee2b46..abe6c003fe23d8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_colon.py.snap @@ -67,6 +67,6 @@ Module( 1 | while ( 2 | a < 30 # comment 3 | ) - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 4 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_test.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_test.py.snap index 817161e3b1c743..8c0d73f1e90acc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_test.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_missing_test.py.snap @@ -97,7 +97,7 @@ Module( | 1 | while : ... - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 2 | while : 3 | a = 1 | @@ -106,6 +106,6 @@ Module( | 1 | while : ... 2 | while : - | ^ Syntax Error: Expected an expression + | ^ Syntax Error: invalid syntax 3 | a = 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_colon.py.snap index cf300bb6502b6e..2ace23eb61bcbf 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_colon.py.snap @@ -66,6 +66,6 @@ Module( | 1 | # `)` followed by a newline 2 | with (item1, item2) - | ^ Syntax Error: Expected `:`, found newline + | ^ Syntax Error: expected ':' 3 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap index 7510942975f0bd..77a1fc598a0bbd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap @@ -355,7 +355,7 @@ Module( | 1 | with (item1 item2): ... - | ^^^^^ Syntax Error: Expected `,`, found identifier + | ^^^^^ Syntax Error: invalid syntax 2 | with (item1 as f1 item2): ... 3 | with (item1, item2 item3, item4): ... | @@ -364,7 +364,7 @@ Module( | 1 | with (item1 item2): ... 2 | with (item1 as f1 item2): ... - | ^^^^^ Syntax Error: Expected `,`, found identifier + | ^^^^^ Syntax Error: invalid syntax 3 | with (item1, item2 item3, item4): ... 4 | with (item1, item2 as f1 item3, item4): ... | @@ -374,7 +374,7 @@ Module( 1 | with (item1 item2): ... 2 | with (item1 as f1 item2): ... 3 | with (item1, item2 item3, item4): ... - | ^^^^^ Syntax Error: Expected `,`, found identifier + | ^^^^^ Syntax Error: invalid syntax 4 | with (item1, item2 as f1 item3, item4): ... 5 | with (item1, item2: ... | @@ -384,7 +384,7 @@ Module( 2 | with (item1 as f1 item2): ... 3 | with (item1, item2 item3, item4): ... 4 | with (item1, item2 as f1 item3, item4): ... - | ^^^^^ Syntax Error: Expected `,`, found identifier + | ^^^^^ Syntax Error: invalid syntax 5 | with (item1, item2: ... | @@ -393,4 +393,4 @@ Module( 3 | with (item1, item2 item3, item4): ... 4 | with (item1, item2 as f1 item3, item4): ... 5 | with (item1, item2: ... - | ^ Syntax Error: Expected `)`, found `:` + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_after_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_after_comma.py.snap index e7db000f7fc0f2..b5b435bf40515c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_after_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@yield_after_comma.py.snap @@ -93,4 +93,4 @@ Module( | 1 | def f(): 1, yield 1 - | ^^^^^^^ Syntax Error: Yield expression cannot be used here + | ^^^^^^^ Syntax Error: yield expression cannot be used here From c66aaf408f868b9de162b06dad66442c57d121c6 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 4 Oct 2026 19:05:41 +0900 Subject: [PATCH 06/20] Report misplaced starred expressions at the `*` `InvalidStarredExpressionUsage` and `InvalidStarPatternUsage` errors now cover only the first character of the starred expression or star pattern, and a bytes literal with a non-ASCII character is reported over the whole literal instead of the offending character. Assisted-by: Claude Code:claude-opus-5-5 --- crates/ruff_python_parser/src/parser/mod.rs | 10 ++++++++- ...ng__tests__invalid_byte_literal_error.snap | 2 +- crates/ruff_python_parser/src/string.rs | 8 ++----- ...ann_assign_stmt_invalid_annotation.py.snap | 2 +- ...lid_syntax@assert_invalid_msg_expr.py.snap | 2 +- ...id_syntax@assert_invalid_test_expr.py.snap | 2 +- ...yntax@decorator_invalid_expression.py.snap | 6 ++--- ...tax@except_stmt_invalid_expression.py.snap | 2 +- ...essions__arguments__double_starred.py.snap | 4 ++-- ...uments__invalid_keyword_expression.py.snap | 4 ++-- ...ressions__arguments__invalid_order.py.snap | 2 +- ...syntax@expressions__await__recover.py.snap | 4 ++-- ...ssions__bin_op__starred_expression.py.snap | 4 ++-- ...sions__bool_op__starred_expression.py.snap | 4 ++-- ...sions__compare__starred_expression.py.snap | 4 ++-- ...x@expressions__dict__comprehension.py.snap | 4 ++-- ...s__dict__double_star_comprehension.py.snap | 2 +- ..._syntax@expressions__dict__recover.py.snap | 8 +++---- ...id_syntax@expressions__if__recover.py.snap | 4 ++-- ...x@expressions__list__comprehension.py.snap | 6 ++--- ...__list__star_expression_precedence.py.snap | 2 +- ...ions__parenthesized__parenthesized.py.snap | 2 +- ...ax@expressions__set__comprehension.py.snap | 4 ++-- ...s__set__star_expression_precedence.py.snap | 2 +- ...__subscript__invalid_slice_element.py.snap | 6 ++--- ...xpressions__yield__star_expression.py.snap | 2 +- ...ns__yield_from__starred_expression.py.snap | 4 ++-- ...x@function_def_invalid_return_expr.py.snap | 4 ++-- ...tax@if_stmt_invalid_elif_test_expr.py.snap | 2 +- ...d_syntax@if_stmt_invalid_test_expr.py.snap | 2 +- ...nvalid_syntax@invalid_byte_literal.py.snap | 6 ++--- ...ntax@lambda_body_with_starred_expr.py.snap | 8 +++---- ..._classify_as_keyword_or_identifier.py.snap | 2 +- ...ntax@match_stmt_invalid_guard_expr.py.snap | 4 ++-- ...ax@match_stmt_invalid_subject_expr.py.snap | 2 +- ...@match_stmt_single_starred_subject.py.snap | 2 +- ...ntax@param_with_invalid_annotation.py.snap | 2 +- ..._syntax@param_with_invalid_default.py.snap | 4 ++-- ...param_with_invalid_star_annotation.py.snap | 2 +- ...ict_unpacking_comprehensions_py315.py.snap | 8 +++---- ...id_syntax@raise_stmt_invalid_cause.py.snap | 2 +- ...alid_syntax@raise_stmt_invalid_exc.py.snap | 2 +- .../invalid_syntax@star_slices.py.snap | 4 ++-- ..._syntax@starred_starred_expression.py.snap | 4 ++-- ...ts__match__invalid_mapping_pattern.py.snap | 8 +++---- ...tements__match__star_pattern_usage.py.snap | 22 +++++++++---------- ...s__with__ambiguous_lpar_with_items.py.snap | 10 ++++----- ...__with__unparenthesized_with_items.py.snap | 8 +++---- ...ntax@type_alias_invalid_value_expr.py.snap | 2 +- ...ntax@type_param_invalid_bound_expr.py.snap | 2 +- ...am_param_spec_invalid_default_expr.py.snap | 4 ++-- ...aram_type_var_invalid_default_expr.py.snap | 4 ++-- ...yntax@while_stmt_invalid_test_expr.py.snap | 2 +- 53 files changed, 116 insertions(+), 112 deletions(-) diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index 817ecda7c97a92..c436ed5572cffd 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -674,7 +674,15 @@ impl<'src> Parser<'src> { } } - inner(&mut self.errors, error, ranged.range()); + let mut range = ranged.range(); + // A misplaced starred expression or star pattern is reported at its `*`. + if matches!( + error, + ParseErrorType::InvalidStarredExpressionUsage | ParseErrorType::InvalidStarPatternUsage + ) { + range = TextRange::at(range.start(), TextSize::new(1)); + } + inner(&mut self.errors, error, range); } /// Add an [`UnsupportedSyntaxError`] with the given [`UnsupportedSyntaxErrorKind`] and diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_byte_literal_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_byte_literal_error.snap index cfd2346294c99a..5cac49de923d82 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_byte_literal_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_byte_literal_error.snap @@ -6,5 +6,5 @@ ParseError { error: Lexical( InvalidByteLiteral, ), - location: 6..10, + location: 0..12, } diff --git a/crates/ruff_python_parser/src/string.rs b/crates/ruff_python_parser/src/string.rs index bd7e9961abbf90..e97475d0e1f304 100644 --- a/crates/ruff_python_parser/src/string.rs +++ b/crates/ruff_python_parser/src/string.rs @@ -374,14 +374,10 @@ impl<'src> StringParser<'src> { } fn parse_bytes(mut self) -> Result { - if let Some(index) = self.source.as_bytes().find_non_ascii_byte() { - let ch = self.source.chars().nth(index).unwrap(); + if self.source.as_bytes().find_non_ascii_byte().is_some() { return Err(LexicalError::new( LexicalErrorType::InvalidByteLiteral, - TextRange::at( - self.compute_position(index), - TextSize::try_from(ch.len_utf8()).unwrap(), - ), + self.range, )); } diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap index 6911290ff0bbfd..cdce818301dcf4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_annotation.py.snap @@ -198,7 +198,7 @@ Module( | 1 | x: *int = 1 - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | x: yield a = 1 3 | x: yield from b = 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap index cd189ef161a5c6..5d1a26299d08a9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_msg_expr.py.snap @@ -147,7 +147,7 @@ Module( | 1 | assert False, *x - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | assert False, assert x 3 | assert False, yield x | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap index da455d6a67f409..eac8e83a2f87f5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assert_invalid_test_expr.py.snap @@ -123,7 +123,7 @@ Module( | 1 | assert *x - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | assert assert x 3 | assert yield x | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap index bcafc4596c3bec..404c8bc00b692c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap @@ -158,7 +158,7 @@ Module( | 1 | @*x - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | @(*x) 3 | @((*x)) | @@ -167,7 +167,7 @@ Module( | 1 | @*x 2 | @(*x) - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | @((*x)) 4 | @yield x | @@ -177,7 +177,7 @@ Module( 1 | @*x 2 | @(*x) 3 | @((*x)) - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 4 | @yield x 5 | @yield from x | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap index fb9829ff918766..6efa041a7acd1b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_expression.py.snap @@ -144,6 +144,6 @@ Module( 5 | try: 6 | pass 7 | except* *x: - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 8 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap index c94716bb7bb19d..32313905023003 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap @@ -228,7 +228,7 @@ Module( | 1 | call(**yield x) 2 | call(** *x) - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | call(***x) | @@ -237,7 +237,7 @@ Module( 1 | call(**yield x) 2 | call(** *x) 3 | call(***x) - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 4 | 5 | call(**x := 1) | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap index 04b42f4517d8fc..796dc13c4b6a00 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap @@ -258,7 +258,7 @@ Module( 1 | call(x = yield y) 2 | call(x = yield from y) 3 | call(x = *y) - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 4 | call(x = (*y)) | @@ -267,4 +267,4 @@ Module( 2 | call(x = yield from y) 3 | call(x = *y) 4 | call(x = (*y)) - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap index e7b3dbec5f794a..b555c7b7aa882c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap @@ -353,4 +353,4 @@ Module( 3 | call(x=1, **kwargs, y) 4 | call(**kwargs, *args) 5 | call(**kwargs, (*args)) - | ^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap index 2e64245210720f..cbc87bb567e168 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap @@ -301,7 +301,7 @@ Module( | 7 | # Starred expressions 8 | await *x - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 9 | await (*x) | @@ -310,7 +310,7 @@ Module( 7 | # Starred expressions 8 | await *x 9 | await (*x) - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 10 | 11 | # Invalid expression as per precedence | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap index b9cb398c61c83b..07e5349354b029 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__starred_expression.py.snap @@ -91,7 +91,7 @@ Module( | 1 | x + *y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | x ** *y | @@ -99,4 +99,4 @@ Module( | 1 | x + *y 2 | x ** *y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap index 0d8597d695f99f..8569a576b87a34 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__starred_expression.py.snap @@ -97,7 +97,7 @@ Module( | 1 | x and *y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | x or *y | @@ -105,4 +105,4 @@ Module( | 1 | x and *y 2 | x or *y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap index 3f820762c30a07..0e58920499204d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__starred_expression.py.snap @@ -183,7 +183,7 @@ Module( | 1 | x >= *y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | x not in *y | @@ -191,7 +191,7 @@ Module( | 1 | x >= *y 2 | x not in *y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | 4 | *x < y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap index 7b784d6d669f20..b7404c9d4d25f5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap @@ -925,7 +925,7 @@ Module( | 7 | # Invalid iter 8 | {x: y for x in *y} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 9 | {x: y for x in yield y} 10 | {x: y for x in yield from y} | @@ -963,7 +963,7 @@ Module( | 13 | # Invalid if 14 | {x: y for x in data if *y} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 15 | {x: y for x in data if yield y} 16 | {x: y for x in data if yield from y} | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap index 8b78c5d41828ab..f97bc98dee2414 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star_comprehension.py.snap @@ -96,7 +96,7 @@ Module( 2 | # it's actually a comprehension. 3 | 4 | {**x: y for x, y in data} - | ^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 5 | 6 | # TODO(dhruvmanila): This test case fails because there's no way to represent `**y` | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap index 7fce88bdb76a59..e48cabd9ff4a63 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap @@ -550,7 +550,7 @@ Module( | 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 24 | {x: *y, z: *a} | @@ -558,7 +558,7 @@ Module( | 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 24 | {x: *y, z: *a} | @@ -567,11 +567,11 @@ Module( 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} 24 | {x: *y, z: *a} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax | 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} 24 | {x: *y, z: *a} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap index ed79e9aee5d3c6..3e919888a8bb13 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap @@ -350,7 +350,7 @@ Module( | 1 | # Invalid test expression 2 | x if *expr else y - | ^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | x if lambda x: x else y 4 | x if yield x else y | @@ -388,7 +388,7 @@ Module( | 7 | # Invalid orelse expression 8 | x if expr else *orelse - | ^^^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 9 | x if expr else yield y 10 | x if expr else yield from y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap index 4bcc73eb1d390e..12796c3cb35012 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap @@ -1184,7 +1184,7 @@ Module( | 7 | # Invalid iter 8 | [x for x in *y] - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 9 | [x for x in yield y] 10 | [x for x in yield from y] | @@ -1293,7 +1293,7 @@ Module( | 16 | # Invalid if 17 | [x for x in data if *y] - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 18 | [x for x in data if yield y] 19 | [x for x in data if yield from y] | @@ -1342,7 +1342,7 @@ Module( 20 | [x for x in data if lambda y: y] 21 | [*x if x else y for x in z] 22 | [x if x else *y for x in z] - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax ## Unsupported Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap index 265a08bbae5130..26ead6f1e7db38 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap @@ -468,7 +468,7 @@ Module( 1 | # For list expression, the minimum binding power of star expression is bitwise or. 2 | 3 | [(*x), y] - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 4 | [*x in y, z] 5 | [*not x, z] | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap index a6b3e86363206f..ff04483ea7702a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap @@ -70,7 +70,7 @@ Module( | 1 | # Starred expression isn't allowed in a parenthesized expression. 2 | (*x) - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | 4 | # Unparenthesized named expression is allowed. | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap index 97fab935909093..fd5274b8087900 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap @@ -805,7 +805,7 @@ Module( | 7 | # Invalid iter 8 | {x for x in *y} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 9 | {x for x in yield y} 10 | {x for x in yield from y} | @@ -843,7 +843,7 @@ Module( | 13 | # Invalid if 14 | {x for x in data if *y} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 15 | {x for x in data if yield y} 16 | {x for x in data if yield from y} | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap index 1e2ac72cd5ca62..b1e5aa0a9ddf9e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap @@ -460,7 +460,7 @@ Module( 1 | # For set expression, the minimum binding power of star expression is bitwise or. 2 | 3 | {(*x), y} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 4 | {*x in y, z} 5 | {*not x, z} | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap index 1dd645cd78e943..0c7a4a965bf53f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap @@ -300,7 +300,7 @@ Module( | 3 | # Starred expression 4 | x[*x:] - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 5 | x[:*x] 6 | x[::*x] | @@ -310,7 +310,7 @@ Module( 3 | # Starred expression 4 | x[*x:] 5 | x[:*x] - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 6 | x[::*x] | @@ -319,7 +319,7 @@ Module( 4 | x[*x:] 5 | x[:*x] 6 | x[::*x] - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 7 | 8 | # Empty slice | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap index bb4871b6ba6483..41d6dad95ccc06 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap @@ -115,7 +115,7 @@ Module( | 1 | # Cannot use starred expression here 2 | yield (*x) - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | 4 | yield *x and y, z | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap index a799c917cab3b9..051d418cae5491 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield_from__starred_expression.py.snap @@ -94,7 +94,7 @@ Module( 1 | # Yield from doesn't allow top-level starred expression unlike yield 2 | 3 | yield from *x - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 4 | yield from *x, y | @@ -102,4 +102,4 @@ Module( | 3 | yield from *x 4 | yield from *x, y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap index df2fe3d7b11996..44155c830fefd5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap @@ -197,7 +197,7 @@ Module( | 1 | def foo() -> *int: ... - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | def foo() -> (*int): ... 3 | def foo() -> yield x: ... | @@ -206,7 +206,7 @@ Module( | 1 | def foo() -> *int: ... 2 | def foo() -> (*int): ... - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | def foo() -> yield x: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap index d49261a9f69dfd..8b65d7eb2d13d4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_elif_test_expr.py.snap @@ -109,7 +109,7 @@ Module( 1 | if x: 2 | pass 3 | elif *x: - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 4 | pass 5 | elif yield x: | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap index b071542bb91859..dda59bc3c3a866 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_invalid_test_expr.py.snap @@ -130,7 +130,7 @@ Module( | 1 | if *x: ... - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | if yield x: ... 3 | if yield from x: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_byte_literal.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_byte_literal.py.snap index e070f35d212154..52685a23a0bb72 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_byte_literal.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_byte_literal.py.snap @@ -102,7 +102,7 @@ Module( | 1 | b'123a𝐁c' - | ^ Syntax Error: bytes can only contain ASCII literal characters + | ^^^^^^^^^ Syntax Error: bytes can only contain ASCII literal characters 2 | rb"a𝐁c123" 3 | b"""123a𝐁c""" | @@ -111,7 +111,7 @@ Module( | 1 | b'123a𝐁c' 2 | rb"a𝐁c123" - | ^ Syntax Error: bytes can only contain ASCII literal characters + | ^^^^^^^^^^ Syntax Error: bytes can only contain ASCII literal characters 3 | b"""123a𝐁c""" | @@ -120,4 +120,4 @@ Module( 1 | b'123a𝐁c' 2 | rb"a𝐁c123" 3 | b"""123a𝐁c""" - | ^ Syntax Error: bytes can only contain ASCII literal characters + | ^^^^^^^^^^^^^ Syntax Error: bytes can only contain ASCII literal characters diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap index fcdfca36d60b08..73c87a6ad594f4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_body_with_starred_expr.py.snap @@ -295,7 +295,7 @@ Module( | 1 | lambda x: *y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | lambda x: *y, 3 | lambda x: *y, z | @@ -304,7 +304,7 @@ Module( | 1 | lambda x: *y 2 | lambda x: *y, - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | lambda x: *y, z 4 | lambda x: *y and z | @@ -314,7 +314,7 @@ Module( 1 | lambda x: *y 2 | lambda x: *y, 3 | lambda x: *y, z - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 4 | lambda x: *y and z | @@ -323,4 +323,4 @@ Module( 2 | lambda x: *y, 3 | lambda x: *y, z 4 | lambda x: *y and z - | ^^^^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap index 53cf09d4ca7e7c..0e6f018693aeb9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_classify_as_keyword_or_identifier.py.snap @@ -70,6 +70,6 @@ Module( | 1 | match *foo: # Keyword - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | case _: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap index 0f2c38a45efe19..d3933468e58806 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap @@ -219,7 +219,7 @@ Module( | 1 | match x: 2 | case y if *a: ... - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | match x: 4 | case y if (*a): ... | @@ -229,7 +229,7 @@ Module( 2 | case y if *a: ... 3 | match x: 4 | case y if (*a): ... - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 5 | match x: 6 | case y if yield x: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap index 9714589315d3b3..28a6a77837f6cd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap @@ -210,7 +210,7 @@ Module( | 1 | match (*x): - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | case _: ... 3 | # Starred expression precedence test | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap index f7713f4bded99c..25da98b1d82b20 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_single_starred_subject.py.snap @@ -70,6 +70,6 @@ Module( | 1 | match *foo: - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | case _: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap index 3d20ac065f164d..5d2ca911394d8d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_annotation.py.snap @@ -261,7 +261,7 @@ Module( | 1 | def foo(arg: *int): ... - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | def foo(arg: yield int): ... 3 | def foo(arg: x := int): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap index 48c82f18ecc37b..7ede5849703ba5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap @@ -251,7 +251,7 @@ Module( | 1 | def foo(x=*int): ... - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | def foo(x=(*int)): ... 3 | def foo(x=yield y): ... | @@ -260,7 +260,7 @@ Module( | 1 | def foo(x=*int): ... 2 | def foo(x=(*int)): ... - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | def foo(x=yield y): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap index b4766118cb5456..681dfc4e4a26c7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap @@ -357,7 +357,7 @@ Module( | 1 | def foo(*args: *): ... 2 | def foo(*args: (*tuple[int])): ... - | ^^^^^^^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | def foo(*args: *int or str): ... 4 | def foo(*args: *yield x): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap index cc6d0a2c720037..7532827636dfdd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap @@ -334,7 +334,7 @@ Module( | 1 | # parse_options: {"target-version": "3.15"} 2 | {*k: v for k, v in items} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | {k: *v for k, v in items} 4 | {**k: v for k, v in items} | @@ -344,7 +344,7 @@ Module( 1 | # parse_options: {"target-version": "3.15"} 2 | {*k: v for k, v in items} 3 | {k: *v for k, v in items} - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 4 | {**k: v for k, v in items} 5 | {k: **v for k, v in items} | @@ -354,7 +354,7 @@ Module( 2 | {*k: v for k, v in items} 3 | {k: *v for k, v in items} 4 | {**k: v for k, v in items} - | ^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 5 | {k: **v for k, v in items} | @@ -363,4 +363,4 @@ Module( 3 | {k: *v for k, v in items} 4 | {**k: v for k, v in items} 5 | {k: **v for k, v in items} - | ^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap index 475308da0cb8be..b896c5b2d0f69c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_cause.py.snap @@ -127,7 +127,7 @@ Module( | 1 | raise x from *y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | raise x from yield y 3 | raise x from y := 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap index e39bed4c4196fe..227967f91334f2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@raise_stmt_invalid_exc.py.snap @@ -100,7 +100,7 @@ Module( | 1 | raise *x - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | raise yield x 3 | raise x := 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap index 395a1d065e726c..ce9cb1e48f66c4 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap @@ -81,9 +81,9 @@ Module( | 1 | array[*start:*end] - | ^^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax | 1 | array[*start:*end] - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap index 78aa115c891c97..e499920e77e1a1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap @@ -124,7 +124,7 @@ Module( | 1 | print(* 2 | *[]) - | ^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 3 | print(* *[]) | @@ -133,4 +133,4 @@ Module( 1 | print(* 2 | *[]) 3 | print(* *[]) - | ^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap index a91072687799be..16d6cf482be8c8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_mapping_pattern.py.snap @@ -557,7 +557,7 @@ Module( 1 | # Starred expression is not allowed as a mapping pattern key 2 | match subject: 3 | case {*key}: - | ^^^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 4 | pass 5 | case {*key: 1}: | @@ -577,7 +577,7 @@ Module( 3 | case {*key}: 4 | pass 5 | case {*key: 1}: - | ^^^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 6 | pass 7 | case {*key 1}: | @@ -587,7 +587,7 @@ Module( 5 | case {*key: 1}: 6 | pass 7 | case {*key 1}: - | ^^^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 8 | pass 9 | case {*key, None: 1}: | @@ -607,7 +607,7 @@ Module( 7 | case {*key 1}: 8 | pass 9 | case {*key, None: 1}: - | ^^^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 10 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap index ef901f062ad453..8cecfcc67cbc1d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__star_pattern_usage.py.snap @@ -605,7 +605,7 @@ Module( 1 | # Star pattern is only allowed inside a sequence pattern 2 | match subject: 3 | case *_: - | ^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 4 | pass 5 | case *_ as x: | @@ -615,7 +615,7 @@ Module( 3 | case *_: 4 | pass 5 | case *_ as x: - | ^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 6 | pass 7 | case *foo: | @@ -625,7 +625,7 @@ Module( 5 | case *_ as x: 6 | pass 7 | case *foo: - | ^^^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 8 | pass 9 | case *foo | 1: | @@ -635,7 +635,7 @@ Module( 7 | case *foo: 8 | pass 9 | case *foo | 1: - | ^^^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 10 | pass 11 | case 1 | *foo: | @@ -645,7 +645,7 @@ Module( 9 | case *foo | 1: 10 | pass 11 | case 1 | *foo: - | ^^^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 12 | pass 13 | case Foo(*_): | @@ -655,7 +655,7 @@ Module( 11 | case 1 | *foo: 12 | pass 13 | case Foo(*_): - | ^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 14 | pass 15 | case Foo(x=*_): | @@ -665,7 +665,7 @@ Module( 13 | case Foo(*_): 14 | pass 15 | case Foo(x=*_): - | ^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 16 | pass 17 | case {*_}: | @@ -675,7 +675,7 @@ Module( 15 | case Foo(x=*_): 16 | pass 17 | case {*_}: - | ^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 18 | pass 19 | case {*_: 1}: | @@ -695,7 +695,7 @@ Module( 17 | case {*_}: 18 | pass 19 | case {*_: 1}: - | ^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 20 | pass 21 | case {None: *_}: | @@ -705,7 +705,7 @@ Module( 19 | case {*_: 1}: 20 | pass 21 | case {None: *_}: - | ^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 22 | pass 23 | case 1 + *_: | @@ -715,7 +715,7 @@ Module( 21 | case {None: *_}: 22 | pass 23 | case 1 + *_: - | ^^ Syntax Error: cannot use starred expression here + | ^ Syntax Error: cannot use starred expression here 24 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap index 9d6fb221fb52f9..61e83db69ffa29 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap @@ -1701,7 +1701,7 @@ Module( 5 | with (item1, item2), as f: ... 6 | with (item1, item2), item3,: ... 7 | with (*item): ... - | ^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 8 | with (*item) as f: ... 9 | with (item := 10 as f): ... | @@ -1711,7 +1711,7 @@ Module( 6 | with (item1, item2), item3,: ... 7 | with (*item): ... 8 | with (*item) as f: ... - | ^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 9 | with (item := 10 as f): ... 10 | with (item1, item2 := 10 as f): ... | @@ -1788,7 +1788,7 @@ Module( | 14 | # Make sure the parser doesn't report the same error twice 15 | with ((*item)): ... - | ^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 16 | 17 | with (*x for x in iter, item): ... | @@ -1845,7 +1845,7 @@ Module( 17 | with (*x for x in iter, item): ... 18 | with (item1, *x for x in iter, item2): ... 19 | with (x as f, *y): ... - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 20 | with (*x, y as f): ... 21 | with (x, yield y): ... | @@ -1855,7 +1855,7 @@ Module( 18 | with (item1, *x for x in iter, item2): ... 19 | with (x as f, *y): ... 20 | with (*x, y as f): ... - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 21 | with (x, yield y): ... 22 | with (x, yield y, z): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap index 3edbdea2bf05d2..d4e2af063e1359 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unparenthesized_with_items.py.snap @@ -384,7 +384,7 @@ Module( 3 | with item,: pass 4 | with item as x,: pass 5 | with *item: pass - | ^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 6 | with *item as x: pass 7 | with *item1, item2 as f: pass | @@ -394,7 +394,7 @@ Module( 4 | with item as x,: pass 5 | with *item: pass 6 | with *item as x: pass - | ^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 7 | with *item1, item2 as f: pass 8 | with item1 as f, *item2: pass | @@ -404,7 +404,7 @@ Module( 5 | with *item: pass 6 | with *item as x: pass 7 | with *item1, item2 as f: pass - | ^^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 8 | with item1 as f, *item2: pass 9 | with item := 0 as f: pass | @@ -414,7 +414,7 @@ Module( 6 | with *item as x: pass 7 | with *item1, item2 as f: pass 8 | with item1 as f, *item2: pass - | ^^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 9 | with item := 0 as f: pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap index 2b09be956bcd8f..5c5080f3ca944b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_alias_invalid_value_expr.py.snap @@ -147,7 +147,7 @@ Module( | 1 | type x = *y - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | type x = yield y 3 | type x = yield from y | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap index 3a73f9342946ff..9a2479b7a1b98b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_invalid_bound_expr.py.snap @@ -265,7 +265,7 @@ Module( | 1 | type X[T: *int] = int - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | type X[T: yield x] = int 3 | type X[T: yield from x] = int | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap index 65da3fc9ffae79..7f2c7712770822 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_invalid_default_expr.py.snap @@ -320,7 +320,7 @@ Module( | 1 | type X[**P = *int] = int - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | type X[**P = yield x] = int 3 | type X[**P = yield from x] = int | @@ -358,7 +358,7 @@ Module( 3 | type X[**P = yield from x] = int 4 | type X[**P = x := int] = int 5 | type X[**P = *int] = int - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap index 7ac76453f879d3..def565d5727c63 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_invalid_default_expr.py.snap @@ -395,7 +395,7 @@ Module( | 1 | type X[T = *int] = int - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | type X[T = yield x] = int 3 | type X[T = (yield x)] = int | @@ -433,7 +433,7 @@ Module( 4 | type X[T = yield from x] = int 5 | type X[T = x := int] = int 6 | type X[T: int = *int] = int - | ^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap index 2e72d5e1f59a83..70e3a0bdf9b428 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@while_stmt_invalid_test_expr.py.snap @@ -193,7 +193,7 @@ Module( | 1 | while *x: ... - | ^^ Syntax Error: invalid syntax + | ^ Syntax Error: invalid syntax 2 | while yield x: ... 3 | while a, b: ... | From 9be8d5dab63778bed35a0f8e5ce5847132987f56 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 4 Oct 2026 23:03:03 +0900 Subject: [PATCH 07/20] Report indentation errors as separate lexer error kinds Indentation compares columns with a tab size of 8 and checks the character count only for consistency, so tabs and spaces that agree at tab size 8 are accepted. Inconsistent mixing is reported as `LexicalErrorType::TabError`, and nesting past 99 levels as `LexicalErrorType::TooDeepIndentation`; both are reported at the start of the line. An unmatched dedent is reported at the end of the line, an unexpected indent at the last character of the indentation, and a line continuation error after the backslash. The parser no longer adds an error while the current token is the `Unknown` token of a lexer error. `ParseErrorType::UnexpectedIndentation` now displays as "unexpected indent". `nested_def_blocks_grow_stack` expects the depth error. Assisted-by: Claude Code:claude-opus-5-5 --- crates/ruff_python_parser/src/error.rs | 10 ++- crates/ruff_python_parser/src/lexer.rs | 61 +++++++++------ .../src/lexer/indentation.rs | 77 +++++++++++++++---- crates/ruff_python_parser/src/parser/mod.rs | 30 +++++--- ..._inner_line_continuation_and_t_string.snap | 2 +- crates/ruff_python_parser/src/parser/tests.rs | 11 ++- ...ash_continuation_mismatch_indentation.snap | 2 +- ...ser__lexer__tests__tet_too_low_dedent.snap | 2 +- ...ash_continuation_indentation_error.py.snap | 9 +-- ...nparenthesized_tuple_as_incomplete.py.snap | 2 +- ...lid_syntax@if_stmt_misspelled_elif.py.snap | 4 +- ...x@re_lexing__fstring_format_spec_1.py.snap | 2 +- ...tax@re_lexing__line_continuation_1.py.snap | 4 +- ...ents__if_extra_closing_parentheses.py.snap | 2 +- ...syntax@statements__if_extra_indent.py.snap | 16 ++-- ...ax@statements__match__as_pattern_3.py.snap | 2 +- ...alid_syntax@try_stmt_invalid_order.py.snap | 2 +- ..._syntax@try_stmt_misspelled_except.py.snap | 6 +- 18 files changed, 162 insertions(+), 82 deletions(-) diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index 3fcc9ae5fbb642..db9f1faca7e1ea 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -321,7 +321,7 @@ impl std::fmt::Display for ParseErrorType { f.write_str("expected an imaginary number in complex literal pattern") } ParseErrorType::ExpectedExpression => f.write_str("invalid syntax"), - ParseErrorType::UnexpectedIndentation => f.write_str("unexpected indentation"), + ParseErrorType::UnexpectedIndentation => f.write_str("unexpected indent"), ParseErrorType::InvalidAssignmentTarget => f.write_str("invalid assignment target"), ParseErrorType::InvalidAnnotatedAssignmentTarget => { f.write_str("illegal target for annotation") @@ -419,8 +419,12 @@ pub enum LexicalErrorType { MissingUnicodeLbrace, /// Missing the `}` for unicode escape sequence. MissingUnicodeRbrace, - /// The indentation is not consistent. + /// A dedent does not match any outer indentation level. IndentationError, + /// Tabs and spaces are mixed in a way that makes the indentation depend on the tab size. + TabError, + /// The indentation is nested too deeply. + TooDeepIndentation, /// An unrecognized token was encountered. UnrecognizedToken { tok: char }, /// An f-string error containing the [`InterpolatedStringErrorType`]. @@ -468,6 +472,8 @@ impl std::fmt::Display for LexicalErrorType { Self::IndentationError => { write!(f, "unindent does not match any outer indentation level") } + Self::TabError => write!(f, "inconsistent use of tabs and spaces in indentation"), + Self::TooDeepIndentation => write!(f, "too many levels of indentation"), Self::UnrecognizedToken { .. } => f.write_str("invalid syntax"), Self::LineContinuationError => { write!(f, "unexpected character after line continuation character") diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 7aedc4722ba586..ec8863605bff3a 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -19,7 +19,9 @@ use ruff_text_size::{TextLen, TextRange, TextSize}; use crate::Mode; use crate::error::{InterpolatedStringErrorType, LexicalError, LexicalErrorType}; use crate::lexer::cursor::{Cursor, EOF_CHAR}; -use crate::lexer::indentation::{Indentation, Indentations, IndentationsCheckpoint}; +use crate::lexer::indentation::{ + Indentation, IndentationError, Indentations, IndentationsCheckpoint, +}; use crate::lexer::interpolated_string::{ InterpolatedStringContext, InterpolatedStrings, InterpolatedStringsCheckpoint, }; @@ -138,6 +140,29 @@ impl<'src> Lexer<'src> { TokenKind::Unknown } + /// Pushes an indentation error for the current line. + /// + /// An unmatched dedent is reported at the end of the line, tab and depth errors at its start. + fn push_indentation_error(&mut self, error: IndentationError) -> TokenKind { + let offset = self.offset().to_usize(); + let line_start = self.source[..offset] + .rfind(['\n', '\r']) + .map_or(0, |index| index + 1); + let line_end = self.source[offset..] + .find(['\n', '\r']) + .map_or(self.source.len(), |index| offset + index); + let (error, position) = match error { + IndentationError::UnmatchedDedent => (LexicalErrorType::IndentationError, line_end), + IndentationError::InconsistentTabs => (LexicalErrorType::TabError, line_start), + IndentationError::TooDeep => (LexicalErrorType::TooDeepIndentation, line_start), + }; + let range = TextRange::empty(TextSize::try_from(position).unwrap()); + self.push_error(LexicalError::new(error, range)); + // The token keeps covering the indentation. + self.current_range = self.token_range(); + TokenKind::Unknown + } + /// Lex the next token. pub fn next_token(&mut self) -> TokenKind { // `lex_token` marks the start on the path that lexes each token. @@ -171,21 +196,13 @@ impl<'src> Lexer<'src> { match self.indentations.current().try_compare(indentation) { Ok(Ordering::Greater) => { self.pending_indentation = Some(indentation); - if self.indentations.dedent_one(indentation).is_err() { - return self.push_error(LexicalError::new( - LexicalErrorType::IndentationError, - self.token_range(), - )); + if let Err(error) = self.indentations.dedent_one(indentation) { + return self.push_indentation_error(error); } return TokenKind::Dedent; } Ok(_) => {} - Err(_) => { - return self.push_error(LexicalError::new( - LexicalErrorType::IndentationError, - self.token_range(), - )); - } + Err(error) => return self.push_indentation_error(error), } } @@ -245,7 +262,7 @@ impl<'src> Lexer<'src> { } else if !self.cursor.eat_char('\n') { return Some(self.push_error(LexicalError::new( LexicalErrorType::LineContinuationError, - TextRange::at(self.offset() - '\\'.text_len(), '\\'.text_len()), + TextRange::empty(self.offset()), ))); } if self.cursor.is_eof() { @@ -310,11 +327,8 @@ impl<'src> Lexer<'src> { Ok(Ordering::Greater) => { self.pending_indentation = Some(indentation); - if self.indentations.dedent_one(indentation).is_err() { - return Some(self.push_error(LexicalError::new( - LexicalErrorType::IndentationError, - self.token_range(), - ))); + if let Err(error) = self.indentations.dedent_one(indentation) { + return Some(self.push_indentation_error(error)); } // The lexer might've eaten some whitespaces to calculate the `indentation`. For @@ -339,13 +353,12 @@ impl<'src> Lexer<'src> { // Indent Ok(Ordering::Less) => { - self.indentations.indent(indentation); + if let Err(error) = self.indentations.indent(indentation) { + return Some(self.push_indentation_error(error)); + } Some(TokenKind::Indent) } - Err(_) => Some(self.push_error(LexicalError::new( - LexicalErrorType::IndentationError, - self.token_range(), - ))), + Err(error) => Some(self.push_indentation_error(error)), } } @@ -371,7 +384,7 @@ impl<'src> Lexer<'src> { } else if !self.cursor.eat_char('\n') { return Err(LexicalError::new( LexicalErrorType::LineContinuationError, - TextRange::at(self.offset() - '\\'.text_len(), '\\'.text_len()), + TextRange::empty(self.offset()), )); } if self.cursor.is_eof() { diff --git a/crates/ruff_python_parser/src/lexer/indentation.rs b/crates/ruff_python_parser/src/lexer/indentation.rs index acdf53a2fb6445..89071578e59dc4 100644 --- a/crates/ruff_python_parser/src/lexer/indentation.rs +++ b/crates/ruff_python_parser/src/lexer/indentation.rs @@ -6,8 +6,7 @@ use ruff_python_trivia::tab_offset_u32; /// The column index of an indentation. /// -/// A space increments the column by one. A tab adds up to 2 (if tab size is 2) indices, but just one -/// if the column isn't even. +/// A space increments the column by one. A tab advances the column to the next multiple of 8. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Default)] pub(super) struct Column(u32); @@ -35,7 +34,7 @@ pub(super) struct Indentation { } impl Indentation { - const TAB_SIZE: u32 = 2; + const TAB_SIZE: u32 = 8; pub(super) const fn root() -> Self { Self { @@ -69,20 +68,37 @@ impl Indentation { } } - pub(super) fn try_compare(self, other: Indentation) -> Result { - let column_ordering = self.column.cmp(&other.column); - let character_ordering = self.character.cmp(&other.character); - - if column_ordering == character_ordering { - Ok(column_ordering) + /// Compares the current indentation `self` with the indentation `other` of a new line by + /// column. + /// + /// A deeper line must also have more characters, and a line at the same column the same + /// number of characters; otherwise tabs and spaces are mixed inconsistently. A shallower line + /// is checked against the level it dedents to, in [`Indentations::dedent_one`]. + pub(super) fn try_compare(self, other: Indentation) -> Result { + let ordering = self.column.cmp(&other.column); + let consistent = match ordering { + Ordering::Less => self.character < other.character, + Ordering::Equal => self.character == other.character, + Ordering::Greater => true, + }; + + if consistent { + Ok(ordering) } else { - Err(UnexpectedIndentation) + Err(IndentationError::InconsistentTabs) } } } #[derive(Debug, Copy, Clone, PartialEq)] -pub(super) struct UnexpectedIndentation; +pub(super) enum IndentationError { + /// Tabs and spaces are mixed in a way that makes the indentation depend on the tab size. + InconsistentTabs, + /// A dedent does not match any outer indentation level. + UnmatchedDedent, + /// Indenting would exceed [`Indentations::MAX_DEPTH`]. + TooDeep, +} /// The indentations stack is used to keep track of the current indentation level /// [See Indentation](docs.python.org/3/reference/lexical_analysis.html#indentation). @@ -92,10 +108,17 @@ pub(super) struct Indentations { } impl Indentations { - pub(super) fn indent(&mut self, indent: Indentation) { + /// The maximum number of nested indentation levels. + const MAX_DEPTH: usize = 99; + + pub(super) fn indent(&mut self, indent: Indentation) -> Result<(), IndentationError> { debug_assert_eq!(self.current().try_compare(indent), Ok(Ordering::Less)); + if self.stack.len() >= Self::MAX_DEPTH { + return Err(IndentationError::TooDeep); + } self.stack.push(indent); + Ok(()) } /// Dedent one level to eventually reach `new_indentation`. @@ -104,17 +127,20 @@ impl Indentations { pub(super) fn dedent_one( &mut self, new_indentation: Indentation, - ) -> Result, UnexpectedIndentation> { + ) -> Result, IndentationError> { let previous = self.dedent(); + let current = *self.current(); - match new_indentation.try_compare(*self.current())? { - Ordering::Less | Ordering::Equal => Ok(previous), + match new_indentation.column.cmp(¤t.column) { + Ordering::Less => Ok(previous), + Ordering::Equal if new_indentation.character == current.character => Ok(previous), + Ordering::Equal => Err(IndentationError::InconsistentTabs), // ```python // if True: // pass // pass <- The indentation is greater than the expected indent of 0. // ``` - Ordering::Greater => Err(UnexpectedIndentation), + Ordering::Greater => Err(IndentationError::UnmatchedDedent), } } @@ -143,7 +169,7 @@ assert_eq_size!(Indentation, u64); #[cfg(test)] mod tests { - use super::{Character, Column, Indentation}; + use super::{Character, Column, Indentation, IndentationError}; use std::cmp::Ordering; #[test] @@ -156,4 +182,21 @@ mod tests { assert_eq!(two_tabs.try_compare(tab), Ok(Ordering::Greater)); assert_eq!(tab.try_compare(two_tabs), Ok(Ordering::Less)); } + + #[test] + fn indentation_try_compare_mixed_tabs() { + let tab = Indentation::new(Column::new(8), Character::new(1)); + let eight_spaces = Indentation::new(Column::new(8), Character::new(8)); + let tab_and_space = Indentation::new(Column::new(9), Character::new(2)); + + assert_eq!( + tab.try_compare(eight_spaces), + Err(IndentationError::InconsistentTabs) + ); + assert_eq!( + eight_spaces.try_compare(tab_and_space), + Err(IndentationError::InconsistentTabs) + ); + assert_eq!(tab.try_compare(tab_and_space), Ok(Ordering::Less)); + } } diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index c436ed5572cffd..01d6db94bd5cce 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -668,21 +668,33 @@ impl<'src> Parser<'src> { if !is_same_location { errors.push(ParseError { + location: reported_range(&error, range), error, - location: range, }); } } - let mut range = ranged.range(); - // A misplaced starred expression or star pattern is reported at its `*`. - if matches!( - error, - ParseErrorType::InvalidStarredExpressionUsage | ParseErrorType::InvalidStarPatternUsage - ) { - range = TextRange::at(range.start(), TextSize::new(1)); + fn reported_range(error: &ParseErrorType, range: TextRange) -> TextRange { + match error { + // A misplaced starred expression or star pattern is reported at its `*`. + ParseErrorType::InvalidStarredExpressionUsage + | ParseErrorType::InvalidStarPatternUsage => { + TextRange::at(range.start(), TextSize::new(1)) + } + // An unexpected indent is reported at the last character of the indentation. + ParseErrorType::UnexpectedIndentation if !range.is_empty() => { + TextRange::at(range.end() - TextSize::new(1), TextSize::new(1)) + } + _ => range, + } } - inner(&mut self.errors, error, range); + + // The lexer already reported an error for the current token, which comes first. + if self.at(TokenKind::Unknown) { + return; + } + + inner(&mut self.errors, error, ranged.range()); } /// Add an [`UnsupportedSyntaxError`] with the given [`UnsupportedSyntaxErrorKind`] and diff --git a/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__fstring_expr_inner_line_continuation_and_t_string.snap b/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__fstring_expr_inner_line_continuation_and_t_string.snap index 490211dd4ea0ed..3bf63899e39946 100644 --- a/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__fstring_expr_inner_line_continuation_and_t_string.snap +++ b/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__fstring_expr_inner_line_continuation_and_t_string.snap @@ -6,5 +6,5 @@ ParseError { error: Lexical( LineContinuationError, ), - location: 3..4, + location: 4..4, } diff --git a/crates/ruff_python_parser/src/parser/tests.rs b/crates/ruff_python_parser/src/parser/tests.rs index 8c856712d0f68d..21c0fe1f217019 100644 --- a/crates/ruff_python_parser/src/parser/tests.rs +++ b/crates/ruff_python_parser/src/parser/tests.rs @@ -2,7 +2,9 @@ use std::assert_matches; use ruff_python_ast::{Expr, InterpolatedStringElement, IpyEscapeKind, Number, Stmt}; -use crate::{Mode, ParseOptions, parse, parse_expression, parse_module}; +use crate::{ + LexicalErrorType, Mode, ParseErrorType, ParseOptions, parse, parse_expression, parse_module, +}; // Keep recursive ASTs shallow enough for Windows's 1 MiB test-thread stacks. const RECURSIVE_AST_TEST_DEPTH: usize = 1_000; @@ -375,6 +377,7 @@ fn deep_nesting_preserves_surrounding_statements() { #[test] fn nested_def_blocks_grow_stack() { // Each nested function crosses the suite boundary where the parser rechecks the stack. + // Indentation stops at 99 levels, so the deeper blocks are reported instead of parsed. let depth = RECURSIVE_AST_TEST_DEPTH; let mut src = String::new(); for i in 0..depth { @@ -383,7 +386,11 @@ fn nested_def_blocks_grow_stack() { } src.push_str(&"\t".repeat(depth)); src.push_str("pass\n"); - parse_module(&src).unwrap(); + let error = parse_module(&src).unwrap_err(); + assert_eq!( + error.error, + ParseErrorType::Lexical(LexicalErrorType::TooDeepIndentation) + ); } #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__backslash_continuation_mismatch_indentation.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__backslash_continuation_mismatch_indentation.snap index 1c38031ff47226..3d9d62651a802b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__backslash_continuation_mismatch_indentation.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__backslash_continuation_mismatch_indentation.snap @@ -22,7 +22,7 @@ expression: "lex_invalid(&source, Mode::Module)" [ LexicalError { error: IndentationError, - location: 15..23, + location: 24..24, }, ] ``` diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tet_too_low_dedent.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tet_too_low_dedent.snap index 0d5f83daccb46e..15d725022db584 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tet_too_low_dedent.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tet_too_low_dedent.snap @@ -22,7 +22,7 @@ expression: "lex_invalid(source, Mode::Module)" [ LexicalError { error: IndentationError, - location: 18..20, + location: 24..24, }, ] ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap index 9a0b8e2ef7cf53..c7e2dea2b1783a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@backslash_continuation_indentation_error.py.snap @@ -65,8 +65,7 @@ Module( ## Errors | -1 | if True: -2 | 1 -3 | / \ -4 | | 2 - | |____^ Syntax Error: unexpected indentation +2 | 1 +3 | \ +4 | 2 + | ^ Syntax Error: unexpected indent diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap index 188fbda1d97336..2d84884218d341 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_unparenthesized_tuple_as_incomplete.py.snap @@ -209,7 +209,7 @@ Module( 2 | pass 3 | except x, y as (exc): 4 | pass - | ^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 5 | try: 6 | pass | 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 a48c3053e1e525..4b8ce2635cd795 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 @@ -92,7 +92,7 @@ Module( 2 | pass 3 | elf: 4 | pass - | ^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 5 | else: 6 | pass | @@ -129,4 +129,4 @@ Module( 4 | pass 5 | else: 6 | pass - | ^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 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 86ed30ea320d5f..40671188f16037 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 @@ -465,7 +465,7 @@ Module( | 8 | f'middle {'string':\\ 9 | 'format spec'} - | ^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 10 | 11 | f'middle {'string':\\\ | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap index 77889c58598368..6b59262e774325 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__line_continuation_1.py.snap @@ -101,7 +101,7 @@ Module( | 1 | call(a, b, \\\ - | ^ Syntax Error: unexpected character after line continuation character + | ^ Syntax Error: unexpected character after line continuation character 2 | 3 | def bar(): | @@ -109,7 +109,7 @@ Module( | 1 | call(a, b, \\\ - | ^ Syntax Error: unexpected character after line continuation character + | ^ Syntax Error: unexpected character after line continuation character 2 | 3 | def bar(): | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap index 1b482bcd9ae00b..80de24ea6d2624 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap @@ -75,4 +75,4 @@ Module( 1 | # FIXME(micha): This creates two syntax errors instead of just one (and overlapping ones) 2 | if True)): 3 | pass - | ^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 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 5c1e64db6f56f0..13bc4dd2186208 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 @@ -532,7 +532,7 @@ Module( 2 | if True: 3 | pass 4 | a + b - | ^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 5 | 6 | pass | @@ -542,7 +542,7 @@ Module( 11 | if True: 12 | before_nested 13 | first_nested - | ^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 14 | second_nested 15 | after_nested | @@ -552,7 +552,7 @@ Module( 12 | before_nested 13 | first_nested 14 | second_nested - | ^^^^^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 15 | after_nested | @@ -561,7 +561,7 @@ Module( 20 | if True: 21 | before_compound 22 | if condition: - | ^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 23 | nested_compound 24 | recovered_compound | @@ -571,7 +571,7 @@ Module( 30 | if True: 31 | before_regions 32 | first_region - | ^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 33 | middle_region 34 | second_region | @@ -581,7 +581,7 @@ Module( 32 | first_region 33 | middle_region 34 | second_region - | ^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 35 | after_region | @@ -590,7 +590,7 @@ Module( 40 | if True: 41 | before_error 42 | broken(,) - | ^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 43 | after_error | @@ -608,4 +608,4 @@ Module( 48 | if True: 49 | before_eof 50 | final_eof - | ^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap index f64f6e8fadbdc7..9add671bfaadb3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap @@ -164,7 +164,7 @@ Module( 3 | # v 4 | case {(x as y): 1}: 5 | pass - | ^^^^^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap index 5bdd7806fe646a..b6663eb1fe476a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_invalid_order.py.snap @@ -83,4 +83,4 @@ Module( 4 | pass 5 | else: 6 | pass - | ^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 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 2d4d0f0d9578f6..b9421f6fc39485 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 @@ -228,7 +228,7 @@ Module( 2 | pass 3 | exept: # spellchecker:disable-line 4 | pass - | ^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 5 | finally: 6 | pass | @@ -269,7 +269,7 @@ Module( 4 | pass 5 | finally: 6 | pass - | ^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 7 | a = 1 8 | try: | @@ -289,6 +289,6 @@ Module( 11 | pass 12 | exept: # spellchecker:disable-line 13 | pass - | ^^^^ Syntax Error: unexpected indentation + | ^ Syntax Error: unexpected indent 14 | b = 1 | From e68ded45e1af139d1fda761ebb5549f8782fec0f Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 4 Oct 2026 23:52:03 +0900 Subject: [PATCH 08/20] Report unterminated strings at their start with the detected line `LexicalErrorType::UnclosedStringError` now carries whether the string is triple-quoted, whether it contains a backslash followed by its quote character, and the line at which the lexer reached the end of the line or the source. The f/t-string `UnterminatedString` and `UnterminatedTripleQuotedString` errors carry the detected line too, and the messages include it. These errors are reported as an empty range at the start of the string, including its prefix, for which `InterpolatedStringContext` now records the start offset. Assisted-by: Claude Code:claude-opus-5-5 --- crates/ruff_python_parser/src/error.rs | 60 ++++-- crates/ruff_python_parser/src/lexer.rs | 199 +++++++++++++----- .../src/lexer/interpolated_string.rs | 12 +- ...r__tests__fstring_newline_format_spec.snap | 16 +- ...r__tests__tstring_newline_format_spec.snap | 16 +- ...y_concatenated_unterminated_string.py.snap | 13 +- ...ated_unterminated_string_multiline.py.snap | 4 +- ...nvalid_syntax@re_lex_logical_token.py.snap | 4 +- ...x@re_lexing__fstring_format_spec_1.py.snap | 4 +- ...re_lexing__triple_quoted_fstring_1.py.snap | 10 +- .../invalid_syntax@re_lexing__ty_1828.py.snap | 19 +- ...erminated_fstring_newline_recovery.py.snap | 15 +- 12 files changed, 266 insertions(+), 106 deletions(-) diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index db9f1faca7e1ea..cf98ddb7095de9 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -64,10 +64,10 @@ pub enum InterpolatedStringErrorType { InvalidConversionFlag, /// A single right brace was encountered. SingleRbrace, - /// Unterminated string. - UnterminatedString, - /// Unterminated triple-quoted string. - UnterminatedTripleQuotedString, + /// Unterminated string, detected at the given one-based line. + UnterminatedString { detected_line: u32 }, + /// Unterminated triple-quoted string, detected at the given one-based line. + UnterminatedTripleQuotedString { detected_line: u32 }, /// A lambda expression without parentheses was encountered. LambdaWithoutParentheses, /// Conversion flag does not immediately follow exclamation. @@ -82,8 +82,10 @@ impl std::fmt::Display for InterpolatedStringErrorType { Self::UnclosedLbrace => f.write_str("expecting '}'"), Self::InvalidConversionFlag => write!(f, "invalid conversion character"), Self::SingleRbrace => f.write_str("single '}' is not allowed"), - Self::UnterminatedString => write!(f, "unterminated string"), - Self::UnterminatedTripleQuotedString => write!(f, "unterminated triple-quoted string"), + Self::UnterminatedString { .. } => write!(f, "unterminated string"), + Self::UnterminatedTripleQuotedString { .. } => { + write!(f, "unterminated triple-quoted string") + } Self::LambdaWithoutParentheses => { write!(f, "lambda expressions are not allowed without parentheses") } @@ -107,11 +109,17 @@ fn write_interpolated_string_error( error: &InterpolatedStringErrorType, ) -> std::fmt::Result { match error { - InterpolatedStringErrorType::UnterminatedString => { - write!(f, "unterminated {kind} literal") + InterpolatedStringErrorType::UnterminatedString { detected_line } => { + write!( + f, + "unterminated {kind} literal (detected at line {detected_line})" + ) } - InterpolatedStringErrorType::UnterminatedTripleQuotedString => { - write!(f, "unterminated triple-quoted {kind} literal") + InterpolatedStringErrorType::UnterminatedTripleQuotedString { detected_line } => { + write!( + f, + "unterminated triple-quoted {kind} literal (detected at line {detected_line})" + ) } _ => write!(f, "{kind}: {error}"), } @@ -411,8 +419,13 @@ pub enum LexicalErrorType { // to use the `UnicodeError` variant instead. #[doc(hidden)] StringError, - /// A string literal without the closing quote. - UnclosedStringError, + /// A string literal without the closing quote, detected at the given one-based line. + UnclosedStringError { + triple_quoted: bool, + /// The literal contains a backslash followed by its quote character. + escaped_end_quote: bool, + detected_line: u32, + }, /// Decoding of a unicode escape sequence in a string literal failed. UnicodeError, /// Missing the `{` for unicode escape sequence. @@ -480,8 +493,27 @@ impl std::fmt::Display for LexicalErrorType { } Self::Eof => write!(f, "unexpected EOF while parsing"), Self::OtherError(msg) => write!(f, "{msg}"), - Self::UnclosedStringError => { - write!(f, "missing closing quote in string literal") + Self::UnclosedStringError { + triple_quoted: true, + detected_line, + .. + } => write!( + f, + "unterminated triple-quoted string literal (detected at line {detected_line})" + ), + Self::UnclosedStringError { + escaped_end_quote, + detected_line, + .. + } => { + write!( + f, + "unterminated string literal (detected at line {detected_line})" + )?; + if *escaped_end_quote { + f.write_str("; perhaps you escaped the end quote?")?; + } + Ok(()) } Self::MissingUnicodeLbrace => { write!(f, "missing `{{` in Unicode escape sequence") diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index ec8863605bff3a..611250dfa2ef1c 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -792,7 +792,11 @@ impl<'src> Lexer<'src> { self.current_flags |= TokenFlags::TRIPLE_QUOTED_STRING; } - let ftcontext = InterpolatedStringContext::new(self.current_flags, self.nesting)?; + let ftcontext = InterpolatedStringContext::new( + self.current_flags, + self.nesting, + self.token_range().start(), + )?; let kind = ftcontext.kind(); @@ -831,10 +835,14 @@ impl<'src> Lexer<'src> { // in the source code and the one returned by `self.cursor.first()` when // we reach the end of the source code. EOF_CHAR if self.cursor.is_eof() => { + let detected_line = self.detected_line(); + let range = TextRange::empty(interpolated_string.start()); let error = if interpolated_string.is_triple_quoted() { - InterpolatedStringErrorType::UnterminatedTripleQuotedString + InterpolatedStringErrorType::UnterminatedTripleQuotedString { + detected_line, + } } else { - InterpolatedStringErrorType::UnterminatedString + InterpolatedStringErrorType::UnterminatedString { detected_line } }; self.nesting = interpolated_string.nesting(); @@ -842,7 +850,7 @@ impl<'src> Lexer<'src> { self.current_flags |= TokenFlags::UNCLOSED_STRING; self.push_error(LexicalError::new( LexicalErrorType::from_interpolated_string_error(error, string_kind), - self.token_range(), + range, )); break; @@ -850,10 +858,18 @@ impl<'src> Lexer<'src> { '\n' | '\r' if !interpolated_string.is_triple_quoted() => { // https://github.com/astral-sh/ruff/issues/18632 - let error_type = if in_format_spec { - InterpolatedStringErrorType::NewlineInFormatSpec + let (error_type, range) = if in_format_spec { + ( + InterpolatedStringErrorType::NewlineInFormatSpec, + self.token_range(), + ) } else { - InterpolatedStringErrorType::UnterminatedString + ( + InterpolatedStringErrorType::UnterminatedString { + detected_line: self.detected_line(), + }, + TextRange::empty(interpolated_string.start()), + ) }; self.nesting = interpolated_string.nesting(); @@ -862,7 +878,7 @@ impl<'src> Lexer<'src> { self.push_error(LexicalError::new( LexicalErrorType::from_interpolated_string_error(error_type, string_kind), - self.token_range(), + range, )); break; @@ -953,10 +969,7 @@ impl<'src> Lexer<'src> { self.cursor.skip_to_end(); self.current_flags |= TokenFlags::UNCLOSED_STRING; - self.push_error(LexicalError::new( - LexicalErrorType::UnclosedStringError, - self.token_range(), - )); + self.push_unclosed_string_error(quote); break; }; @@ -990,11 +1003,7 @@ impl<'src> Lexer<'src> { else { self.cursor.skip_to_end(); self.current_flags |= TokenFlags::UNCLOSED_STRING; - - self.push_error(LexicalError::new( - LexicalErrorType::UnclosedStringError, - self.token_range(), - )); + self.push_unclosed_string_error(quote); break; }; @@ -1025,10 +1034,7 @@ impl<'src> Lexer<'src> { match quote_or_newline { '\r' | '\n' => { self.current_flags |= TokenFlags::UNCLOSED_STRING; - self.push_error(LexicalError::new( - LexicalErrorType::UnclosedStringError, - self.token_range(), - )); + self.push_unclosed_string_error(quote); break; } ch if ch == quote => { @@ -1043,6 +1049,46 @@ impl<'src> Lexer<'src> { TokenKind::String } + /// Pushes an [`LexicalErrorType::UnclosedStringError`] for the string token lexed so far, + /// reported at the start of the token. + fn push_unclosed_string_error(&mut self, quote: char) { + let range = self.token_range(); + let body = &self.source[range]; + let body = &body[body.find(quote).unwrap_or(0)..]; + let mut escaped_end_quote = false; + let mut chars = body.chars(); + while let Some(c) = chars.next() { + if c == '\\' && chars.next() == Some(quote) { + escaped_end_quote = true; + break; + } + } + let error = LexicalErrorType::UnclosedStringError { + triple_quoted: self.current_flags.is_triple_quoted(), + escaped_end_quote, + detected_line: self.detected_line(), + }; + self.push_error(LexicalError::new(error, TextRange::empty(range.start()))); + } + + /// Returns the one-based line number of the cursor, where a newline that ends the source + /// belongs to the line it terminates. + fn detected_line(&self) -> u32 { + let source = self.source.as_bytes(); + let mut offset = self.offset().to_usize(); + if offset == source.len() && matches!(source.last(), Some(b'\n' | b'\r')) { + offset -= 1; + } + let newlines = source[..offset] + .iter() + .enumerate() + .filter(|&(index, &byte)| { + byte == b'\n' || (byte == b'\r' && source.get(index + 1) != Some(&b'\n')) + }) + .count(); + u32::try_from(newlines + 1).unwrap() + } + /// Numeric lexing. The feast can start! fn lex_number(&mut self, first: char) -> TokenKind { if first == '0' { @@ -1207,12 +1253,13 @@ impl<'src> Lexer<'src> { // First, finish any unterminated interpolated-strings. while let Some(interpolated_string) = self.interpolated_strings.pop() { self.nesting = interpolated_string.nesting(); + let detected_line = self.detected_line(); self.push_error(LexicalError::new( LexicalErrorType::from_interpolated_string_error( - InterpolatedStringErrorType::UnterminatedString, + InterpolatedStringErrorType::UnterminatedString { detected_line }, interpolated_string.kind(), ), - self.token_range(), + TextRange::empty(interpolated_string.start()), )); } @@ -1389,8 +1436,8 @@ impl<'src> Lexer<'src> { } if self.errors.last().is_some_and(|error| { - error.location() == self.current_range - && matches!(error.error(), LexicalErrorType::UnclosedStringError) + error.location().start() == self.current_range.start() + && matches!(error.error(), LexicalErrorType::UnclosedStringError { .. }) }) { self.errors.pop(); } @@ -1429,8 +1476,8 @@ impl<'src> Lexer<'src> { == AnyStringPrefix::Regular(StringLiteralPrefix::Raw { uppercase: false }) { if self.errors.last().is_some_and(|error| { - error.location() == self.current_range - && matches!(error.error(), LexicalErrorType::UnclosedStringError) + error.location().start() == self.current_range.start() + && matches!(error.error(), LexicalErrorType::UnclosedStringError { .. }) }) { self.errors.pop(); } @@ -2647,19 +2694,31 @@ t"{(lambda x:{x})}" assert_eq!(lex_fstring_error("f'{3:}}>10}'"), SingleRbrace); assert_eq!(lex_fstring_error(r"f'\{foo}\}'"), SingleRbrace); - assert_eq!(lex_fstring_error(r#"f""#), UnterminatedString); - assert_eq!(lex_fstring_error(r"f'"), UnterminatedString); + assert!(matches!( + lex_fstring_error(r#"f""#), + UnterminatedString { .. } + )); + assert!(matches!( + lex_fstring_error(r"f'"), + UnterminatedString { .. } + )); - assert_eq!(lex_fstring_error(r#"f""""#), UnterminatedTripleQuotedString); - assert_eq!(lex_fstring_error(r"f'''"), UnterminatedTripleQuotedString); - assert_eq!( + assert!(matches!( + lex_fstring_error(r#"f""""#), + UnterminatedTripleQuotedString { .. } + )); + assert!(matches!( + lex_fstring_error(r"f'''"), + UnterminatedTripleQuotedString { .. } + )); + assert!(matches!( lex_fstring_error(r#"f"""""#), - UnterminatedTripleQuotedString - ); - assert_eq!( + UnterminatedTripleQuotedString { .. } + )); + assert!(matches!( lex_fstring_error(r#"f""""""#), - UnterminatedTripleQuotedString - ); + UnterminatedTripleQuotedString { .. } + )); } fn lex_tstring_error(source: &str) -> InterpolatedStringErrorType { @@ -2694,9 +2753,11 @@ t"{(lambda x:{x})}" [ LexicalError { error: FStringError( - UnterminatedString, + UnterminatedString { + detected_line: 1, + }, ), - location: 2..7, + location: 0..0, }, ] ``` @@ -2721,14 +2782,20 @@ t"{(lambda x:{x})}" ``` [ LexicalError { - error: UnclosedStringError, - location: 3..4, + error: UnclosedStringError { + triple_quoted: false, + escaped_end_quote: false, + detected_line: 1, + }, + location: 3..3, }, LexicalError { error: FStringError( - UnterminatedString, + UnterminatedString { + detected_line: 1, + }, ), - location: 4..4, + location: 0..0, }, ] ``` @@ -2755,14 +2822,20 @@ t"{(lambda x:{x})}" ``` [ LexicalError { - error: UnclosedStringError, - location: 7..9, + error: UnclosedStringError { + triple_quoted: false, + escaped_end_quote: false, + detected_line: 1, + }, + location: 7..7, }, LexicalError { error: FStringError( - UnterminatedString, + UnterminatedString { + detected_line: 1, + }, ), - location: 9..9, + location: 0..0, }, ] ``` @@ -2784,19 +2857,31 @@ t"{(lambda x:{x})}" assert_eq!(lex_tstring_error("t'{3:}}>10}'"), SingleRbrace); assert_eq!(lex_tstring_error(r"t'\{foo}\}'"), SingleRbrace); - assert_eq!(lex_tstring_error(r#"t""#), UnterminatedString); - assert_eq!(lex_tstring_error(r"t'"), UnterminatedString); + assert!(matches!( + lex_tstring_error(r#"t""#), + UnterminatedString { .. } + )); + assert!(matches!( + lex_tstring_error(r"t'"), + UnterminatedString { .. } + )); - assert_eq!(lex_tstring_error(r#"t""""#), UnterminatedTripleQuotedString); - assert_eq!(lex_tstring_error(r"t'''"), UnterminatedTripleQuotedString); - assert_eq!( + assert!(matches!( + lex_tstring_error(r#"t""""#), + UnterminatedTripleQuotedString { .. } + )); + assert!(matches!( + lex_tstring_error(r"t'''"), + UnterminatedTripleQuotedString { .. } + )); + assert!(matches!( lex_tstring_error(r#"t"""""#), - UnterminatedTripleQuotedString - ); - assert_eq!( + UnterminatedTripleQuotedString { .. } + )); + assert!(matches!( lex_tstring_error(r#"t""""""#), - UnterminatedTripleQuotedString - ); + UnterminatedTripleQuotedString { .. } + )); } #[test] diff --git a/crates/ruff_python_parser/src/lexer/interpolated_string.rs b/crates/ruff_python_parser/src/lexer/interpolated_string.rs index 826edfa79642e4..d165be8692c291 100644 --- a/crates/ruff_python_parser/src/lexer/interpolated_string.rs +++ b/crates/ruff_python_parser/src/lexer/interpolated_string.rs @@ -1,4 +1,5 @@ use ruff_python_ast::StringFlags; +use ruff_text_size::TextSize; use crate::string::InterpolatedStringKind; @@ -18,15 +19,19 @@ pub(crate) struct InterpolatedStringContext { /// there can be multiple format specs nested for the same f-string. /// For example, `{a:{b:{c}}}` has 3 format specs. format_spec_depth: u32, + + /// The start of the f/t-string, including its prefix. + start: TextSize, } impl InterpolatedStringContext { - pub(crate) const fn new(flags: TokenFlags, nesting: u32) -> Option { + pub(crate) const fn new(flags: TokenFlags, nesting: u32, start: TextSize) -> Option { if flags.is_interpolated_string() { Some(Self { flags, nesting, format_spec_depth: 0, + start, }) } else { None @@ -51,6 +56,11 @@ impl InterpolatedStringContext { self.nesting } + /// Returns the start of the f/t-string, including its prefix. + pub(crate) const fn start(&self) -> TextSize { + self.start + } + /// Returns the quote character for the current f-string. pub(crate) fn quote_char(&self) -> char { self.flags.quote_style().as_char() diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__fstring_newline_format_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__fstring_newline_format_spec.snap index 589f4fa68df9a0..77ac031429992c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__fstring_newline_format_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__fstring_newline_format_spec.snap @@ -46,8 +46,12 @@ expression: "lex_invalid(source, Mode::Module)" location: 13..14, }, LexicalError { - error: UnclosedStringError, - location: 18..19, + error: UnclosedStringError { + triple_quoted: false, + escaped_end_quote: false, + detected_line: 4, + }, + location: 18..18, }, LexicalError { error: FStringError( @@ -56,8 +60,12 @@ expression: "lex_invalid(source, Mode::Module)" location: 32..33, }, LexicalError { - error: UnclosedStringError, - location: 47..48, + error: UnclosedStringError { + triple_quoted: false, + escaped_end_quote: false, + detected_line: 8, + }, + location: 47..47, }, ] ``` diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tstring_newline_format_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tstring_newline_format_spec.snap index 76291b41bf998f..5c8e926ae42ad1 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tstring_newline_format_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tstring_newline_format_spec.snap @@ -46,8 +46,12 @@ expression: "lex_invalid(source, Mode::Module)" location: 13..14, }, LexicalError { - error: UnclosedStringError, - location: 18..19, + error: UnclosedStringError { + triple_quoted: false, + escaped_end_quote: false, + detected_line: 4, + }, + location: 18..18, }, LexicalError { error: TStringError( @@ -56,8 +60,12 @@ expression: "lex_invalid(source, Mode::Module)" location: 32..33, }, LexicalError { - error: UnclosedStringError, - location: 47..48, + error: UnclosedStringError { + triple_quoted: false, + escaped_end_quote: false, + detected_line: 8, + }, + location: 47..47, }, ] ``` diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap index 5dc27f2c95256c..edba18ddd324cd 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string.py.snap @@ -198,7 +198,7 @@ Module( | 1 | 'hello' 'world - | ^^^^^^ Syntax Error: missing closing quote in string literal + | ^ Syntax Error: unterminated string literal (detected at line 1) 2 | 1 + 1 3 | 'hello' f'world {x} | @@ -208,6 +208,15 @@ Module( 1 | 'hello' 'world 2 | 1 + 1 3 | 'hello' f'world {x} - | ^ Syntax Error: unterminated f-string literal + | ^ Syntax Error: unterminated f-string literal (detected at line 3) +4 | 2 + 2 + | + + + | +1 | 'hello' 'world +2 | 1 + 1 +3 | 'hello' f'world {x} + | ^ Syntax Error: invalid syntax 4 | 2 + 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap index 237a21f958fcd0..12fc46f9d5d76b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@implicitly_concatenated_unterminated_string_multiline.py.snap @@ -224,7 +224,7 @@ Module( 1 | ( 2 | 'hello' 3 | f'world {x} - | ^ Syntax Error: unterminated f-string literal + | ^ Syntax Error: unterminated f-string literal (detected at line 3) 4 | ) 5 | 1 + 1 | @@ -255,7 +255,7 @@ Module( 6 | ( 7 | 'first' 8 | 'second - | ^^^^^^^ Syntax Error: missing closing quote in string literal + | ^ Syntax Error: unterminated string literal (detected at line 8) 9 | f'third' 10 | ) | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap index 63bf85a52d87cb..714ee338c5dc24 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap @@ -967,7 +967,7 @@ Module( | 49 | # F-strings uses normal list parsing, so test those as well 50 | if call(f"hello {x - | ^ Syntax Error: unterminated f-string literal + | ^ Syntax Error: unterminated f-string literal (detected at line 50) 51 | def bar(): 52 | pass | @@ -993,7 +993,7 @@ Module( | 55 | if call(f"hello - | ^^^^^ Syntax Error: unterminated f-string literal + | ^ Syntax Error: unterminated f-string literal (detected at line 55) 56 | def bar(): 57 | pass | 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 40671188f16037..92f497b1901f16 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 @@ -436,7 +436,7 @@ Module( | 5 | f'middle {'string':\ 6 | 'format spec'} - | ^^ Syntax Error: missing closing quote in string literal + | ^ Syntax Error: unterminated string literal (detected at line 6) 7 | 8 | f'middle {'string':\\ | @@ -511,4 +511,4 @@ Module( | 11 | f'middle {'string':\\\ 12 | 'format spec'} - | ^^ Syntax Error: missing closing quote in string literal + | ^ Syntax Error: unterminated string literal (detected at line 12) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap index 6cc40a19b4130b..e3dfa752353269 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap @@ -75,12 +75,12 @@ Module( ## Errors | -3 | # https://github.com/astral-sh/ruff/issues/11929 +3 | # https://github.com/astral-sh/ruff/issues/11929 4 | -5 | f"""hello {x # comment - | ___________________________^ -6 | | y = 1 - | |_____^ Syntax Error: unterminated triple-quoted f-string literal +5 | f"""hello {x # comment + | ^ Syntax Error: unterminated triple-quoted f-string literal (detected at line 6) +6 | y = 1 + | | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap index a426d014f3c635..96631687913d24 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap @@ -169,6 +169,15 @@ Module( | + | +1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 +2 | (c: int = 1,f"""{d=[ + | ^ Syntax Error: unterminated triple-quoted f-string literal (detected at line 5) +3 | def a( +4 | class A: + | + + | 1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 2 | (c: int = 1,f"""{d=[ @@ -198,16 +207,6 @@ Module( | - | -1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 -2 | (c: int = 1,f"""{d=[ -3 | def a( - | _______^ -4 | | class A: -5 | | pass - | |_________^ Syntax Error: unterminated triple-quoted f-string literal - - | 2 | (c: int = 1,f"""{d=[ 3 | def a( diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap index f2e687b13c648a..6a4fbb1a560d32 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap @@ -357,7 +357,7 @@ Module( | 1 | f"hello - | ^^^^^ Syntax Error: unterminated f-string literal + | ^ Syntax Error: unterminated f-string literal (detected at line 1) 2 | 1 + 1 3 | f"hello {x | @@ -376,7 +376,7 @@ Module( 1 | f"hello 2 | 1 + 1 3 | f"hello {x - | ^ Syntax Error: unterminated f-string literal + | ^ Syntax Error: unterminated f-string literal (detected at line 3) 4 | 2 + 2 5 | f"hello {x: | @@ -417,6 +417,15 @@ Module( 5 | f"hello {x: 6 | 3 + 3 7 | f"hello {x} - | ^ Syntax Error: unterminated f-string literal + | ^ Syntax Error: unterminated f-string literal (detected at line 7) +8 | 4 + 4 + | + + + | +5 | f"hello {x: +6 | 3 + 3 +7 | f"hello {x} + | ^ Syntax Error: invalid syntax 8 | 4 + 4 | From 0b20bf480cf4c85bacd6cc13e8eaea427b050ba4 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 5 Oct 2026 02:02:36 +0900 Subject: [PATCH 09/20] Report bracket errors and prioritize tokenizer errors Add lexer error kinds for unmatched, mismatched and unclosed brackets and for brackets nested more than 200 deep. An unclosed bracket is reported at the innermost opening bracket instead of as an unexpected EOF, and an unterminated replacement field reports its open bracket. Report unrecognized non-ASCII and control characters with their code points. After parsing, tokenize the source again and move the first tokenizer error in front of the parser's first error when tokenizing the rest of the source would report it. `UnclosedBracket::incomplete` tells whether the parser read to the end of the source with the bracket open. Assisted-by: Claude Code:claude-opus-5-5 --- crates/ruff_python_parser/src/error.rs | 76 +++++++ crates/ruff_python_parser/src/lexer.rs | 206 ++++++++++++++---- crates/ruff_python_parser/src/parser/mod.rs | 146 ++++++++++++- crates/ruff_python_parser/src/parser/tests.rs | 69 +++++- ...r__tests__fstring_newline_format_spec.snap | 12 + ...r__tests__tstring_newline_format_spec.snap | 12 + crates/ruff_python_parser/src/string.rs | 12 +- ...class_def_unclosed_type_param_list.py.snap | 8 + ...valid_syntax@del_incomplete_target.py.snap | 5 +- ...expressions__arguments__unclosed_0.py.snap | 8 + ...expressions__arguments__unclosed_1.py.snap | 8 + ...expressions__arguments__unclosed_2.py.snap | 8 + ...ons__dict__missing_closing_brace_0.py.snap | 10 +- ...ons__dict__missing_closing_brace_1.py.snap | 10 +- ...ons__dict__missing_closing_brace_2.py.snap | 8 + ...tax@expressions__emoji_identifiers.py.snap | 6 +- ...yntax@expressions__emoji_statement.py.snap | 2 +- ...x@expressions__list__comprehension.py.snap | 4 +- ...s__list__missing_closing_bracket_0.py.snap | 9 +- ...s__list__missing_closing_bracket_1.py.snap | 12 +- ...s__list__missing_closing_bracket_2.py.snap | 12 +- ...s__list__missing_closing_bracket_3.py.snap | 10 + ...sions__named__missing_expression_1.py.snap | 9 +- ...sions__named__missing_expression_2.py.snap | 12 +- ...sions__named__missing_expression_3.py.snap | 12 +- ...ressions__parenthesized__generator.py.snap | 2 +- ...nthesized__missing_closing_paren_0.py.snap | 9 +- ...nthesized__missing_closing_paren_1.py.snap | 12 +- ...nthesized__missing_closing_paren_2.py.snap | 12 +- ...nthesized__missing_closing_paren_3.py.snap | 10 + ...set__missing_closing_curly_brace_0.py.snap | 9 +- ...set__missing_closing_curly_brace_1.py.snap | 12 +- ...set__missing_closing_curly_brace_2.py.snap | 12 +- ...set__missing_closing_curly_brace_3.py.snap | 10 + ...sions__subscript__unclosed_slice_0.py.snap | 10 +- ...sions__subscript__unclosed_slice_1.py.snap | 10 +- ...nction_def_unclosed_parameter_list.py.snap | 11 +- ...ction_def_unclosed_type_param_list.py.snap | 8 + ...ax@import_stmt_parenthesized_names.py.snap | 13 ++ ...lp_escape_command_error_recovery_2.py.snap | 10 +- ...ax@params_var_keyword_with_default.py.snap | 7 +- ...params_var_positional_with_default.py.snap | 2 +- ...nvalid_syntax@re_lex_logical_token.py.snap | 20 +- ...yntax@re_lex_logical_token_mac_eol.py.snap | 5 + ...x@re_lex_logical_token_windows_eol.py.snap | 8 + ...x@re_lexing__fstring_format_spec_1.py.snap | 10 +- ...ing__line_continuation_windows_eol.py.snap | 8 + ...re_lexing__triple_quoted_fstring_1.py.snap | 10 +- ...re_lexing__triple_quoted_fstring_3.py.snap | 35 ++- .../invalid_syntax@re_lexing__ty_1828.py.snap | 11 +- ...atements__function_type_parameters.py.snap | 2 +- ...ents__if_extra_closing_parentheses.py.snap | 4 +- ...ax@statements__match__as_pattern_3.py.snap | 11 +- ...s__with__ambiguous_lpar_with_items.py.snap | 4 +- ...nts__with__unclosed_ambiguous_lpar.py.snap | 10 +- ..._with__unclosed_ambiguous_lpar_eof.py.snap | 7 +- ...syntax@type_param_param_spec_bound.py.snap | 2 +- ...ax@type_param_type_var_tuple_bound.py.snap | 2 +- 58 files changed, 873 insertions(+), 121 deletions(-) diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index cf98ddb7095de9..41ce7f8fa11ad0 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -450,6 +450,23 @@ pub enum LexicalErrorType { LineContinuationError, /// An unexpected end of file was encountered. Eof, + /// A closing bracket without an opening bracket. + UnmatchedBracket { closing: char }, + /// A closing bracket that does not match the innermost opening bracket. `opening_line` is the + /// line of the opening bracket if it is on another line. + MismatchedBracket { + closing: char, + opening: char, + opening_line: Option, + }, + /// An opening bracket that is not closed by the end of the source. + /// + /// `incomplete` is whether more input could still close it: the parser read to the end of the + /// source with the bracket open. Otherwise, the error is reported in place of an earlier syntax + /// error. + UnclosedBracket { opening: char, incomplete: bool }, + /// Brackets are nested too deeply. + TooDeeplyNestedBrackets, /// An unexpected error occurred. OtherError(Box), } @@ -457,6 +474,38 @@ pub enum LexicalErrorType { impl std::error::Error for LexicalErrorType {} impl LexicalErrorType { + /// Returns `true` if the error stops tokenization, as opposed to an error found while + /// decoding the content of a token. + pub fn is_tokenizer_error(&self) -> bool { + match self { + Self::StringError + | Self::UnicodeError + | Self::MissingUnicodeLbrace + | Self::MissingUnicodeRbrace + | Self::InvalidByteLiteral + | Self::OtherError(_) => false, + // An ASCII punctuation character is a token that the parser rejects. + Self::UnrecognizedToken { tok } => !tok.is_ascii() || tok.is_ascii_control(), + Self::FStringError(error) | Self::TStringError(error) => matches!( + error, + InterpolatedStringErrorType::UnterminatedString { .. } + | InterpolatedStringErrorType::UnterminatedTripleQuotedString { .. } + | InterpolatedStringErrorType::SingleRbrace + | InterpolatedStringErrorType::NewlineInFormatSpec + ), + Self::UnclosedStringError { .. } + | Self::IndentationError + | Self::TabError + | Self::TooDeepIndentation + | Self::LineContinuationError + | Self::Eof + | Self::UnmatchedBracket { .. } + | Self::MismatchedBracket { .. } + | Self::UnclosedBracket { .. } + | Self::TooDeeplyNestedBrackets => true, + } + } + pub(crate) fn from_interpolated_string_error( error: InterpolatedStringErrorType, string_kind: InterpolatedStringKind, @@ -487,11 +536,38 @@ impl std::fmt::Display for LexicalErrorType { } Self::TabError => write!(f, "inconsistent use of tabs and spaces in indentation"), Self::TooDeepIndentation => write!(f, "too many levels of indentation"), + Self::UnrecognizedToken { tok } if tok.is_ascii_control() => { + write!( + f, + "invalid non-printable character U+{:04X}", + u32::from(*tok) + ) + } + Self::UnrecognizedToken { tok } if !tok.is_ascii() => { + write!(f, "invalid character '{tok}' (U+{:04X})", u32::from(*tok)) + } Self::UnrecognizedToken { .. } => f.write_str("invalid syntax"), Self::LineContinuationError => { write!(f, "unexpected character after line continuation character") } Self::Eof => write!(f, "unexpected EOF while parsing"), + Self::UnmatchedBracket { closing } => write!(f, "unmatched '{closing}'"), + Self::MismatchedBracket { + closing, + opening, + opening_line, + } => { + write!( + f, + "closing parenthesis '{closing}' does not match opening parenthesis '{opening}'" + )?; + if let Some(line) = opening_line { + write!(f, " on line {line}")?; + } + Ok(()) + } + Self::UnclosedBracket { opening, .. } => write!(f, "'{opening}' was never closed"), + Self::TooDeeplyNestedBrackets => f.write_str("too many nested parentheses"), Self::OtherError(msg) => write!(f, "{msg}"), Self::UnclosedStringError { triple_quoted: true, diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 611250dfa2ef1c..0c2802cb820d19 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -58,6 +58,11 @@ pub struct Lexer<'src> { /// The lexer is within a parenthesized context if the value is greater than 0. nesting: u32, + /// The opening brackets that are not closed yet, innermost last. It holds the innermost + /// `nesting` brackets; the implicit outer parentheses of + /// [`Mode::ParenthesizedExpression`] have no entry. + brackets: Vec, + /// A stack of indentation representing the current indentation level. indentations: Indentations, pending_indentation: Option, @@ -98,6 +103,7 @@ impl<'src> Lexer<'src> { current_range: TextRange::empty(start_offset), current_flags: TokenFlags::empty(), nesting, + brackets: Vec::new(), indentations: Indentations::default(), pending_indentation: None, mode, @@ -178,9 +184,12 @@ impl<'src> Lexer<'src> { fn lex_token(&mut self) -> TokenKind { if let Some(interpolated_string) = self.interpolated_strings.current() { if !interpolated_string.is_in_interpolation(self.nesting) { + let nesting = interpolated_string.nesting(); self.cursor.start_token(); if let Some(token) = self.lex_interpolated_string_middle_or_end() { if token.is_interpolated_string_end() { + // Brackets left open in a replacement field end with the string. + self.reset_nesting(nesting); self.interpolated_strings.pop(); } return token; @@ -266,10 +275,8 @@ impl<'src> Lexer<'src> { ))); } if self.cursor.is_eof() { - return Some(self.push_error(LexicalError::new( - LexicalErrorType::Eof, - self.token_range(), - ))); + let error = self.eof_error(self.token_range()); + return Some(self.push_error(error)); } // test_ok backslash_continuation_indentation // if True: @@ -388,10 +395,7 @@ impl<'src> Lexer<'src> { )); } if self.cursor.is_eof() { - return Err(LexicalError::new( - LexicalErrorType::Eof, - TextRange::new(whitespace_start, self.offset()), - )); + return Err(self.eof_error(TextRange::new(whitespace_start, self.offset()))); } } // Form feed @@ -523,23 +527,23 @@ impl<'src> Lexer<'src> { } '~' => TokenKind::Tilde, '(' => { - self.nesting += 1; + self.open_bracket('('); TokenKind::Lpar } ')' => { - self.nesting = self.nesting.saturating_sub(1); + self.close_bracket(')'); TokenKind::Rpar } '[' => { - self.nesting += 1; + self.open_bracket('['); TokenKind::Lsqb } ']' => { - self.nesting = self.nesting.saturating_sub(1); + self.close_bracket(']'); TokenKind::Rsqb } '{' => { - self.nesting += 1; + self.open_bracket('{'); TokenKind::Lbrace } '}' => { @@ -553,7 +557,7 @@ impl<'src> Lexer<'src> { } interpolated_string.try_end_format_spec(self.nesting); } - self.nesting = self.nesting.saturating_sub(1); + self.close_bracket('}'); TokenKind::Rbrace } ':' => { @@ -845,7 +849,7 @@ impl<'src> Lexer<'src> { InterpolatedStringErrorType::UnterminatedString { detected_line } }; - self.nesting = interpolated_string.nesting(); + self.reset_nesting(interpolated_string.nesting()); self.interpolated_strings.pop(); self.current_flags |= TokenFlags::UNCLOSED_STRING; self.push_error(LexicalError::new( @@ -872,7 +876,7 @@ impl<'src> Lexer<'src> { ) }; - self.nesting = interpolated_string.nesting(); + self.reset_nesting(interpolated_string.nesting()); self.interpolated_strings.pop(); self.current_flags |= TokenFlags::UNCLOSED_STRING; @@ -1074,12 +1078,17 @@ impl<'src> Lexer<'src> { /// Returns the one-based line number of the cursor, where a newline that ends the source /// belongs to the line it terminates. fn detected_line(&self) -> u32 { - let source = self.source.as_bytes(); - let mut offset = self.offset().to_usize(); - if offset == source.len() && matches!(source.last(), Some(b'\n' | b'\r')) { - offset -= 1; + let mut offset = self.offset(); + if offset.to_usize() == self.source.len() && self.source.ends_with(['\n', '\r']) { + offset -= TextSize::new(1); } - let newlines = source[..offset] + self.line_number(offset) + } + + /// Returns the one-based line number of `offset`. + fn line_number(&self, offset: TextSize) -> u32 { + let source = self.source.as_bytes(); + let newlines = source[..offset.to_usize()] .iter() .enumerate() .filter(|&(index, &byte)| { @@ -1089,6 +1098,66 @@ impl<'src> Lexer<'src> { u32::try_from(newlines + 1).unwrap() } + /// Returns the error for reaching the end of the source unexpectedly at `range`: the innermost + /// bracket that is not closed, if any. + fn eof_error(&self, range: TextRange) -> LexicalError { + match self.brackets.last() { + Some(bracket) => LexicalError::new( + LexicalErrorType::UnclosedBracket { + opening: bracket.kind, + incomplete: true, + }, + TextRange::empty(bracket.start), + ), + None => LexicalError::new(LexicalErrorType::Eof, range), + } + } + + /// Enters the opening bracket `kind` at the current token. + fn open_bracket(&mut self, kind: char) { + let start = self.token_range().start(); + if self.nesting >= MAX_NESTING { + self.errors.push(LexicalError::new( + LexicalErrorType::TooDeeplyNestedBrackets, + TextRange::empty(start), + )); + } + self.nesting += 1; + self.brackets.push(OpenBracket { kind, start }); + } + + /// Leaves the innermost bracket at the closing bracket `closing`, reporting a closing bracket + /// that has no opening bracket or does not match it. + fn close_bracket(&mut self, closing: char) { + let start = self.token_range().start(); + let error = match self.brackets.pop() { + Some(open) if open.kind == opening_bracket(closing) => None, + Some(open) => { + let opening_line = self.line_number(open.start); + Some(LexicalErrorType::MismatchedBracket { + closing, + opening: open.kind, + opening_line: (opening_line != self.line_number(start)).then_some(opening_line), + }) + } + None if self.nesting == 0 => Some(LexicalErrorType::UnmatchedBracket { closing }), + None => None, + }; + if let Some(error) = error { + self.errors + .push(LexicalError::new(error, TextRange::empty(start))); + } + self.nesting = self.nesting.saturating_sub(1); + } + + /// Sets the nesting level to `nesting`, dropping the brackets inside it. + fn reset_nesting(&mut self, nesting: u32) { + let implicit = self.nesting as usize - self.brackets.len(); + self.brackets + .truncate((nesting as usize).saturating_sub(implicit)); + self.nesting = nesting; + } + /// Numeric lexing. The feast can start! fn lex_number(&mut self, first: char) -> TokenKind { if first == '0' { @@ -1252,15 +1321,27 @@ impl<'src> Lexer<'src> { // First, finish any unterminated interpolated-strings. while let Some(interpolated_string) = self.interpolated_strings.pop() { - self.nesting = interpolated_string.nesting(); - let detected_line = self.detected_line(); - self.push_error(LexicalError::new( - LexicalErrorType::from_interpolated_string_error( - InterpolatedStringErrorType::UnterminatedString { detected_line }, - interpolated_string.kind(), + // An unterminated replacement field reports its innermost open bracket. + let error = match self.brackets.last() { + Some(bracket) if self.nesting > interpolated_string.nesting() => LexicalError::new( + LexicalErrorType::UnclosedBracket { + opening: bracket.kind, + incomplete: true, + }, + TextRange::empty(bracket.start), ), - TextRange::empty(interpolated_string.start()), - )); + _ => LexicalError::new( + LexicalErrorType::from_interpolated_string_error( + InterpolatedStringErrorType::UnterminatedString { + detected_line: self.detected_line(), + }, + interpolated_string.kind(), + ), + TextRange::empty(interpolated_string.start()), + ), + }; + self.reset_nesting(interpolated_string.nesting()); + self.push_error(error); } // Second, finish all nestings. @@ -1269,9 +1350,13 @@ impl<'src> Lexer<'src> { let init_nesting = u32::from(self.mode == Mode::ParenthesizedExpression); if self.nesting > init_nesting { + let error = self.eof_error(self.token_range()); // Reset the nesting to avoid going into infinite loop. self.nesting = 0; - return self.push_error(LexicalError::new(LexicalErrorType::Eof, self.token_range())); + self.brackets.clear(); + self.push_error(error); + self.current_range = self.token_range(); + return TokenKind::Unknown; } // Next, insert a trailing newline, if required. @@ -1353,6 +1438,7 @@ impl<'src> Lexer<'src> { // Reduce the nesting level because the parser recovered from an error inside list parsing // i.e., it recovered from an unclosed parenthesis (`(`, `[`, or `{`). self.nesting -= 1; + let unclosed = self.brackets.pop(); // The lexer can't be moved back for a triple-quoted f/t-string because the newlines are // part of the f/t-string itself, so there is no newline token to be emitted. @@ -1382,6 +1468,7 @@ impl<'src> Lexer<'src> { TokenKind::Rpar | TokenKind::Rsqb | TokenKind::Rbrace ) { self.nesting += 1; + self.brackets.extend(unclosed); } self.cursor = Cursor::new(self.source); @@ -1447,7 +1534,7 @@ impl<'src> Lexer<'src> { self.current_kind = kind.end_token(); self.current_flags = TokenFlags::empty(); - self.nesting = interpolated_string.nesting(); + self.reset_nesting(interpolated_string.nesting()); self.interpolated_strings.pop(); self.cursor = Cursor::new(self.source); @@ -1507,7 +1594,7 @@ impl<'src> Lexer<'src> { // SAFETY: Lexer doesn't allow files larger than 4GB #[expect(clippy::cast_possible_truncation)] #[inline] - fn offset(&self) -> TextSize { + pub(crate) fn offset(&self) -> TextSize { TextSize::new(self.source.len() as u32) - self.cursor.text_len() } @@ -1520,6 +1607,7 @@ impl<'src> Lexer<'src> { cursor_offset: self.offset(), state: self.state, nesting: self.nesting, + brackets: self.brackets.clone(), indentations_checkpoint: self.indentations.checkpoint(), pending_indentation: self.pending_indentation, interpolated_strings_checkpoint: self.interpolated_strings.checkpoint(), @@ -1536,6 +1624,7 @@ impl<'src> Lexer<'src> { cursor_offset, state, nesting, + brackets, indentations_checkpoint, pending_indentation, interpolated_strings_checkpoint, @@ -1552,6 +1641,7 @@ impl<'src> Lexer<'src> { self.cursor = cursor; self.state = state; self.nesting = nesting; + self.brackets = brackets; self.indentations.rewind(indentations_checkpoint); self.pending_indentation = pending_indentation; self.interpolated_strings @@ -1562,6 +1652,35 @@ impl<'src> Lexer<'src> { pub(crate) fn finish(self) -> Vec { self.errors } + + /// Returns the errors found so far. + pub(crate) fn errors(&self) -> &[LexicalError] { + &self.errors + } + + /// Returns `true` if the lexer is inside an f-string or t-string. + pub(crate) fn in_interpolated_string(&self) -> bool { + self.interpolated_strings.current().is_some() + } +} + +/// The maximum number of nested brackets. +const MAX_NESTING: u32 = 200; + +/// An opening bracket that is not closed yet. +#[derive(Copy, Clone, Debug)] +struct OpenBracket { + kind: char, + start: TextSize, +} + +/// Returns the opening bracket for the closing bracket `closing`. +const fn opening_bracket(closing: char) -> char { + match closing { + ')' => '(', + ']' => '[', + _ => '{', + } } pub(crate) struct LexerCheckpoint { @@ -1571,6 +1690,7 @@ pub(crate) struct LexerCheckpoint { cursor_offset: TextSize, state: State, nesting: u32, + brackets: Vec, indentations_checkpoint: IndentationsCheckpoint, pending_indentation: Option, interpolated_strings_checkpoint: InterpolatedStringsCheckpoint, @@ -2790,12 +2910,11 @@ t"{(lambda x:{x})}" location: 3..3, }, LexicalError { - error: FStringError( - UnterminatedString { - detected_line: 1, - }, - ), - location: 0..0, + error: UnclosedBracket { + opening: '{', + incomplete: true, + }, + location: 2..2, }, ] ``` @@ -2830,12 +2949,11 @@ t"{(lambda x:{x})}" location: 7..7, }, LexicalError { - error: FStringError( - UnterminatedString { - detected_line: 1, - }, - ), - location: 0..0, + error: UnclosedBracket { + opening: '{', + incomplete: true, + }, + location: 2..2, }, ] ``` diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index 01d6db94bd5cce..71079925eaf243 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -16,7 +16,8 @@ use rustc_hash::FxBuildHasher; use thin_vec::ThinVec; use unicode_normalization::UnicodeNormalization; -use crate::error::UnsupportedSyntaxError; +use crate::error::{LexicalError, LexicalErrorType, UnsupportedSyntaxError}; +use crate::lexer::Lexer; use crate::parser::expression::ExpressionContext; use crate::parser::progress::{ParserProgress, TokenId}; use crate::parser::scratch_buffer::ScratchBuffer; @@ -98,6 +99,11 @@ pub(crate) struct Parser<'src> { /// The start offset in the source code from which to start parsing at. start_offset: TextSize, + /// The start of the token at which the parser first recovered from an unclosed bracket, if + /// that happened before any error was found. The error itself is reported at the end of the + /// bracket's logical line. + first_unclosed_bracket_recovery: Option, + /// Number of active recursive statement, expression, and pattern parsing operations. recursion_depth: usize, @@ -145,6 +151,7 @@ impl<'src> Parser<'src> { recovery_context: RecoveryContext::empty(), prev_token_end: TextSize::new(0), start_offset, + first_unclosed_bracket_recovery: None, recursion_depth: 0, current_token_id: TokenId::default(), expr_scratch: ScratchBuffer::with_capacity(16), @@ -254,13 +261,20 @@ impl<'src> Parser<'src> { "Parser should be at the end of the file." ); // TODO consider re-integrating lexical error handling into the parser? - let parse_errors = self.errors; + let mut parse_errors = self.errors; let (tokens, lex_errors) = self.tokens.finish(); // Fast path for when there are no lex errors. // There's no fast path for when there are no parse errors because a lex error // always results in a parse error. if lex_errors.is_empty() { + prioritize_tokenizer_error( + &mut parse_errors, + self.source, + self.options.mode, + self.start_offset, + self.first_unclosed_bracket_recovery, + ); return Parsed { syntax, tokens: Tokens::new(tokens), @@ -292,6 +306,13 @@ impl<'src> Parser<'src> { merged.extend(parse_errors); merged.extend(lex_errors.map(ParseError::from)); + prioritize_tokenizer_error( + &mut merged, + self.source, + self.options.mode, + self.start_offset, + self.first_unclosed_bracket_recovery, + ); Parsed { syntax, @@ -656,6 +677,15 @@ impl<'src> Parser<'src> { false } + /// Re-lexes the current token in the context of a logical line to recover from an unclosed + /// bracket. + fn re_lex_logical_token(&mut self) { + if self.errors.is_empty() && self.first_unclosed_bracket_recovery.is_none() { + self.first_unclosed_bracket_recovery = Some(self.current_token_range().start()); + } + self.tokens.re_lex_logical_token(); + } + fn add_error(&mut self, error: ParseErrorType, ranged: T) where T: Ranged, @@ -771,7 +801,7 @@ impl<'src> Parser<'src> { // of an enclosing list, then we try to re-lex in the context of a logical line and // break out of list parsing. if self.is_enclosing_list_element_or_terminator() { - self.tokens.re_lex_logical_token(); + self.re_lex_logical_token(); break; } @@ -892,7 +922,7 @@ impl<'src> Parser<'src> { // enclosing list, then we try to re-lex in the context of a logical line and break out // of list parsing. if self.is_enclosing_list_element_or_terminator() { - self.tokens.re_lex_logical_token(); + self.re_lex_logical_token(); break; } @@ -1755,3 +1785,111 @@ impl RecoveryContext { }) } } + +/// Moves the error that stops parsing first to the front of `errors`. +/// +/// The source is tokenized again without the parser's error recovery, and its first tokenizer +/// error is compared with the first error found by the parser, other than a tokenizer error. A +/// tokenizer error detected before that error stops parsing there. One detected after it is still +/// reported, because the rest of the source is tokenized once parsing failed, except: +/// - an error detected inside an f-string or t-string keeps the parser's error; +/// - an unexpected indent is reported without tokenizing the rest of the source; +/// - a bracket that is never closed wins over an error on a later line. On the same line, it wins +/// over an error at or after it when parsing reads ahead from the error to the end of the +/// source, which it does unless a `:`, a `;` or an unknown token follows. An error found by +/// recovering from an unclosed bracket is placed at the token that started the recovery, +/// `unclosed_bracket_recovery`. +fn prioritize_tokenizer_error( + errors: &mut Vec, + source: &str, + mode: Mode, + start_offset: TextSize, + unclosed_bracket_recovery: Option, +) { + let is_tokenizer_error = |error: &ParseError| matches!(&error.error, ParseErrorType::Lexical(lexical) if lexical.is_tokenizer_error()); + let first = errors + .iter() + .find(|error| !is_tokenizer_error(error)) + .cloned(); + + let mut lexer = Lexer::new(source, mode, start_offset); + // The starts of the tokens at which parsing stops without reading ahead. + let mut stops = Vec::new(); + let (tokenizer_error, in_interpolated_string, detected) = loop { + let in_interpolated_string = lexer.in_interpolated_string(); + let previous_errors = lexer.errors().len(); + let kind = lexer.next_token(); + if let Some(error) = lexer.errors()[previous_errors..] + .iter() + .find(|error| error.error().is_tokenizer_error()) + { + break (error.clone(), in_interpolated_string, lexer.offset()); + } + if matches!( + kind, + TokenKind::Colon | TokenKind::Semi | TokenKind::Unknown + ) { + stops.push(lexer.current_range().start()); + } + if kind == TokenKind::EndOfFile { + return; + } + }; + + let Some(first) = first else { + move_to_front(errors, ParseError::from(tokenizer_error)); + return; + }; + let first_start = first.location.start(); + let error_start = match tokenizer_error.error() { + LexicalErrorType::UnclosedBracket { .. } => { + unclosed_bracket_recovery.map_or(first_start, |start| start.max(first_start)) + } + _ => first_start, + }; + let wins = detected <= first_start + || (!in_interpolated_string + && match tokenizer_error.error() { + LexicalErrorType::UnclosedBracket { .. } => { + let line = |offset: TextSize| { + let text = &source[..offset.to_usize()]; + text.matches('\n').count() + text.matches('\r').count() + - text.matches("\r\n").count() + }; + let bracket_start = tokenizer_error.location().start(); + bracket_start <= error_start + && (line(bracket_start) < line(error_start) + || stops.iter().all(|stop| *stop < first_start)) + } + _ => !matches!(first.error, ParseErrorType::UnexpectedIndentation), + }); + if !wins { + move_to_front(errors, first); + return; + } + // A bracket reported in place of an error before the end of the source can't be closed by + // more input. + let front = match *tokenizer_error.error() { + LexicalErrorType::UnclosedBracket { + opening, + incomplete: true, + } if error_start.to_usize() < source.trim_end().len() => { + errors.retain(|error| *error != ParseError::from(tokenizer_error.clone())); + LexicalError::new( + LexicalErrorType::UnclosedBracket { + opening, + incomplete: false, + }, + tokenizer_error.location(), + ) + } + _ => tokenizer_error, + }; + move_to_front(errors, ParseError::from(front)); +} + +/// Moves `error` to the front of `errors`, removing an equal error elsewhere. +fn move_to_front(errors: &mut Vec, error: ParseError) { + errors.retain(|other| *other != error); + errors.insert(0, error); +} diff --git a/crates/ruff_python_parser/src/parser/tests.rs b/crates/ruff_python_parser/src/parser/tests.rs index 21c0fe1f217019..d715caf2cd1a68 100644 --- a/crates/ruff_python_parser/src/parser/tests.rs +++ b/crates/ruff_python_parser/src/parser/tests.rs @@ -1,9 +1,10 @@ use std::assert_matches; -use ruff_python_ast::{Expr, InterpolatedStringElement, IpyEscapeKind, Number, Stmt}; +use ruff_python_ast::{Expr, InterpolatedStringElement, IpyEscapeKind, ModModule, Number, Stmt}; use crate::{ - LexicalErrorType, Mode, ParseErrorType, ParseOptions, parse, parse_expression, parse_module, + LexicalErrorType, Mode, ParseErrorType, ParseOptions, Parsed, parse, parse_expression, + parse_module, parse_unchecked, }; // Keep recursive ASTs shallow enough for Windows's 1 MiB test-thread stacks. @@ -345,12 +346,27 @@ fn test_tstring_fstring_middle_fuzzer() { insta::assert_debug_snapshot!(error); } +/// Parses the module `source`, which nests brackets deeper than allowed, and asserts that this is +/// its only error. +fn parse_too_deeply_nested(source: &str) -> Parsed { + let parsed = parse_unchecked(source, ParseOptions::from(Mode::Module)) + .try_into_module() + .unwrap(); + assert!(!parsed.errors().is_empty()); + for error in parsed.errors() { + assert_eq!( + error.error, + ParseErrorType::Lexical(LexicalErrorType::TooDeeplyNestedBrackets) + ); + } + parsed +} + #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] #[test] fn nested_parens_grow_stack() { let src = format!("{}1{}", "(".repeat(1_000), ")".repeat(1_000)); - let parsed = stacker::grow(32 * 1024, || parse_module(&src)); - assert!(parsed.is_ok()); + stacker::grow(32 * 1024, || parse_too_deeply_nested(&src)); } #[test] @@ -367,7 +383,7 @@ fn deep_nesting_preserves_surrounding_statements() { "(".repeat(1_000), ")".repeat(1_000), ); - let parsed = parse_module(&src).unwrap(); + let parsed = parse_too_deeply_nested(&src); assert_matches!(parsed.suite().first(), Some(Stmt::Assign(_))); assert_matches!(parsed.suite().last(), Some(Stmt::Assign(_))); @@ -397,21 +413,21 @@ fn nested_def_blocks_grow_stack() { #[test] fn nested_lists_grow_stack() { let src = format!("{}1{}", "[".repeat(1_000), "]".repeat(1_000)); - parse_module(&src).unwrap(); + parse_too_deeply_nested(&src); } #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] #[test] fn nested_calls_grow_stack() { let src = format!("x = {}1{}", "f(".repeat(1_000), ")".repeat(1_000)); - parse_module(&src).unwrap(); + parse_too_deeply_nested(&src); } #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] #[test] fn nested_subscripts_grow_stack() { let src = format!("x = {}1{}", "a[".repeat(1_000), "]".repeat(1_000)); - parse_module(&src).unwrap(); + parse_too_deeply_nested(&src); } #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] @@ -428,7 +444,7 @@ fn nested_match_patterns_grow_stack() { src.push(')'); } src.push_str(": pass\n"); - parse_module(&src).unwrap(); + parse_too_deeply_nested(&src); } #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] @@ -459,7 +475,7 @@ fn binary_paren_interplay_grows_stack() { for _ in 0..depth { src.push(')'); } - parse_module(&src).unwrap(); + parse_too_deeply_nested(&src); } #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] @@ -528,3 +544,36 @@ fn nested_unary_chains_grow_stack() { let source = format!("{}True\n", "not ".repeat(depth)); parse_module(&source).unwrap(); } + +fn first_error(source: &str) -> ParseErrorType { + parse_unchecked(source, ParseOptions::from(Mode::Module)).errors()[0] + .error + .clone() +} + +#[test] +fn unclosed_bracket_at_end_is_incomplete() { + assert_eq!( + first_error("x = [\n1,\n"), + ParseErrorType::Lexical(LexicalErrorType::UnclosedBracket { + opening: '[', + incomplete: true, + }) + ); +} + +#[test] +fn unclosed_bracket_in_place_of_earlier_error_is_complete() { + assert_eq!( + first_error("x = [\nx for x\nin raise(3)\nof x\n"), + ParseErrorType::Lexical(LexicalErrorType::UnclosedBracket { + opening: '[', + incomplete: false, + }) + ); +} + +#[test] +fn unclosed_bracket_after_same_line_error() { + assert_eq!(first_error("def f(:\n").to_string(), "invalid syntax"); +} diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__fstring_newline_format_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__fstring_newline_format_spec.snap index 77ac031429992c..cce66157c42805 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__fstring_newline_format_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__fstring_newline_format_spec.snap @@ -45,6 +45,12 @@ expression: "lex_invalid(source, Mode::Module)" ), location: 13..14, }, + LexicalError { + error: UnmatchedBracket { + closing: '}', + }, + location: 15..15, + }, LexicalError { error: UnclosedStringError { triple_quoted: false, @@ -59,6 +65,12 @@ expression: "lex_invalid(source, Mode::Module)" ), location: 32..33, }, + LexicalError { + error: UnmatchedBracket { + closing: '}', + }, + location: 44..44, + }, LexicalError { error: UnclosedStringError { triple_quoted: false, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tstring_newline_format_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tstring_newline_format_spec.snap index 5c8e926ae42ad1..1e293ceef45911 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tstring_newline_format_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__tstring_newline_format_spec.snap @@ -45,6 +45,12 @@ expression: "lex_invalid(source, Mode::Module)" ), location: 13..14, }, + LexicalError { + error: UnmatchedBracket { + closing: '}', + }, + location: 15..15, + }, LexicalError { error: UnclosedStringError { triple_quoted: false, @@ -59,6 +65,12 @@ expression: "lex_invalid(source, Mode::Module)" ), location: 32..33, }, + LexicalError { + error: UnmatchedBracket { + closing: '}', + }, + location: 44..44, + }, LexicalError { error: UnclosedStringError { triple_quoted: false, diff --git a/crates/ruff_python_parser/src/string.rs b/crates/ruff_python_parser/src/string.rs index e97475d0e1f304..f8a82a6ad6496f 100644 --- a/crates/ruff_python_parser/src/string.rs +++ b/crates/ruff_python_parser/src/string.rs @@ -585,7 +585,11 @@ mod tests { #[test] fn parse_fstring_nested_spec_grows_stack() { - assert!(parse_suite(&nested_format_spec('f', 200)).is_ok()); + let error = parse_suite(&nested_format_spec('f', 200)).unwrap_err(); + assert_eq!( + error.error, + ParseErrorType::Lexical(LexicalErrorType::TooDeeplyNestedBrackets) + ); } #[test] @@ -702,7 +706,11 @@ mod tests { #[test] fn parse_tstring_nested_spec_grows_stack() { - assert!(parse_suite(&nested_format_spec('t', 200)).is_ok()); + let error = parse_suite(&nested_format_spec('t', 200)).unwrap_err(); + assert_eq!( + error.error, + ParseErrorType::Lexical(LexicalErrorType::TooDeeplyNestedBrackets) + ); } #[test] diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap index 104e87b7484b7b..aa8a8e93fdca12 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unclosed_type_param_list.py.snap @@ -132,5 +132,13 @@ Module( 1 | class Foo[T1, *T2(a, b): | ^ Syntax Error: invalid syntax 2 | pass +3 | x = 10 + | + + + | +1 | class Foo[T1, *T2(a, b): + | ^ Syntax Error: closing parenthesis ')' does not match opening parenthesis '[' +2 | pass 3 | x = 10 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap index 7ce171d0bf2ec2..b02c116954f2df 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@del_incomplete_target.py.snap @@ -137,6 +137,9 @@ Module( | +1 | del x, y. +2 | z 3 | del x, y[ + | ^ Syntax Error: '[' was never closed 4 | z - | ^ Syntax Error: unexpected EOF while parsing + | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap index e16c7dbe432f78..4ecf988bdb03b5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_0.py.snap @@ -82,6 +82,14 @@ Module( ``` ## Errors + | +1 | call( + | ^ Syntax Error: '(' was never closed +2 | +3 | def foo(): + | + + | 1 | call( | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap index a3b2aebe77f48d..706ede0ddf4282 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_1.py.snap @@ -91,6 +91,14 @@ Module( ``` ## Errors + | +1 | call(x + | ^ Syntax Error: '(' was never closed +2 | +3 | def foo(): + | + + | 1 | call(x | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap index 9f0a0a5fc37b1e..ca6ea5182a1eeb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__unclosed_2.py.snap @@ -91,6 +91,14 @@ Module( ``` ## Errors + | +1 | call(x, + | ^ Syntax Error: '(' was never closed +2 | +3 | def foo(): + | + + | 1 | call(x, | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap index ac36a64deb9efa..7df86a65a7ea78 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_0.py.snap @@ -86,6 +86,14 @@ Module( ``` ## Errors + | +1 | {x: + | ^ Syntax Error: '{' was never closed +2 | +3 | def foo(): + | + + | 1 | {x: 2 | @@ -113,4 +121,4 @@ Module( | 3 | def foo(): 4 | pass - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap index 8f3e3fa390f4ef..e49d00f228701b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_1.py.snap @@ -71,6 +71,14 @@ Module( | 1 | {x: + | ^ Syntax Error: '{' was never closed 2 | 3 | 1 + 2 - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +1 | {x: +2 | +3 | 1 + 2 + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap index 1ba383b08598df..bb8d6ee12cbcd1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__missing_closing_brace_2.py.snap @@ -90,6 +90,14 @@ Module( ``` ## Errors + | +1 | {x: 1, + | ^ Syntax Error: '{' was never closed +2 | +3 | def foo(): + | + + | 1 | {x: 1, | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap index df8919487a4eb0..0f7eb2619a07fa 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_identifiers.py.snap @@ -94,7 +94,7 @@ Module( | 1 | a = (🐶 - | ^^ Syntax Error: invalid syntax + | ^^ Syntax Error: invalid character '🐶' (U+1F436) 2 | # comment 🐶 3 | ) | @@ -125,7 +125,7 @@ Module( 3 | ) 4 | 5 | a = (🐶 + - | ^^ Syntax Error: invalid syntax + | ^^ Syntax Error: invalid character '🐶' (U+1F436) 6 | # comment 7 | 🐶) | @@ -135,7 +135,7 @@ Module( 5 | a = (🐶 + 6 | # comment 7 | 🐶) - | ^^ Syntax Error: invalid syntax + | ^^ Syntax Error: invalid character '🐶' (U+1F436) | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap index 1ce96dca91ee41..c9e38ce30cde2f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__emoji_statement.py.snap @@ -18,4 +18,4 @@ Module( | 1 | 👍 - | ^^ Syntax Error: invalid syntax + | ^^ Syntax Error: invalid character '👍' (U+1F44D) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap index 12796c3cb35012..ed05f054752da5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap @@ -1243,7 +1243,7 @@ Module( 11 | [x for x in lambda y: y] 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ']' 14 | [*x, *y for x in y] | @@ -1273,7 +1273,7 @@ Module( 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] 14 | [*x, *y for x in y] - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ']' 15 | 16 | # Invalid if | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap index f5a0011be6862f..87a18bf0a1e736 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_0.py.snap @@ -45,4 +45,11 @@ Module( 1 | # Missing closing bracket 0: No elements 2 | 3 | [ - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: '[' was never closed + + + | +1 | # Missing closing bracket 0: No elements +2 | +3 | [ + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap index 8ed3312ef99cb5..05451011b5e8cb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_1.py.snap @@ -57,7 +57,17 @@ Module( ## Errors | +2 | # is considered to be part of the list. +3 | 4 | [ + | ^ Syntax Error: '[' was never closed 5 | 6 | x + y - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +4 | [ +5 | +6 | x + y + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap index 5011545c94ebc3..dac2359f892fff 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_2.py.snap @@ -66,7 +66,17 @@ Module( ## Errors | +2 | # will be considered to be part of the list. +3 | 4 | [1, + | ^ Syntax Error: '[' was never closed 5 | 6 | x + y - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +4 | [1, +5 | +6 | x + y + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap index be24e50b936ec5..938a9c97622ef7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__missing_closing_bracket_3.py.snap @@ -88,6 +88,16 @@ Module( ``` ## Errors + | +2 | # token starts a statement. +3 | +4 | [1, 2 + | ^ Syntax Error: '[' was never closed +5 | +6 | def foo(): + | + + | 2 | # token starts a statement. 3 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap index 40da172faddd9b..ee7df341f6e1f0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_1.py.snap @@ -49,4 +49,11 @@ Module( 1 | # EOF after the `:=` token 2 | 3 | (x := - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: '(' was never closed + + + | +1 | # EOF after the `:=` token +2 | +3 | (x := + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap index 414930d14ed63c..263df437b25894 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_2.py.snap @@ -84,6 +84,16 @@ Module( ``` ## Errors + | +1 | # Missing expression, instead there's a function definition +2 | +3 | (x := + | ^ Syntax Error: '(' was never closed +4 | +5 | def foo(): + | + + | 3 | (x := 4 | @@ -111,4 +121,4 @@ Module( | 5 | def foo(): 6 | pass - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap index 04396d360723c8..18b4868b5fd758 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__missing_expression_3.py.snap @@ -61,7 +61,17 @@ Module( ## Errors | +2 | # assignment value. +3 | 4 | (x := + | ^ Syntax Error: '(' was never closed 5 | 6 | x + y - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +4 | (x := +5 | +6 | x + y + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap index 07309f06260902..ba4e41ab536845 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__generator.py.snap @@ -93,7 +93,7 @@ Module( | 1 | (x := 1, for x in y) - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ')' | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap index e27cf853188ae7..d1a844f6d1b596 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_0.py.snap @@ -35,4 +35,11 @@ Module( 1 | # Missing closing parentheses 0: No elements 2 | 3 | ( - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: '(' was never closed + + + | +1 | # Missing closing parentheses 0: No elements +2 | +3 | ( + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap index 89c867e25f2acc..94317cc0c49af0 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_1.py.snap @@ -47,7 +47,17 @@ Module( ## Errors | +2 | # is considered to be part of the list. +3 | 4 | ( + | ^ Syntax Error: '(' was never closed 5 | 6 | x + y - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +4 | ( +5 | +6 | x + y + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap index 53daeeecb05fd9..9b6377be64b836 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_2.py.snap @@ -67,7 +67,17 @@ Module( ## Errors | +2 | # will be considered to be part of the tuple. +3 | 4 | (1, + | ^ Syntax Error: '(' was never closed 5 | 6 | x + y - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +4 | (1, +5 | +6 | x + y + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap index 136a9f14232c7d..0b9c8446abf9d2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__missing_closing_paren_3.py.snap @@ -89,6 +89,16 @@ Module( ``` ## Errors + | +2 | # token starts a statement. +3 | +4 | (1, 2 + | ^ Syntax Error: '(' was never closed +5 | +6 | def foo(): + | + + | 2 | # token starts a statement. 3 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap index c3f04d00c5eb60..642255af95b5be 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_0.py.snap @@ -44,4 +44,11 @@ Module( 1 | # Missing closing curly brace 0: No elements 2 | 3 | { - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: '{' was never closed + + + | +1 | # Missing closing curly brace 0: No elements +2 | +3 | { + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap index bff106292258dd..ef79c9be87a102 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_1.py.snap @@ -56,7 +56,17 @@ Module( ## Errors | +2 | # is considered to be part of the set. +3 | 4 | { + | ^ Syntax Error: '{' was never closed 5 | 6 | x + y - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +4 | { +5 | +6 | x + y + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap index fcf5a11bdeed9e..678ddfafec397d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_2.py.snap @@ -65,7 +65,17 @@ Module( ## Errors | +2 | # will be considered to be part of the set. +3 | 4 | {1, + | ^ Syntax Error: '{' was never closed 5 | 6 | x + y - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +4 | {1, +5 | +6 | x + y + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap index 5880118381ebcf..63e720575f5348 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__missing_closing_curly_brace_3.py.snap @@ -87,6 +87,16 @@ Module( ``` ## Errors + | +2 | # token starts a statement. +3 | +4 | {1, 2 + | ^ Syntax Error: '{' was never closed +5 | +6 | def foo(): + | + + | 2 | # token starts a statement. 3 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap index 0364937d6a21dd..27cf9c86680f55 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_0.py.snap @@ -73,6 +73,14 @@ Module( | 1 | x[: + | ^ Syntax Error: '[' was never closed 2 | 3 | x + y - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +1 | x[: +2 | +3 | x + y + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap index 4f0e744f30e0ed..32cf45551af895 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap @@ -95,6 +95,14 @@ Module( ``` ## Errors + | +1 | x[:: + | ^ Syntax Error: '[' was never closed +2 | +3 | def foo(): + | + + | 1 | x[:: 2 | @@ -122,4 +130,4 @@ Module( | 3 | def foo(): 4 | pass - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap index a94f6db90f72ad..6be9cddae6d5d2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap @@ -276,6 +276,15 @@ Module( | + | +2 | def foo(): +3 | return 42 +4 | def foo(a: int, b: str + | ^ Syntax Error: '(' was never closed +5 | x = 10 + | + + | 3 | return 42 4 | def foo(a: int, b: str @@ -286,4 +295,4 @@ Module( | 4 | def foo(a: int, b: str 5 | x = 10 - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap index 7e5c676a0e7609..79b88440725203 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_type_param_list.py.snap @@ -179,5 +179,13 @@ Module( 1 | def foo[T1, *T2(a, b): | ^ Syntax Error: invalid syntax 2 | return a + b +3 | x = 10 + | + + + | +1 | def foo[T1, *T2(a, b): + | ^ Syntax Error: closing parenthesis ')' does not match opening parenthesis '[' +2 | return a + b 3 | x = 10 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap index 0f3c9508589952..b13ffd34aa1d6c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_parenthesized_names.py.snap @@ -87,7 +87,20 @@ Module( | + | +1 | import (a) + | ^ Syntax Error: unmatched ')' +2 | import (a, b) + | + + | 1 | import (a) 2 | import (a, b) | ^ Syntax Error: Expected one or more names after 'import' + + + | +1 | import (a) +2 | import (a, b) + | ^ Syntax Error: unmatched ')' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap index 386b42c81c9e9b..44ddec6c778746 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_2.py.snap @@ -62,6 +62,14 @@ Module( ``` ## Errors + | +1 | # parse_options: {"mode": "ipython"} +2 | with (a, ?b + | ^ Syntax Error: '(' was never closed +3 | ? + | + + | 1 | # parse_options: {"mode": "ipython"} 2 | with (a, ?b @@ -80,4 +88,4 @@ Module( | 2 | with (a, ?b 3 | ? - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap index 5db35c1ac1588a..911d6a2c5fc6aa 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap @@ -186,7 +186,12 @@ Module( | 1 | def foo(a, **kwargs={'b': 1, 'c': 2}): ... - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: closing parenthesis '}' does not match opening parenthesis '(' + + + | +1 | def foo(a, **kwargs={'b': 1, 'c': 2}): ... + | ^ Syntax Error: unmatched ')' | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap index 7aafdcd9639327..40bc0067cd3a66 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap @@ -138,7 +138,7 @@ Module( | 1 | def foo(a, *args=(1, 2)): ... - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ')' | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap index 714ee338c5dc24..429ff977726196 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap @@ -861,6 +861,15 @@ Module( ``` ## Errors + | +34 | # The outer parenthesis is closed but the inner bracket isn't +35 | if call(foo, [a, b) + | ^ Syntax Error: closing parenthesis ')' does not match opening parenthesis '[' +36 | def bar(): +37 | pass + | + + | 1 | # No indentation before the function definition 2 | if call(foo @@ -926,15 +935,6 @@ Module( | - | -34 | # The outer parenthesis is closed but the inner bracket isn't -35 | if call(foo, [a, b) - | ^ Syntax Error: invalid syntax -36 | def bar(): -37 | pass - | - - | 34 | # The outer parenthesis is closed but the inner bracket isn't 35 | if call(foo, [a, b) @@ -948,7 +948,7 @@ Module( 42 | if call(foo, [a, 43 | b 44 | ) - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: closing parenthesis ')' does not match opening parenthesis '[' on line 42 45 | def bar(): 46 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap index 2db1802b133718..87fb2347f76b3f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token_mac_eol.py.snap @@ -121,6 +121,11 @@ Module( ``` ## Errors + | +1 | if call(foo, [a, b␍ def bar():␍ pass + | ^ Syntax Error: '[' was never closed + + | 1 | if call(foo, [a, b␍ def bar():␍ pass | ^^^ Syntax Error: invalid syntax 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 2ec258b09d25c0..367bff8fc6a89f 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 @@ -121,6 +121,14 @@ Module( ``` ## Errors + | +1 | if call(foo, [a, b + | ^ Syntax Error: '[' was never closed +2 | def bar(): +3 | pass + | + + | 1 | if call(foo, [a, b 2 | def bar(): 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 92f497b1901f16..57bea42adbb5ed 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 @@ -409,7 +409,7 @@ Module( | 5 | f'middle {'string':\ 6 | 'format spec'} - | ^ Syntax Error: f-string: expecting '}' + | ^ Syntax Error: unterminated string literal (detected at line 6) 7 | 8 | f'middle {'string':\\ | @@ -418,7 +418,7 @@ Module( | 5 | f'middle {'string':\ 6 | 'format spec'} - | ^^^^^^ Syntax Error: invalid syntax + | ^ Syntax Error: f-string: expecting '}' 7 | 8 | f'middle {'string':\\ | @@ -427,7 +427,7 @@ Module( | 5 | f'middle {'string':\ 6 | 'format spec'} - | ^^^^ Syntax Error: invalid syntax + | ^^^^^^ Syntax Error: invalid syntax 7 | 8 | f'middle {'string':\\ | @@ -436,7 +436,7 @@ Module( | 5 | f'middle {'string':\ 6 | 'format spec'} - | ^ Syntax Error: unterminated string literal (detected at line 6) + | ^^^^ Syntax Error: invalid syntax 7 | 8 | f'middle {'string':\\ | @@ -474,7 +474,7 @@ Module( | 8 | f'middle {'string':\\ 9 | 'format spec'} - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched '}' 10 | 11 | f'middle {'string':\\\ | 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 c3006ebefd645f..7bfeaad2009901 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 @@ -99,6 +99,14 @@ Module( ``` ## Errors + | +1 | call(a, b, # comment \ + | ^ Syntax Error: '(' was never closed +2 | +3 | def bar(): + | + + | 1 | call(a, b, # comment \ | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap index e3dfa752353269..aaadf59c35f59d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap @@ -75,18 +75,18 @@ Module( ## Errors | -3 | # https://github.com/astral-sh/ruff/issues/11929 -4 | 5 | f"""hello {x # comment - | ^ Syntax Error: unterminated triple-quoted f-string literal (detected at line 6) 6 | y = 1 - | + | ^ Syntax Error: f-string: expecting '}' | +3 | # https://github.com/astral-sh/ruff/issues/11929 +4 | 5 | f"""hello {x # comment + | ^ Syntax Error: unterminated triple-quoted f-string literal (detected at line 6) 6 | y = 1 - | ^ Syntax Error: f-string: expecting '}' + | | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap index 4086dd7b0c940c..984a676f989937 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap @@ -17,7 +17,7 @@ Module( test: Call( ExprCall { node_index: NodeIndex(None), - range: 234..253, + range: 234..258, func: Name( ExprName { node_index: NodeIndex(None), @@ -27,7 +27,7 @@ Module( }, ), arguments: Arguments { - range: 238..253, + range: 238..258, node_index: NodeIndex(None), args: [ FString( @@ -114,6 +114,16 @@ Module( ``` ## Errors + | +3 | # within an f-string but the lexer shouldn't go back. +4 | +5 | if call(f'''{x:.3f + | ^ Syntax Error: '(' was never closed +6 | ''' +7 | pass + | + + | 5 | if call(f'''{x:.3f 6 | ''' @@ -128,3 +138,24 @@ Module( | ^ Syntax Error: invalid syntax 7 | pass | + + + | +5 | if call(f'''{x:.3f +6 | ''' +7 | pass + | ^^^^ Syntax Error: invalid syntax + + + | +5 | if call(f'''{x:.3f +6 | ''' +7 | pass + | ^^^^ Syntax Error: invalid syntax + + + | +5 | if call(f'''{x:.3f +6 | ''' +7 | pass + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap index 96631687913d24..b5bb933fbb7339 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap @@ -178,6 +178,15 @@ Module( | + | +1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 +2 | (c: int = 1,f"""{d=[ + | ^ Syntax Error: '(' was never closed +3 | def a( +4 | class A: + | + + | 1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 2 | (c: int = 1,f"""{d=[ @@ -229,4 +238,4 @@ Module( | 4 | class A: 5 | pass - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap index 39f380c008f38b..f9a8f3549fae39 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__function_type_parameters.py.snap @@ -472,7 +472,7 @@ Module( 17 | def multiple_trailing_commas[A,,](): ... 18 | 19 | def multiple_commas_and_recovery[A,,100](): ... - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ']' | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap index 80de24ea6d2624..192bce954abf2f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__if_extra_closing_parentheses.py.snap @@ -42,7 +42,7 @@ Module( | 1 | # FIXME(micha): This creates two syntax errors instead of just one (and overlapping ones) 2 | if True)): - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ')' 3 | pass | @@ -50,7 +50,7 @@ Module( | 1 | # FIXME(micha): This creates two syntax errors instead of just one (and overlapping ones) 2 | if True)): - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ')' 3 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap index 9add671bfaadb3..63d7ae32deb61e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__as_pattern_3.py.snap @@ -137,7 +137,16 @@ Module( 2 | # Not in the mapping start token set, so the list parsing bails 3 | # v 4 | case {(x as y): 1}: - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: closing parenthesis ')' does not match opening parenthesis '{' +5 | pass + | + + + | +2 | # Not in the mapping start token set, so the list parsing bails +3 | # v +4 | case {(x as y): 1}: + | ^ Syntax Error: unmatched '}' 5 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap index 61e83db69ffa29..aadfb0dd66cc02 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap @@ -1769,7 +1769,7 @@ Module( 10 | with (item1, item2 := 10 as f): ... 11 | with (x for x in range(10), item): ... 12 | with (item, x for x in range(10)): ... - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ')' 13 | 14 | # Make sure the parser doesn't report the same error twice | @@ -1826,7 +1826,7 @@ Module( | 17 | with (*x for x in iter, item): ... 18 | with (item1, *x for x in iter, item2): ... - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ')' 19 | with (x as f, *y): ... 20 | with (*x, y as f): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap index 5953861fe55db7..6581dba54b5f78 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar.py.snap @@ -83,6 +83,14 @@ Module( | 1 | with (: + | ^ Syntax Error: '(' was never closed 2 | 3 | x + y - | ^ Syntax Error: unexpected EOF while parsing + | + + + | +1 | with (: +2 | +3 | x + y + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap index d660854359bbc6..74dbcd67a4fbe3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__unclosed_ambiguous_lpar_eof.py.snap @@ -45,4 +45,9 @@ Module( | 1 | with ( - | ^ Syntax Error: unexpected EOF while parsing + | ^ Syntax Error: '(' was never closed + + + | +1 | with ( + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap index 3e32e5024e0d75..3c07555e39200a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap @@ -95,7 +95,7 @@ Module( | 1 | type X[**T: int] = int - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ']' | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap index 22bcd6034e84f2..f6dc1d4a12764a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap @@ -95,7 +95,7 @@ Module( | 1 | type X[*T: int] = int - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: unmatched ']' | From 1de4fc5c09f47ffdb2cbb4333523a4cb9e1c6a58 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 5 Oct 2026 02:24:58 +0900 Subject: [PATCH 10/20] Report number literal, string prefix and non-printable errors Lex number literals with the tokenizer's checks: an underscore or exponent sign without a following digit, a radix prefix without digits, a digit outside an octal or binary literal, leading zeros in a decimal integer, and a number directly followed by a name other than a keyword that can follow it. Report these as `InvalidNumberLiteral`, `InvalidDigit` and `LeadingZerosInDecimalInteger`. Report a string prefix that combines incompatible prefixes, such as `ub''`, as `IncompatibleStringPrefixes` over the prefix. Report an unrecognized character that is not printable by its general category as a non-printable character. Assisted-by: Claude Code:claude-opus-5-5 --- Cargo.lock | 1 + crates/ruff_python_parser/Cargo.toml | 1 + crates/ruff_python_parser/src/error.rs | 72 ++++- crates/ruff_python_parser/src/lexer.rs | 297 ++++++++++++------ crates/ruff_python_parser/src/lib.rs | 2 +- crates/ruff_python_parser/src/parser/tests.rs | 44 +++ ...exer__tests__invalid_leading_zero_big.snap | 6 +- ...er__tests__invalid_leading_zero_small.snap | 6 +- 8 files changed, 323 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 297326a8406464..d8a0a86529cfa9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3840,6 +3840,7 @@ dependencies = [ "drop_bomb", "get-size2", "hashbrown 0.17.1", + "icu_properties", "insta", "itertools 0.15.0", "memchr", diff --git a/crates/ruff_python_parser/Cargo.toml b/crates/ruff_python_parser/Cargo.toml index c90093900fe71d..110d29fd407695 100644 --- a/crates/ruff_python_parser/Cargo.toml +++ b/crates/ruff_python_parser/Cargo.toml @@ -23,6 +23,7 @@ bstr = { workspace = true } drop_bomb = { workspace = true } get-size2 = { workspace = true } hashbrown = { workspace = true } +icu_properties = { workspace = true } memchr = { workspace = true } rustc-hash = { workspace = true } static_assertions = { workspace = true } diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index 41ce7f8fa11ad0..33898e0a3d4841 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -467,12 +467,64 @@ pub enum LexicalErrorType { UnclosedBracket { opening: char, incomplete: bool }, /// Brackets are nested too deeply. TooDeeplyNestedBrackets, + /// A malformed number literal, or one directly followed by a name. + InvalidNumberLiteral { kind: NumberLiteralKind }, + /// A digit that is not valid in the octal or binary literal it appears in. + InvalidDigit { + digit: char, + kind: NumberLiteralKind, + }, + /// A decimal integer literal with leading zeros. + LeadingZerosInDecimalInteger, + /// A string prefix that combines incompatible prefixes, such as `ub`. + IncompatibleStringPrefixes { first: char, second: char }, /// An unexpected error occurred. OtherError(Box), } impl std::error::Error for LexicalErrorType {} +/// The kind of a number literal, as named in error messages. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, get_size2::GetSize)] +pub enum NumberLiteralKind { + Decimal, + Hexadecimal, + Octal, + Binary, + Imaginary, +} + +impl std::fmt::Display for NumberLiteralKind { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(match self { + Self::Decimal => "decimal", + Self::Hexadecimal => "hexadecimal", + Self::Octal => "octal", + Self::Binary => "binary", + Self::Imaginary => "imaginary", + }) + } +} + +/// Whether `c` is printable: not a control, format, surrogate, private use, unassigned or +/// separator character, other than the ASCII space. +fn is_printable(c: char) -> bool { + use icu_properties::props::{EnumeratedProperty, GeneralCategory}; + + c == ' ' + || !matches!( + GeneralCategory::for_char(c), + GeneralCategory::SpaceSeparator + | GeneralCategory::LineSeparator + | GeneralCategory::ParagraphSeparator + | GeneralCategory::Control + | GeneralCategory::Format + | GeneralCategory::Surrogate + | GeneralCategory::PrivateUse + | GeneralCategory::Unassigned + ) +} + impl LexicalErrorType { /// Returns `true` if the error stops tokenization, as opposed to an error found while /// decoding the content of a token. @@ -485,7 +537,7 @@ impl LexicalErrorType { | Self::InvalidByteLiteral | Self::OtherError(_) => false, // An ASCII punctuation character is a token that the parser rejects. - Self::UnrecognizedToken { tok } => !tok.is_ascii() || tok.is_ascii_control(), + Self::UnrecognizedToken { tok } => !tok.is_ascii() || !is_printable(*tok), Self::FStringError(error) | Self::TStringError(error) => matches!( error, InterpolatedStringErrorType::UnterminatedString { .. } @@ -502,7 +554,11 @@ impl LexicalErrorType { | Self::UnmatchedBracket { .. } | Self::MismatchedBracket { .. } | Self::UnclosedBracket { .. } - | Self::TooDeeplyNestedBrackets => true, + | Self::TooDeeplyNestedBrackets + | Self::InvalidNumberLiteral { .. } + | Self::InvalidDigit { .. } + | Self::LeadingZerosInDecimalInteger + | Self::IncompatibleStringPrefixes { .. } => true, } } @@ -536,7 +592,7 @@ impl std::fmt::Display for LexicalErrorType { } Self::TabError => write!(f, "inconsistent use of tabs and spaces in indentation"), Self::TooDeepIndentation => write!(f, "too many levels of indentation"), - Self::UnrecognizedToken { tok } if tok.is_ascii_control() => { + Self::UnrecognizedToken { tok } if !is_printable(*tok) => { write!( f, "invalid non-printable character U+{:04X}", @@ -547,6 +603,16 @@ impl std::fmt::Display for LexicalErrorType { write!(f, "invalid character '{tok}' (U+{:04X})", u32::from(*tok)) } Self::UnrecognizedToken { .. } => f.write_str("invalid syntax"), + Self::InvalidNumberLiteral { kind } => write!(f, "invalid {kind} literal"), + Self::InvalidDigit { digit, kind } => { + write!(f, "invalid digit '{digit}' in {kind} literal") + } + Self::LeadingZerosInDecimalInteger => f.write_str( + "leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers", + ), + Self::IncompatibleStringPrefixes { first, second } => { + write!(f, "'{first}' and '{second}' prefixes are incompatible") + } Self::LineContinuationError => { write!(f, "unexpected character after line continuation character") } diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 0c2802cb820d19..e5adbbd17fcb64 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -17,7 +17,9 @@ use ruff_python_trivia::is_python_whitespace; use ruff_text_size::{TextLen, TextRange, TextSize}; use crate::Mode; -use crate::error::{InterpolatedStringErrorType, LexicalError, LexicalErrorType}; +use crate::error::{ + InterpolatedStringErrorType, LexicalError, LexicalErrorType, NumberLiteralKind, +}; use crate::lexer::cursor::{Cursor, EOF_CHAR}; use crate::lexer::indentation::{ Indentation, IndentationError, Indentations, IndentationsCheckpoint, @@ -654,6 +656,14 @@ impl<'src> Lexer<'src> { /// Lex an identifier. Also used for keywords and string/bytes literals with a prefix. fn lex_identifier(&mut self, first: char) -> TokenKind { + if let Some(error) = self.incompatible_string_prefixes(first) { + self.cursor + .skip_bytes(error.location().len().to_usize() - first.len_utf8()); + self.errors.push(error); + self.current_range = self.token_range(); + return TokenKind::Unknown; + } + // Detect potential string like rb'' b'' f'' t'' u'' r'' let quote = if let Some(prefix) = single_char_prefix(first) { match self.cursor.first() { @@ -756,6 +766,44 @@ impl<'src> Lexer<'src> { } } + /// Returns the error for a string prefix starting with `first` that combines incompatible + /// prefixes, such as `ub''`. The error covers the prefix. + fn incompatible_string_prefixes(&self, first: char) -> Option { + const PREFIXES: [char; 5] = ['u', 'b', 'r', 'f', 't']; + const INCOMPATIBLE: [(char, char); 7] = [ + ('u', 'b'), + ('u', 'r'), + ('u', 'f'), + ('u', 't'), + ('b', 'f'), + ('b', 't'), + ('f', 't'), + ]; + + let mut seen = Vec::with_capacity(PREFIXES.len()); + let mut len = TextSize::new(0); + let mut chars = std::iter::once(first).chain(self.cursor.rest().chars()); + loop { + let c = chars.next()?; + if is_quote(c) { + break; + } + let prefix = c.to_ascii_lowercase(); + if !PREFIXES.contains(&prefix) || seen.contains(&prefix) { + return None; + } + seen.push(prefix); + len += c.text_len(); + } + let (first, second) = INCOMPATIBLE + .into_iter() + .find(|(first, second)| seen.contains(first) && seen.contains(second))?; + Some(LexicalError::new( + LexicalErrorType::IncompatibleStringPrefixes { first, second }, + TextRange::at(self.token_range().start(), len), + )) + } + /// Try lexing the double character string prefix, updating the token flags accordingly. /// Returns `true` if it matches. fn try_double_char_prefix(&mut self, value: [char; 2]) -> bool { @@ -1175,7 +1223,7 @@ impl<'src> Lexer<'src> { } } - /// Lex a hex/octal/decimal/binary number without a decimal point. + /// Lex a hex/octal/binary number after its `0x`, `0o` or `0b` prefix. fn lex_number_radix(&mut self, radix: Radix) -> TokenKind { #[cfg(debug_assertions)] { @@ -1183,106 +1231,176 @@ impl<'src> Lexer<'src> { debug_assert_matches!(self.cursor.previous().to_ascii_lowercase(), 'x' | 'o' | 'b'); } - let number = self.radix_run(radix); - if !number.has_digit { - let err = u64::from_str_radix("", radix.as_u32()).unwrap_err(); - return self.push_error(LexicalError::new( - LexicalErrorType::OtherError({ - let msg = format!("{err:?}"); - let mut chars = msg.chars(); - match chars.next() { - Some(first) => format!("{}{}", first.to_ascii_lowercase(), chars.as_str()) - .into_boxed_str(), - None => msg.into_boxed_str(), - } - }), - self.token_range(), - )); + loop { + self.cursor.eat_char('_'); + if !radix.is_digit(self.cursor.first()) { + return self.push_invalid_radix_digit(radix); + } + self.cursor.eat_while(|c| radix.is_digit(c)); + if self.cursor.first() != '_' { + break; + } } + if self.cursor.first().is_ascii_digit() && radix != Radix::Hex { + return self.push_invalid_radix_digit(radix); + } + self.verify_end_of_number(radix.kind()); TokenKind::Int } - /// Lex a normal number, that is, no octal, hex or binary number. + /// Pushes the error for a character after the prefix or an `_` of a hex/octal/binary number + /// that is not one of its digits. + fn push_invalid_radix_digit(&mut self, radix: Radix) -> TokenKind { + let kind = radix.kind(); + let digit = self.cursor.first(); + let error = if digit.is_ascii_digit() && radix != Radix::Hex { + self.cursor.bump(); + LexicalErrorType::InvalidDigit { digit, kind } + } else { + LexicalErrorType::InvalidNumberLiteral { kind } + }; + self.push_number_error(error) + } + + /// Lex a decimal number, starting with a digit or with a `.` followed by a digit. fn lex_decimal_number(&mut self, first_digit_or_dot: char) -> TokenKind { #[cfg(debug_assertions)] debug_assert!(self.cursor.previous().is_ascii_digit() || self.cursor.previous() == '.'); - let start_is_zero = first_digit_or_dot == '0'; - - let mut integer_part = RadixRun { - has_digit: first_digit_or_dot != '.', - has_nonzero_digit: first_digit_or_dot != '.' && first_digit_or_dot != '0', - }; - if first_digit_or_dot != '.' { - integer_part.has_nonzero_digit |= self.radix_run(Radix::Decimal).has_nonzero_digit; - } - let is_float = if first_digit_or_dot == '.' || self.cursor.eat_char('.') { - if self.cursor.eat_char('_') { - return self.push_error(LexicalError::new( - LexicalErrorType::OtherError("invalid syntax".to_string().into_boxed_str()), - TextRange::new(self.offset() - TextSize::new(1), self.offset()), - )); + let mut fraction = first_digit_or_dot == '.'; + if first_digit_or_dot == '0' { + // Zeros, which may be followed by other digits only in a float or imaginary literal. + loop { + if self.cursor.eat_char('_') && !self.cursor.first().is_ascii_digit() { + return self.push_number_error(LexicalErrorType::InvalidNumberLiteral { + kind: NumberLiteralKind::Decimal, + }); + } + if !self.cursor.eat_char('0') { + break; + } } + let nonzero_start = self.offset(); + let nonzero = self.cursor.first().is_ascii_digit(); + if nonzero && !self.decimal_tail() { + return TokenKind::Unknown; + } + match self.cursor.first() { + '.' => { + self.cursor.bump(); + fraction = true; + } + 'e' | 'E' | 'j' | 'J' => {} + _ if nonzero => { + self.errors.push(LexicalError::new( + LexicalErrorType::LeadingZerosInDecimalInteger, + TextRange::new(self.token_range().start(), nonzero_start), + )); + self.current_range = self.token_range(); + return TokenKind::Unknown; + } + _ => {} + } + } else if first_digit_or_dot != '.' { + if !self.decimal_tail() { + return TokenKind::Unknown; + } + fraction = self.cursor.eat_char('.'); + } - self.radix_run(Radix::Decimal); - true - } else { - // Normal number: - false - }; - - let is_float = match self.cursor.rest().as_bytes() { - [b'e' | b'E', b'0'..=b'9', ..] | [b'e' | b'E', b'-' | b'+', b'0'..=b'9', ..] => { - // 'e' | 'E' - self.cursor.bump(); - - self.cursor.eat_if(|c| matches!(c, '+' | '-')); - - self.radix_run(Radix::Decimal); + let mut is_float = fraction; + if fraction && self.cursor.first().is_ascii_digit() && !self.decimal_tail() { + return TokenKind::Unknown; + } - true + if matches!(self.cursor.first(), 'e' | 'E') { + match self.cursor.second() { + '+' | '-' => { + self.cursor.bump(); + self.cursor.bump(); + if !self.cursor.first().is_ascii_digit() { + return self.push_number_error(LexicalErrorType::InvalidNumberLiteral { + kind: NumberLiteralKind::Decimal, + }); + } + } + second if !second.is_ascii_digit() => { + // The `e` isn't part of the number. + self.verify_end_of_number(NumberLiteralKind::Decimal); + return if is_float { + TokenKind::Float + } else { + TokenKind::Int + }; + } + _ => { + self.cursor.bump(); + } } - _ => is_float, - }; + if !self.decimal_tail() { + return TokenKind::Unknown; + } + is_float = true; + } if self.cursor.eat_if(|c| matches!(c, 'j' | 'J')).is_some() { + self.verify_end_of_number(NumberLiteralKind::Imaginary); TokenKind::Complex - } else if is_float { - TokenKind::Float - } else if start_is_zero && integer_part.has_nonzero_digit { - // Leading zeros in decimal integer literals are not permitted. - self.push_error(LexicalError::new( - LexicalErrorType::OtherError( - "invalid decimal integer literal" - .to_string() - .into_boxed_str(), - ), - self.token_range(), - )) } else { - TokenKind::Int + self.verify_end_of_number(NumberLiteralKind::Decimal); + if is_float { + TokenKind::Float + } else { + TokenKind::Int + } } } - /// Consume a sequence of numbers with the given radix, - /// the digits can be decorated with underscores - /// like this: '`1_2_3_4`' == '1234' - fn radix_run(&mut self, radix: Radix) -> RadixRun { - let mut run = RadixRun::default(); + /// Consumes decimal digits, which may be separated by single underscores. Pushes an error and + /// returns `false` for an underscore that is not followed by a digit. + fn decimal_tail(&mut self) -> bool { loop { - if let Some(c) = self.cursor.eat_if(|c| radix.is_digit(c)) { - run.has_digit = true; - run.has_nonzero_digit |= c != '0'; - } - // Number that contains `_` separators. - else if self.cursor.first() == '_' && radix.is_digit(self.cursor.second()) { - // Skip over `_` - self.cursor.bump(); - } else { - break; + self.cursor.eat_while(|c| c.is_ascii_digit()); + if !self.cursor.eat_char('_') { + return true; + } + if !self.cursor.first().is_ascii_digit() { + self.push_number_error(LexicalErrorType::InvalidNumberLiteral { + kind: NumberLiteralKind::Decimal, + }); + return false; } } - run + } + + /// Pushes an error for the number literal at its last consumed character, ending the token. + fn push_number_error(&mut self, error: LexicalErrorType) -> TokenKind { + self.errors.push(LexicalError::new( + error, + TextRange::empty(self.offset() - TextSize::new(1)), + )); + self.current_range = self.token_range(); + TokenKind::Unknown + } + + /// Pushes an error if the number literal is directly followed by a name, unless the name starts + /// with a keyword that can follow a number in valid code. The token is kept as a number. + fn verify_end_of_number(&mut self, kind: NumberLiteralKind) { + let rest = self.cursor.rest(); + let before_keyword = ["and", "else", "for", "if", "in", "is", "not", "or"] + .iter() + .any(|keyword| rest.starts_with(keyword)); + if !before_keyword + && rest + .chars() + .next() + .is_some_and(|c| c.is_ascii_alphanumeric() || c == '_') + { + self.errors.push(LexicalError::new( + LexicalErrorType::InvalidNumberLiteral { kind }, + TextRange::empty(self.offset() - TextSize::new(1)), + )); + } } /// Lex a single comment. @@ -1726,21 +1844,19 @@ impl State { } } -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] enum Radix { Binary, Octal, - Decimal, Hex, } impl Radix { - const fn as_u32(self) -> u32 { + const fn kind(self) -> NumberLiteralKind { match self { - Radix::Binary => 2, - Radix::Octal => 8, - Radix::Decimal => 10, - Radix::Hex => 16, + Radix::Binary => NumberLiteralKind::Binary, + Radix::Octal => NumberLiteralKind::Octal, + Radix::Hex => NumberLiteralKind::Hexadecimal, } } @@ -1748,18 +1864,11 @@ impl Radix { match self { Radix::Binary => matches!(c, '0'..='1'), Radix::Octal => matches!(c, '0'..='7'), - Radix::Decimal => c.is_ascii_digit(), Radix::Hex => c.is_ascii_hexdigit(), } } } -#[derive(Default)] -struct RadixRun { - has_digit: bool, - has_nonzero_digit: bool, -} - const fn is_quote(c: char) -> bool { matches!(c, '\'' | '"') } diff --git a/crates/ruff_python_parser/src/lib.rs b/crates/ruff_python_parser/src/lib.rs index a6066bda687cf1..272ce2895a52ec 100644 --- a/crates/ruff_python_parser/src/lib.rs +++ b/crates/ruff_python_parser/src/lib.rs @@ -64,7 +64,7 @@ //! [lexer]: crate::lexer pub use crate::error::{ - InterpolatedStringErrorType, LexicalErrorType, ParseError, ParseErrorType, + InterpolatedStringErrorType, LexicalErrorType, NumberLiteralKind, ParseError, ParseErrorType, UnsupportedSyntaxError, UnsupportedSyntaxErrorKind, }; pub use crate::parser::ParseOptions; diff --git a/crates/ruff_python_parser/src/parser/tests.rs b/crates/ruff_python_parser/src/parser/tests.rs index d715caf2cd1a68..d3947f71700a6f 100644 --- a/crates/ruff_python_parser/src/parser/tests.rs +++ b/crates/ruff_python_parser/src/parser/tests.rs @@ -577,3 +577,47 @@ fn unclosed_bracket_in_place_of_earlier_error_is_complete() { fn unclosed_bracket_after_same_line_error() { assert_eq!(first_error("def f(:\n").to_string(), "invalid syntax"); } + +#[test] +fn number_literal_errors() { + for (source, message) in [ + ("0x\n", "invalid hexadecimal literal"), + ("0o9\n", "invalid digit '9' in octal literal"), + ("0b1_2\n", "invalid digit '2' in binary literal"), + ("1_\n", "invalid decimal literal"), + ("1e+x\n", "invalid decimal literal"), + ("1abc\n", "invalid decimal literal"), + ("1jx\n", "invalid imaginary literal"), + ( + "0012\n", + "leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers", + ), + ] { + assert_eq!(first_error(source).to_string(), message, "{source:?}"); + } +} + +#[test] +fn number_literal_before_keyword() { + assert!(parse_unchecked("1if x else 2\n", ParseOptions::from(Mode::Module)).has_valid_syntax()); +} + +#[test] +fn incompatible_string_prefixes() { + assert_eq!( + first_error("x = bu''\n"), + ParseErrorType::Lexical(LexicalErrorType::IncompatibleStringPrefixes { + first: 'u', + second: 'b', + }) + ); + assert!(parse_unchecked("ub = 1\n", ParseOptions::from(Mode::Module)).has_valid_syntax()); +} + +#[test] +fn non_printable_character() { + assert_eq!( + first_error("x = \u{a0}\n").to_string(), + "invalid non-printable character U+00A0" + ); +} diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_big.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_big.snap index 4297865f22dbef..1cc2d92de23e7c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_big.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_big.snap @@ -13,10 +13,8 @@ expression: "lex_invalid(source, Mode::Module)" ``` [ LexicalError { - error: OtherError( - "invalid decimal integer literal", - ), - location: 0..85, + error: LeadingZerosInDecimalInteger, + location: 0..1, }, ] ``` diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_small.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_small.snap index d5176b70751422..f0cde0f8a63965 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_small.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__invalid_leading_zero_small.snap @@ -13,10 +13,8 @@ expression: "lex_invalid(source, Mode::Module)" ``` [ LexicalError { - error: OtherError( - "invalid decimal integer literal", - ), - location: 0..3, + error: LeadingZerosInDecimalInteger, + location: 0..1, }, ] ``` From 576d2a4bec044ef16802072d405a93e1b371b422 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 5 Oct 2026 03:09:47 +0900 Subject: [PATCH 11/20] Report a missing indented block with its clause and header line Add `ParseErrorType::ExpectedIndentedBlock { clause, line }`, where `line` is the line of the clause's header keyword, and `BlockClause` for the clause. `except*` is reported apart from `except`. Share the line counting between this error and tokenizer error prioritization. Assisted-by: Claude Code:claude-opus-5-5 Assisted-by: Grok CLI:grok-4.6 --- crates/ruff_python_parser/src/error.rs | 49 +++++++ crates/ruff_python_parser/src/lib.rs | 4 +- crates/ruff_python_parser/src/parser/mod.rs | 24 +++- .../src/parser/statement.rs | 123 +++++++++--------- ..._syntax@case_expect_indented_block.py.snap | 2 +- ...nvalid_syntax@class_def_empty_body.py.snap | 4 +- ...yntax@clause_expect_indented_block.py.snap | 4 +- ...lid_syntax@function_def_empty_body.py.snap | 4 +- ...nction_def_unclosed_parameter_list.py.snap | 2 +- .../invalid_syntax@if_stmt_empty_body.py.snap | 2 +- ...valid_syntax@if_stmt_missing_colon.py.snap | 2 +- ...lp_escape_command_error_recovery_1.py.snap | 2 +- ...lp_escape_command_error_recovery_3.py.snap | 2 +- ...x@match_stmt_expect_indented_block.py.snap | 2 +- ...nvalid_syntax@re_lex_logical_token.py.snap | 2 +- 15 files changed, 141 insertions(+), 87 deletions(-) diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index 33898e0a3d4841..ec3f204dec114a 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -211,6 +211,9 @@ pub enum ParseErrorType { found: TokenKind, }, + /// A compound statement header is not followed by an indented block. `line` is the line of + /// the header's keyword. + ExpectedIndentedBlock { clause: BlockClause, line: u32 }, /// An unexpected indentation was found during parsing. UnexpectedIndentation, /// The statement being parsed cannot be `async`. @@ -228,6 +231,46 @@ pub enum ParseErrorType { Lexical(LexicalErrorType), } +/// The compound statement clause whose header precedes an indented block. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, get_size2::GetSize)] +pub enum BlockClause { + If, + Elif, + Else, + For, + With, + While, + Try, + Except, + ExceptStar, + Finally, + Match, + Case, + Class, + FunctionDef, +} + +impl std::fmt::Display for BlockClause { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(match self { + Self::If => "'if' statement", + Self::Elif => "'elif' statement", + Self::Else => "'else' statement", + Self::For => "'for' statement", + Self::With => "'with' statement", + Self::While => "'while' statement", + Self::Try => "'try' statement", + Self::Except => "'except' statement", + Self::ExceptStar => "'except*' statement", + Self::Finally => "'finally' statement", + Self::Match => "'match' statement", + Self::Case => "'case' statement", + Self::Class => "class definition", + Self::FunctionDef => "function definition", + }) + } +} + impl ParseErrorType { pub(crate) fn from_interpolated_string_error( error: InterpolatedStringErrorType, @@ -246,6 +289,12 @@ impl std::fmt::Display for ParseErrorType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { ParseErrorType::OtherError(msg) => f.write_str(msg), + ParseErrorType::ExpectedIndentedBlock { clause, line } => { + write!( + f, + "expected an indented block after {clause} on line {line}" + ) + } ParseErrorType::StringAnnotationError(msg) => f.write_str(msg), ParseErrorType::ExpectedToken { found, expected } => match (*expected, *found) { (TokenKind::Colon, TokenKind::Newline) => f.write_str("expected ':'"), diff --git a/crates/ruff_python_parser/src/lib.rs b/crates/ruff_python_parser/src/lib.rs index 272ce2895a52ec..4399d90427615d 100644 --- a/crates/ruff_python_parser/src/lib.rs +++ b/crates/ruff_python_parser/src/lib.rs @@ -64,8 +64,8 @@ //! [lexer]: crate::lexer pub use crate::error::{ - InterpolatedStringErrorType, LexicalErrorType, NumberLiteralKind, ParseError, ParseErrorType, - UnsupportedSyntaxError, UnsupportedSyntaxErrorKind, + BlockClause, InterpolatedStringErrorType, LexicalErrorType, NumberLiteralKind, ParseError, + ParseErrorType, UnsupportedSyntaxError, UnsupportedSyntaxErrorKind, }; pub use crate::parser::ParseOptions; diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index 71079925eaf243..412d93518e9964 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -327,6 +327,13 @@ impl<'src> Parser<'src> { self.current_token_range().start() } + /// Returns the 1-based line number of `offset` in the source. + /// + /// `\n`, `\r\n`, and a lone `\r` each count as one line break. + pub(super) fn line_number(&self, offset: TextSize) -> u32 { + line_number(self.source, offset) + } + fn node_range(&self, start: TextSize) -> TextRange { // It's possible during error recovery that the parsing didn't consume any tokens. In that // case, `last_token_end` still points to the end of the previous token but `start` is the @@ -1786,6 +1793,16 @@ impl RecoveryContext { } } +/// Returns the 1-based line number of `offset` in `source`. +/// +/// `\n`, `\r\n`, and a lone `\r` each count as one line break. +fn line_number(source: &str, offset: TextSize) -> u32 { + let text = &source[..offset.to_usize()]; + let newlines = + text.matches('\n').count() + text.matches('\r').count() - text.matches("\r\n").count(); + u32::try_from(newlines + 1).unwrap() +} + /// Moves the error that stops parsing first to the front of `errors`. /// /// The source is tokenized again without the parser's error recovery, and its first tokenizer @@ -1851,14 +1868,9 @@ fn prioritize_tokenizer_error( || (!in_interpolated_string && match tokenizer_error.error() { LexicalErrorType::UnclosedBracket { .. } => { - let line = |offset: TextSize| { - let text = &source[..offset.to_usize()]; - text.matches('\n').count() + text.matches('\r').count() - - text.matches("\r\n").count() - }; let bracket_start = tokenizer_error.location().start(); bracket_start <= error_start - && (line(bracket_start) < line(error_start) + && (line_number(source, bracket_start) < line_number(source, error_start) || stops.iter().all(|stop| *stop < first_start)) } _ => !matches!(first.error, ParseErrorType::UnexpectedIndentation), diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index b1fe2c5c395d45..5643ab229e9c63 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -1,4 +1,4 @@ -use std::fmt::{Display, Write}; +use std::fmt::Write; use ruff_python_ast::name::Name; use ruff_python_ast::token::TokenKind; @@ -16,7 +16,7 @@ use crate::parser::{ helpers, }; use crate::token_set::TokenSet; -use crate::{Mode, ParseErrorType, UnsupportedSyntaxErrorKind}; +use crate::{BlockClause, Mode, ParseErrorType, UnsupportedSyntaxErrorKind}; use super::Parenthesized; use super::expression::ExpressionContext; @@ -1458,7 +1458,7 @@ impl<'src> Parser<'src> { // test_err if_stmt_empty_body // if True: // 1 + 1 - let body = self.parse_body(Clause::If); + let body = self.parse_body(BlockClause::If, start); // test_err if_stmt_misspelled_elif // if True: @@ -1522,7 +1522,7 @@ impl<'src> Parser<'src> { // pass self.expect(TokenKind::Colon); - let body = self.parse_body(kind.as_clause()); + let body = self.parse_body(kind.as_block_clause(), start); ast::ElifElseClause { test, @@ -1548,7 +1548,7 @@ impl<'src> Parser<'src> { let mut is_star: Option = None; - let try_body = self.parse_body(Clause::Try); + let try_body = self.parse_body(BlockClause::Try, try_start); let has_except = self.at(TokenKind::Except); @@ -1621,16 +1621,20 @@ impl<'src> Parser<'src> { // pass // b = 1 - let orelse = if self.eat(TokenKind::Else) { + let orelse = if self.at(TokenKind::Else) { + let else_start = self.current_token_range().start(); + self.bump(TokenKind::Else); self.expect(TokenKind::Colon); - self.parse_body(Clause::Else) + self.parse_body(BlockClause::Else, else_start) } else { Suite::new() }; - let (finalbody, has_finally) = if self.eat(TokenKind::Finally) { + let (finalbody, has_finally) = if self.at(TokenKind::Finally) { + let finally_start = self.current_token_range().start(); + self.bump(TokenKind::Finally); self.expect(TokenKind::Colon); - (self.parse_body(Clause::Finally), true) + (self.parse_body(BlockClause::Finally, finally_start), true) } else { (Suite::new(), false) }; @@ -1849,7 +1853,12 @@ impl<'src> Parser<'src> { self.expect(TokenKind::Colon); - let except_body = self.parse_body(Clause::Except); + let except_clause = if block_kind.is_star() { + BlockClause::ExceptStar + } else { + BlockClause::Except + }; + let except_body = self.parse_body(except_clause, start); ( ExceptHandler::ExceptHandler(ast::ExceptHandlerExceptHandler { @@ -1875,6 +1884,7 @@ impl<'src> Parser<'src> { /// /// See: fn parse_for_statement(&mut self, start: TextSize) -> ast::StmtFor { + let for_start = self.current_token_range().start(); self.bump(TokenKind::For); // test_err for_stmt_missing_target @@ -1954,11 +1964,13 @@ impl<'src> Parser<'src> { self.expect(TokenKind::Colon); - let body = self.parse_body(Clause::For); + let body = self.parse_body(BlockClause::For, for_start); - let orelse = if self.eat(TokenKind::Else) { + let orelse = if self.at(TokenKind::Else) { + let else_start = self.current_token_range().start(); + self.bump(TokenKind::Else); self.expect(TokenKind::Colon); - self.parse_body(Clause::Else) + self.parse_body(BlockClause::Else, else_start) } else { Suite::new() }; @@ -2008,11 +2020,13 @@ impl<'src> Parser<'src> { // pass self.expect(TokenKind::Colon); - let body = self.parse_body(Clause::While); + let body = self.parse_body(BlockClause::While, start); - let orelse = if self.eat(TokenKind::Else) { + let orelse = if self.at(TokenKind::Else) { + let else_start = self.current_token_range().start(); + self.bump(TokenKind::Else); self.expect(TokenKind::Colon); - self.parse_body(Clause::Else) + self.parse_body(BlockClause::Else, else_start) } else { Suite::new() }; @@ -2045,6 +2059,7 @@ impl<'src> Parser<'src> { decorator_list: DecoratorList, start: TextSize, ) -> ast::StmtFunctionDef { + let def_start = self.current_token_range().start(); self.bump(TokenKind::Def); // test_err function_def_missing_identifier @@ -2143,7 +2158,7 @@ impl<'src> Parser<'src> { // def foo(): // def foo() -> int: // x = 42 - let body = self.parse_body(Clause::FunctionDef); + let body = self.parse_body(BlockClause::FunctionDef, def_start); ast::StmtFunctionDef { name, @@ -2177,6 +2192,7 @@ impl<'src> Parser<'src> { decorator_list: DecoratorList, start: TextSize, ) -> ast::StmtClassDef { + let class_start = self.current_token_range().start(); self.bump(TokenKind::Class); // test_err class_def_missing_name @@ -2224,7 +2240,7 @@ impl<'src> Parser<'src> { // class Foo: // class Foo(): // x = 42 - let body = self.parse_body(Clause::Class); + let body = self.parse_body(BlockClause::Class, class_start); ast::StmtClassDef { range: self.node_range(start), @@ -2250,6 +2266,7 @@ impl<'src> Parser<'src> { /// /// See: fn parse_with_statement(&mut self, start: TextSize) -> ast::StmtWith { + let with_start = self.current_token_range().start(); self.bump(TokenKind::With); let mut items = self.parse_with_items(); @@ -2257,7 +2274,7 @@ impl<'src> Parser<'src> { self.expect(TokenKind::Colon); - let body = self.parse_body(Clause::With); + let body = self.parse_body(BlockClause::With, with_start); ast::StmtWith { items, @@ -2618,7 +2635,7 @@ impl<'src> Parser<'src> { // `match [x, y, z]: {dict}` or `match[0]: int`. self.bump(TokenKind::Colon); - let cases = self.parse_match_body(); + let cases = self.parse_match_body(start); Some(ast::StmtMatch { subject: Box::new(subject), @@ -2641,7 +2658,7 @@ impl<'src> Parser<'src> { self.current_token_range(), ); - let cases = self.parse_match_body(); + let cases = self.parse_match_body(start); Some(ast::StmtMatch { subject: Box::new(subject), @@ -2675,7 +2692,7 @@ impl<'src> Parser<'src> { let subject = self.parse_match_subject_expression(); self.expect(TokenKind::Colon); - let cases = self.parse_match_body(); + let cases = self.parse_match_body(start); // test_err match_before_py310 // # parse_options: { "target-version": "3.9" } @@ -2754,7 +2771,9 @@ impl<'src> Parser<'src> { /// /// This method expects that the parser is positioned at a `Newline` token. If not, it adds a /// syntax error and continues parsing. - fn parse_match_body(&mut self) -> Vec { + /// + /// `header_start` is the start of the `match` keyword. + fn parse_match_body(&mut self, header_start: TextSize) -> Vec { // test_err match_stmt_no_newline_before_case // match foo: case _: ... self.expect(TokenKind::Newline); @@ -2765,9 +2784,10 @@ impl<'src> Parser<'src> { // match foo: // case _: ... self.add_error( - ParseErrorType::OtherError( - "expected an indented block after `match` statement".to_string(), - ), + ParseErrorType::ExpectedIndentedBlock { + clause: BlockClause::Match, + line: self.line_number(header_start), + }, self.current_token_range(), ); } @@ -2867,7 +2887,7 @@ impl<'src> Parser<'src> { // match subject: // case 1: // case 2: ... - let body = self.parse_body(Clause::Case); + let body = self.parse_body(BlockClause::Case, start); ast::MatchCase { pattern, @@ -3122,11 +3142,13 @@ impl<'src> Parser<'src> { } } - /// Parses the body of the given [`Clause`]. + /// Parses the body of the given [`BlockClause`]. /// /// This could either be a single statement that's on the same line as the /// clause header or an indented block. - fn parse_body(&mut self, parent_clause: Clause) -> Suite { + /// + /// `header_start` is the start of the clause's header keyword token. + fn parse_body(&mut self, clause: BlockClause, header_start: TextSize) -> Suite { // Note: The test cases in this method chooses a clause at random to test // the error logic. @@ -3143,9 +3165,10 @@ impl<'src> Parser<'src> { // # at the newline token after `:` // if True: self.add_error( - ParseErrorType::OtherError(format!( - "expected an indented block after {parent_clause}" - )), + ParseErrorType::ExpectedIndentedBlock { + clause, + line: self.line_number(header_start), + }, if self.current_token_range().is_empty() { newline_range } else { @@ -4072,7 +4095,6 @@ impl<'src> Parser<'src> { let recovery_kind = match clause { Clause::ElIf => RecoveryContextKind::Elif, Clause::Except => RecoveryContextKind::Except, - _ => unreachable!("Clause is not supported"), }; let saved_context = self.recovery_context; @@ -4092,37 +4114,8 @@ impl<'src> Parser<'src> { #[derive(Copy, Clone)] enum Clause { - If, - Else, ElIf, - For, - With, - Class, - While, - FunctionDef, - Case, - Try, Except, - Finally, -} - -impl Display for Clause { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Clause::If => write!(f, "`if` statement"), - Clause::Else => write!(f, "`else` clause"), - Clause::ElIf => write!(f, "`elif` clause"), - Clause::For => write!(f, "`for` statement"), - Clause::With => write!(f, "`with` statement"), - Clause::Class => write!(f, "`class` definition"), - Clause::While => write!(f, "`while` statement"), - Clause::FunctionDef => write!(f, "function definition"), - Clause::Case => write!(f, "`case` block"), - Clause::Try => write!(f, "`try` statement"), - Clause::Except => write!(f, "`except` clause"), - Clause::Finally => write!(f, "`finally` clause"), - } - } } /// The classification of the `match` token. @@ -4200,10 +4193,10 @@ impl ElifOrElse { } } - const fn as_clause(self) -> Clause { + const fn as_block_clause(self) -> BlockClause { match self { - ElifOrElse::Elif => Clause::ElIf, - ElifOrElse::Else => Clause::Else, + ElifOrElse::Elif => BlockClause::Elif, + ElifOrElse::Else => BlockClause::Else, } } } diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap index d83d217f061314..e1d946181d157e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@case_expect_indented_block.py.snap @@ -94,4 +94,4 @@ Module( 1 | match subject: 2 | case 1: 3 | case 2: ... - | ^^^^ Syntax Error: expected an indented block after `case` block + | ^^^^ Syntax Error: expected an indented block after 'case' statement on line 2 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap index ffabbbe51134e5..0c37c6ae62cecc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_empty_body.py.snap @@ -91,7 +91,7 @@ Module( | 1 | class Foo: 2 | class Foo(): - | ^^^^^ Syntax Error: expected an indented block after `class` definition + | ^^^^^ Syntax Error: expected an indented block after class definition on line 1 3 | x = 42 | @@ -100,4 +100,4 @@ Module( 1 | class Foo: 2 | class Foo(): 3 | x = 42 - | ^ Syntax Error: expected an indented block after `class` definition + | ^ Syntax Error: expected an indented block after class definition on line 2 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap index d2a4c57dd55f91..0895e62f880eb8 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@clause_expect_indented_block.py.snap @@ -59,7 +59,7 @@ Module( 1 | # Here, the error is highlighted at the `pass` token 2 | if True: 3 | pass - | ^^^^ Syntax Error: expected an indented block after `if` statement + | ^^^^ Syntax Error: expected an indented block after 'if' statement on line 2 4 | # The parser is at the end of the program, so let's highlight 5 | # at the newline token after `:` | @@ -69,4 +69,4 @@ Module( 4 | # The parser is at the end of the program, so let's highlight 5 | # at the newline token after `:` 6 | if True: - | ^ Syntax Error: expected an indented block after `if` statement + | ^ Syntax Error: expected an indented block after 'if' statement on line 6 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap index 77165b59c041a5..212cea4686f45d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_empty_body.py.snap @@ -117,7 +117,7 @@ Module( | 1 | def foo(): 2 | def foo() -> int: - | ^^^ Syntax Error: expected an indented block after function definition + | ^^^ Syntax Error: expected an indented block after function definition on line 1 3 | x = 42 | @@ -126,4 +126,4 @@ Module( 1 | def foo(): 2 | def foo() -> int: 3 | x = 42 - | ^ Syntax Error: expected an indented block after function definition + | ^ Syntax Error: expected an indented block after function definition on line 2 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap index 6be9cddae6d5d2..13772a6e79d773 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap @@ -270,7 +270,7 @@ Module( | 1 | def foo(a: int, b: 2 | def foo(): - | ^^^ Syntax Error: expected an indented block after function definition + | ^^^ Syntax Error: expected an indented block after function definition on line 1 3 | return 42 4 | def foo(a: int, b: str | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap index d604ef52f11a8f..400e5a47cde87d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_empty_body.py.snap @@ -67,4 +67,4 @@ Module( | 1 | if True: 2 | 1 + 1 - | ^ Syntax Error: expected an indented block after `if` statement + | ^ Syntax Error: expected an indented block after 'if' statement on line 1 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap index 1f124f45d801e8..2d0a20efb67f99 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_missing_colon.py.snap @@ -98,7 +98,7 @@ Module( | 1 | if x 2 | if x - | ^^ Syntax Error: expected an indented block after `if` statement + | ^^ Syntax Error: expected an indented block after 'if' statement on line 1 3 | pass 4 | a = 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap index f650fd0569b089..8d3dff26ba66bc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_1.py.snap @@ -84,4 +84,4 @@ Module( 1 | # parse_options: {"mode": "ipython"} 2 | with (a, ?b) 3 | ? - | ^ Syntax Error: expected an indented block after `with` statement + | ^ Syntax Error: expected an indented block after 'with' statement on line 2 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap index 3b5a584394e33f..c265bd593a29a2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ipython_help_escape_command_error_recovery_3.py.snap @@ -114,6 +114,6 @@ Module( 1 | # parse_options: {"mode": "ipython"} 2 | with a, ?b 3 | ? - | ^ Syntax Error: expected an indented block after `with` statement + | ^ Syntax Error: expected an indented block after 'with' statement on line 2 4 | x = 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap index 3fdfdf868feb5c..a39e05b63e6e57 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_expect_indented_block.py.snap @@ -64,7 +64,7 @@ Module( | 1 | match foo: 2 | case _: ... - | ^^^^ Syntax Error: expected an indented block after `match` statement + | ^^^^ Syntax Error: expected an indented block after 'match' statement on line 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap index 429ff977726196..8ee64532dd68d6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap @@ -883,7 +883,7 @@ Module( 1 | # No indentation before the function definition 2 | if call(foo 3 | def bar(): - | ^^^ Syntax Error: expected an indented block after `if` statement + | ^^^ Syntax Error: expected an indented block after 'if' statement on line 2 4 | pass | From 2652b5716988eb21cbaa8597793730042b868ba4 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 5 Oct 2026 03:44:48 +0900 Subject: [PATCH 12/20] Name the invalid expression in binding target errors Add `ExpressionKind`, the kind of an expression as syntax errors name it, and carry it in the assignment, named assignment, augmented assignment and delete target errors. Report invalid targets after `as` in imports, patterns and `except` clauses with their kind. In an assignment, report the target before `=` as a possible comparison when the expression after `=` is not itself assigned to, and a bare `yield` target with its own error. Target errors come before errors in the expressions after them. Check `for` targets apart from assignment targets: a comparison is not an invalid target there, and the token after it is reported instead. End an unparenthesized tuple at an augmented assignment operator, and report an unparenthesized tuple annotation target at its first element. Assisted-by: Claude Code:claude-opus-5-5 --- .../err/assign_stmt_comparison_like_target.py | 3 + .../inline/err/assign_stmt_yield_target.py | 2 + ...ssign_stmt_unparenthesized_tuple_target.py | 1 + .../inline/err/except_stmt_invalid_as_name.py | 3 + .../inline/err/for_stmt_comparison_target.py | 2 + .../inline/err/import_alias_invalid_asname.py | 2 + .../err/match_as_pattern_invalid_target.py | 3 + crates/ruff_python_parser/src/error.rs | 180 ++++++++- crates/ruff_python_parser/src/lib.rs | 4 +- .../src/parser/expression.rs | 9 +- crates/ruff_python_parser/src/parser/mod.rs | 54 ++- .../ruff_python_parser/src/parser/pattern.rs | 24 +- .../src/parser/statement.rs | 344 +++++++++++++++++- crates/ruff_python_parser/src/token_source.rs | 5 + ...tax@ann_assign_stmt_invalid_target.py.snap | 4 +- ...assign_stmt_comparison_like_target.py.snap | 233 ++++++++++++ ..._syntax@assign_stmt_invalid_target.py.snap | 12 +- ...id_syntax@assign_stmt_yield_target.py.snap | 101 +++++ ...tax@aug_assign_stmt_invalid_target.py.snap | 8 +- ..._stmt_unparenthesized_tuple_target.py.snap | 65 ++++ ...syntax@except_stmt_invalid_as_name.py.snap | 144 ++++++++ ...ressions__compare__multiple_equals.py.snap | 4 +- ...x@expressions__dict__comprehension.py.snap | 8 +- ...x@expressions__list__comprehension.py.snap | 8 +- ...__list__star_expression_precedence.py.snap | 2 +- ...expressions__named__invalid_target.py.snap | 8 +- ..._parenthesized__tuple_starred_expr.py.snap | 4 +- ...ax@expressions__set__comprehension.py.snap | 8 +- ...s__set__star_expression_precedence.py.snap | 2 +- ...__subscript__invalid_slice_element.py.snap | 2 +- ..._syntax@for_stmt_comparison_target.py.snap | 173 +++++++++ ...lid_syntax@for_stmt_invalid_target.py.snap | 19 +- ...or_stmt_invalid_target_binary_expr.py.snap | 12 +- ...for_stmt_invalid_target_in_keyword.py.snap | 12 +- ...syntax@import_alias_invalid_asname.py.snap | 89 +++++ .../invalid_syntax@invalid_del_target.py.snap | 18 +- ...ax@match_as_pattern_invalid_target.py.snap | 156 ++++++++ ...ements__invalid_assignment_targets.py.snap | 62 ++-- ...nvalid_augmented_assignment_target.py.snap | 58 +-- ...ents__match__invalid_class_pattern.py.snap | 10 + 40 files changed, 1693 insertions(+), 165 deletions(-) create mode 100644 crates/ruff_python_parser/resources/inline/err/assign_stmt_comparison_like_target.py create mode 100644 crates/ruff_python_parser/resources/inline/err/assign_stmt_yield_target.py create mode 100644 crates/ruff_python_parser/resources/inline/err/aug_assign_stmt_unparenthesized_tuple_target.py create mode 100644 crates/ruff_python_parser/resources/inline/err/except_stmt_invalid_as_name.py create mode 100644 crates/ruff_python_parser/resources/inline/err/for_stmt_comparison_target.py create mode 100644 crates/ruff_python_parser/resources/inline/err/import_alias_invalid_asname.py create mode 100644 crates/ruff_python_parser/resources/inline/err/match_as_pattern_invalid_target.py create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_comparison_like_target.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_yield_target.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_unparenthesized_tuple_target.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_as_name.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_comparison_target.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_invalid_asname.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_as_pattern_invalid_target.py.snap diff --git a/crates/ruff_python_parser/resources/inline/err/assign_stmt_comparison_like_target.py b/crates/ruff_python_parser/resources/inline/err/assign_stmt_comparison_like_target.py new file mode 100644 index 00000000000000..0897ed2603b8e2 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/assign_stmt_comparison_like_target.py @@ -0,0 +1,3 @@ +f() = 1 +f(), b = 1 +a, (x < y) = 1 if z else 2 diff --git a/crates/ruff_python_parser/resources/inline/err/assign_stmt_yield_target.py b/crates/ruff_python_parser/resources/inline/err/assign_stmt_yield_target.py new file mode 100644 index 00000000000000..17eafb07817608 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/assign_stmt_yield_target.py @@ -0,0 +1,2 @@ +yield x = 1 +y = yield = 1 diff --git a/crates/ruff_python_parser/resources/inline/err/aug_assign_stmt_unparenthesized_tuple_target.py b/crates/ruff_python_parser/resources/inline/err/aug_assign_stmt_unparenthesized_tuple_target.py new file mode 100644 index 00000000000000..a173896b86c163 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/aug_assign_stmt_unparenthesized_tuple_target.py @@ -0,0 +1 @@ +a, b += 1 diff --git a/crates/ruff_python_parser/resources/inline/err/except_stmt_invalid_as_name.py b/crates/ruff_python_parser/resources/inline/err/except_stmt_invalid_as_name.py new file mode 100644 index 00000000000000..8e54ea6b717157 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/except_stmt_invalid_as_name.py @@ -0,0 +1,3 @@ +try: ... +except Exception as x.y: ... +except* Exception as f(): ... diff --git a/crates/ruff_python_parser/resources/inline/err/for_stmt_comparison_target.py b/crates/ruff_python_parser/resources/inline/err/for_stmt_comparison_target.py new file mode 100644 index 00000000000000..5a662a15f7414e --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/for_stmt_comparison_target.py @@ -0,0 +1,2 @@ +for x == y in z: ... +for (x in y), z in w: ... diff --git a/crates/ruff_python_parser/resources/inline/err/import_alias_invalid_asname.py b/crates/ruff_python_parser/resources/inline/err/import_alias_invalid_asname.py new file mode 100644 index 00000000000000..6bb695d5a27349 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/import_alias_invalid_asname.py @@ -0,0 +1,2 @@ +import x as y.z +from x import (y as z()) diff --git a/crates/ruff_python_parser/resources/inline/err/match_as_pattern_invalid_target.py b/crates/ruff_python_parser/resources/inline/err/match_as_pattern_invalid_target.py new file mode 100644 index 00000000000000..57ff3408afd94f --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/match_as_pattern_invalid_target.py @@ -0,0 +1,3 @@ +match x: + case y as z.w: ... + case y as f(): ... diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index ec3f204dec114a..11b4260e6a84cd 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -1,7 +1,7 @@ use std::fmt::{self, Display}; -use ruff_python_ast::PythonVersion; use ruff_python_ast::token::TokenKind; +use ruff_python_ast::{ConstantValue, Expr, PythonVersion}; use ruff_text_size::{Ranged, TextRange}; use crate::string::InterpolatedStringKind; @@ -172,16 +172,30 @@ pub enum ParseErrorType { /// A default value was found for a `*` or `**` parameter. VarParameterWithDefault, - /// An invalid expression was found in the assignment target. - InvalidAssignmentTarget, + /// An invalid expression was found in the assignment target. `maybe_comparison` is set when + /// the `=` after it may have been meant as `==`. + InvalidAssignmentTarget { + kind: ExpressionKind, + maybe_comparison: bool, + }, + /// A name is assigned to where `==` or `:=` may have been meant. + AssignmentInsteadOfComparison, + /// A `yield` expression is assigned to. + AssignmentToYield, /// An invalid expression was found in the named assignment target. - InvalidNamedAssignmentTarget, + InvalidNamedAssignmentTarget(ExpressionKind), /// An invalid expression was found in the annotated assignment target. InvalidAnnotatedAssignmentTarget, /// An invalid expression was found in the augmented assignment target. - InvalidAugmentedAssignmentTarget, + InvalidAugmentedAssignmentTarget(ExpressionKind), /// An invalid expression was found in the delete target. - InvalidDeleteTarget, + InvalidDeleteTarget(ExpressionKind), + /// An invalid expression was found after `as` in an import. + InvalidImportTarget(ExpressionKind), + /// An invalid expression was found after `as` in a pattern. + InvalidPatternTarget(ExpressionKind), + /// An invalid expression was found after `as` in an `except` or `except*` clause. + InvalidExceptTarget { kind: ExpressionKind, star: bool }, /// A positional argument was found after a keyword argument. PositionalAfterKeywordArgument, @@ -231,6 +245,119 @@ pub enum ParseErrorType { Lexical(LexicalErrorType), } +/// The kind of an expression, as syntax errors name it. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, get_size2::GetSize)] +pub enum ExpressionKind { + Attribute, + Subscript, + Starred, + Name, + List, + Tuple, + Lambda, + FunctionCall, + Expression, + GeneratorExpression, + YieldExpression, + AwaitExpression, + ListComprehension, + SetComprehension, + DictComprehension, + DictLiteral, + SetDisplay, + FStringExpression, + TStringExpression, + None, + False, + True, + Ellipsis, + Literal, + Comparison, + ConditionalExpression, + NamedExpression, +} + +impl ExpressionKind { + pub fn of(expr: &Expr) -> Self { + match expr { + Expr::Attribute(_) => Self::Attribute, + Expr::Subscript(_) => Self::Subscript, + Expr::Starred(_) => Self::Starred, + Expr::Name(_) => Self::Name, + Expr::List(_) => Self::List, + Expr::Tuple(_) => Self::Tuple, + Expr::Lambda(_) => Self::Lambda, + Expr::Call(_) => Self::FunctionCall, + Expr::BoolOp(_) + | Expr::BinOp(_) + | Expr::UnaryOp(_) + | Expr::Slice(_) + | Expr::IpyEscapeCommand(_) => Self::Expression, + Expr::Generator(_) => Self::GeneratorExpression, + Expr::Yield(_) | Expr::YieldFrom(_) => Self::YieldExpression, + Expr::Await(_) => Self::AwaitExpression, + Expr::ListComp(_) => Self::ListComprehension, + Expr::SetComp(_) => Self::SetComprehension, + Expr::DictComp(_) => Self::DictComprehension, + Expr::Dict(_) => Self::DictLiteral, + Expr::Set(_) => Self::SetDisplay, + Expr::FString(_) => Self::FStringExpression, + Expr::TString(_) => Self::TStringExpression, + Expr::NoneLiteral(_) => Self::None, + Expr::BooleanLiteral(literal) if literal.value => Self::True, + Expr::BooleanLiteral(_) => Self::False, + Expr::EllipsisLiteral(_) => Self::Ellipsis, + Expr::StringLiteral(_) | Expr::BytesLiteral(_) | Expr::NumberLiteral(_) => { + Self::Literal + } + Expr::Compare(_) => Self::Comparison, + Expr::If(_) => Self::ConditionalExpression, + Expr::Named(_) => Self::NamedExpression, + Expr::Constant(constant) => match constant.value { + ConstantValue::None => Self::None, + ConstantValue::Boolean(true) => Self::True, + ConstantValue::Boolean(false) => Self::False, + ConstantValue::Ellipsis => Self::Ellipsis, + _ => Self::Literal, + }, + } + } +} + +impl std::fmt::Display for ExpressionKind { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(match self { + Self::Attribute => "attribute", + Self::Subscript => "subscript", + Self::Starred => "starred", + Self::Name => "name", + Self::List => "list", + Self::Tuple => "tuple", + Self::Lambda => "lambda", + Self::FunctionCall => "function call", + Self::Expression => "expression", + Self::GeneratorExpression => "generator expression", + Self::YieldExpression => "yield expression", + Self::AwaitExpression => "await expression", + Self::ListComprehension => "list comprehension", + Self::SetComprehension => "set comprehension", + Self::DictComprehension => "dict comprehension", + Self::DictLiteral => "dict literal", + Self::SetDisplay => "set display", + Self::FStringExpression => "f-string expression", + Self::TStringExpression => "t-string expression", + Self::None => "None", + Self::False => "False", + Self::True => "True", + Self::Ellipsis => "ellipsis", + Self::Literal => "literal", + Self::Comparison => "comparison", + Self::ConditionalExpression => "conditional expression", + Self::NamedExpression => "named expression", + }) + } +} + /// The compound statement clause whose header precedes an indented block. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, get_size2::GetSize)] pub enum BlockClause { @@ -379,17 +506,46 @@ impl std::fmt::Display for ParseErrorType { } ParseErrorType::ExpectedExpression => f.write_str("invalid syntax"), ParseErrorType::UnexpectedIndentation => f.write_str("unexpected indent"), - ParseErrorType::InvalidAssignmentTarget => f.write_str("invalid assignment target"), + ParseErrorType::InvalidAssignmentTarget { + kind, + maybe_comparison: false, + } => write!(f, "cannot assign to {kind}"), + ParseErrorType::InvalidAssignmentTarget { + kind, + maybe_comparison: true, + } => write!( + f, + "cannot assign to {kind} here. Maybe you meant '==' instead of '='?" + ), + ParseErrorType::AssignmentInsteadOfComparison => { + f.write_str("invalid syntax. Maybe you meant '==' or ':=' instead of '='?") + } + ParseErrorType::AssignmentToYield => { + f.write_str("assignment to yield expression not possible") + } ParseErrorType::InvalidAnnotatedAssignmentTarget => { f.write_str("illegal target for annotation") } - ParseErrorType::InvalidNamedAssignmentTarget => { - f.write_str("assignment expression target must be an identifier") + ParseErrorType::InvalidNamedAssignmentTarget(kind) => { + write!(f, "cannot use assignment expressions with {kind}") + } + ParseErrorType::InvalidAugmentedAssignmentTarget(kind) => { + write!( + f, + "'{kind}' is an illegal expression for augmented assignment" + ) + } + ParseErrorType::InvalidDeleteTarget(kind) => write!(f, "cannot delete {kind}"), + ParseErrorType::InvalidImportTarget(kind) => { + write!(f, "cannot use {kind} as import target") + } + ParseErrorType::InvalidPatternTarget(kind) => { + write!(f, "cannot use {kind} as pattern target") } - ParseErrorType::InvalidAugmentedAssignmentTarget => { - f.write_str("invalid augmented assignment target") + ParseErrorType::InvalidExceptTarget { kind, star } => { + let clause = if *star { "except*" } else { "except" }; + write!(f, "cannot use {clause} statement with {kind}") } - ParseErrorType::InvalidDeleteTarget => f.write_str("invalid syntax"), ParseErrorType::UnexpectedIpythonEscapeCommand => { f.write_str("IPython escape commands are only allowed in `Mode::Ipython`") } diff --git a/crates/ruff_python_parser/src/lib.rs b/crates/ruff_python_parser/src/lib.rs index 4399d90427615d..19b81e5d9ed690 100644 --- a/crates/ruff_python_parser/src/lib.rs +++ b/crates/ruff_python_parser/src/lib.rs @@ -64,8 +64,8 @@ //! [lexer]: crate::lexer pub use crate::error::{ - BlockClause, InterpolatedStringErrorType, LexicalErrorType, NumberLiteralKind, ParseError, - ParseErrorType, UnsupportedSyntaxError, UnsupportedSyntaxErrorKind, + BlockClause, ExpressionKind, InterpolatedStringErrorType, LexicalErrorType, NumberLiteralKind, + ParseError, ParseErrorType, UnsupportedSyntaxError, UnsupportedSyntaxErrorKind, }; pub use crate::parser::ParseOptions; diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index de23604617f020..8b68ca49d50b9d 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -23,7 +23,7 @@ use crate::string::{ }; use crate::token_set::TokenSet; use crate::{ - InterpolatedStringErrorType, Mode, ParseErrorType, UnsupportedSyntaxError, + ExpressionKind, InterpolatedStringErrorType, Mode, ParseErrorType, UnsupportedSyntaxError, UnsupportedSyntaxErrorKind, }; @@ -2593,7 +2593,7 @@ impl<'src> Parser<'src> { self.parse_expression_list(ExpressionContext::starred_conditional().with_in_excluded()); helpers::set_expr_ctx(&mut target.expr, ExprContext::Store); - self.validate_assignment_target(&target.expr); + self.validate_for_target(&target.expr); self.expect(TokenKind::In); let iter = self.parse_simple_expression(ExpressionContext::default()); @@ -2875,7 +2875,10 @@ impl<'src> Parser<'src> { self.bump(TokenKind::ColonEqual); if !target.is_name_expr() { - self.add_error(ParseErrorType::InvalidNamedAssignmentTarget, target.range()); + self.add_error( + ParseErrorType::InvalidNamedAssignmentTarget(ExpressionKind::of(&target)), + target.range(), + ); } helpers::set_expr_ctx(&mut target, ExprContext::Store); diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index 412d93518e9964..81f42fed2ee5d4 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -334,6 +334,52 @@ impl<'src> Parser<'src> { line_number(self.source, offset) } + /// Returns `true` if the already parsed expression at `range` is enclosed in parentheses of + /// its own. + fn is_parenthesized(&self, range: TextRange) -> bool { + self.enclosing_parentheses(range).is_some() + } + + /// Returns the end of the already parsed expression at `range`, including the parentheses + /// that enclose only it. + fn parenthesized_end(&self, mut range: TextRange) -> TextSize { + while let Some(parenthesized) = self.enclosing_parentheses(range) { + range = parenthesized; + } + range.end() + } + + /// Returns the range from the `(` directly before `range` to the `)` directly after it, if + /// both exist. + fn enclosing_parentheses(&self, range: TextRange) -> Option { + let tokens = self.tokens.bumped(); + let before = tokens[..tokens.partition_point(|token| token.start() < range.start())] + .iter() + .rev() + .find(|token| !token.kind().is_trivia()) + .filter(|token| token.kind() == TokenKind::Lpar)?; + let (after_kind, after_range) = self.token_after(range.end()); + (after_kind == TokenKind::Rpar).then(|| TextRange::new(before.start(), after_range.end())) + } + + /// Returns the kind of the first non-trivia token that starts at or after `offset`. + fn token_kind_after(&self, offset: TextSize) -> TokenKind { + self.token_after(offset).0 + } + + /// Returns the kind and range of the first non-trivia token that starts at or after + /// `offset`. + fn token_after(&self, offset: TextSize) -> (TokenKind, TextRange) { + let tokens = self.tokens.bumped(); + tokens[tokens.partition_point(|token| token.start() < offset)..] + .iter() + .find(|token| !token.kind().is_trivia()) + .map_or_else( + || (self.current_token_kind(), self.current_token_range()), + |token| (token.kind(), token.range()), + ) + } + fn node_range(&self, start: TextSize) -> TextRange { // It's possible during error recovery that the parsing didn't consume any tokens. In that // case, `last_token_end` still points to the end of the previous token but `start` is the @@ -1404,7 +1450,13 @@ impl RecoveryContextKind { if parenthesized.is_yes() { p.at(TokenKind::Rpar).then_some(ListTerminatorKind::Regular) } else { - p.at_sequence_end().then_some(ListTerminatorKind::Regular) + // test_err aug_assign_stmt_unparenthesized_tuple_target + // a, b += 1 + (p.at_sequence_end() + || p.current_token_kind() + .as_augmented_assign_operator() + .is_some()) + .then_some(ListTerminatorKind::Regular) } } RecoveryContextKind::SequenceMatchPattern(parentheses) => match parentheses { diff --git a/crates/ruff_python_parser/src/parser/pattern.rs b/crates/ruff_python_parser/src/parser/pattern.rs index 5cd876e083f72f..7c7ccaef69ab33 100644 --- a/crates/ruff_python_parser/src/parser/pattern.rs +++ b/crates/ruff_python_parser/src/parser/pattern.rs @@ -9,9 +9,10 @@ use ruff_text_size::{Ranged, TextSize}; use crate::parser::progress::ParserProgress; use crate::parser::{Parser, RecoveryContextKind, SequenceMatchPatternParentheses, recovery}; use crate::token_set::TokenSet; -use crate::{ParseErrorType, UnsupportedSyntaxErrorKind}; +use crate::{ExpressionKind, ParseErrorType, UnsupportedSyntaxErrorKind}; use super::expression::ExpressionContext; +use super::statement::invalid_target_identifier; /// The set of tokens that can start a literal pattern. const LITERAL_PATTERN_START_SET: TokenSet = TokenSet::new([ @@ -126,7 +127,26 @@ impl Parser<'_> { self.add_error(ParseErrorType::InvalidStarPatternUsage, &lhs); } - let ident = self.parse_match_pattern_target(); + let ident = if self.at_expr() + && !(self.at_identifier_or_soft_keyword() + && (self.src_text(self.current_token_range()) == "_" + || !matches!( + self.peek(), + TokenKind::Dot | TokenKind::Lpar | TokenKind::Equal + ))) { + // test_err match_as_pattern_invalid_target + // match x: + // case y as z.w: ... + // case y as f(): ... + let target = self.parse_conditional_expression_or_higher(); + self.add_error( + ParseErrorType::InvalidPatternTarget(ExpressionKind::of(&target.expr)), + &target, + ); + invalid_target_identifier(&target.expr) + } else { + self.parse_match_pattern_target() + }; lhs = Pattern::MatchAs(ast::PatternMatchAs { range: self.node_range(start), name: Some(ident), diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index 5643ab229e9c63..ff0bce286bcc44 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -4,7 +4,7 @@ use ruff_python_ast::name::Name; use ruff_python_ast::token::TokenKind; use ruff_python_ast::{ self as ast, AtomicNodeIndex, DecoratorList, ExceptHandler, Expr, ExprContext, IpyEscapeKind, - Operator, PythonVersion, Stmt, Suite, WithItem, + Operator, PythonVersion, Stmt, Suite, UnaryOp, WithItem, }; use ruff_text_size::{Ranged, TextRange, TextSize}; @@ -16,7 +16,7 @@ use crate::parser::{ helpers, }; use crate::token_set::TokenSet; -use crate::{BlockClause, Mode, ParseErrorType, UnsupportedSyntaxErrorKind}; +use crate::{BlockClause, ExpressionKind, Mode, ParseErrorType, UnsupportedSyntaxErrorKind}; use super::Parenthesized; use super::expression::ExpressionContext; @@ -796,13 +796,32 @@ impl<'src> Parser<'src> { }; let asname = if self.eat(TokenKind::As) { - if self.at_identifier_or_soft_keyword() { + if self.at_identifier_or_soft_keyword() + && matches!( + self.peek(), + TokenKind::Comma + | TokenKind::Rpar + | TokenKind::Semi + | TokenKind::Newline + | TokenKind::EndOfFile + ) + { // test_ok import_as_name_soft_keyword // import foo as match // import bar as case // import baz as type // import qux as lazy Some(self.parse_identifier()) + } else if self.at_expr() { + // test_err import_alias_invalid_asname + // import x as y.z + // from x import (y as z()) + let target = self.parse_conditional_expression_or_higher(); + self.add_error( + ParseErrorType::InvalidImportTarget(ExpressionKind::of(&target.expr)), + &target, + ); + Some(invalid_target_identifier(&target.expr)) } else { // test_err import_alias_missing_asname // import x as @@ -1232,6 +1251,8 @@ impl<'src> Parser<'src> { self.bump(TokenKind::Equal); let mut targets = vec![target.expr]; + // Errors in the targets are reported before the errors in the expressions after them. + let value_errors_start = self.errors.len(); // test_err assign_stmt_missing_rhs // x = @@ -1273,12 +1294,53 @@ impl<'src> Parser<'src> { for target in &mut targets { helpers::set_expr_ctx(target, ExprContext::Store); - // test_err assign_stmt_invalid_target - // 1 = 1 - // x = 1 = 2 - // x = 1 = y = 2 = z - // ["a", "b"] = ["a", "b"] - self.validate_assignment_target(target); + } + + // test_err assign_stmt_invalid_target + // 1 = 1 + // x = 1 = 2 + // x = 1 = y = 2 = z + // ["a", "b"] = ["a", "b"] + if targets + .iter() + .any(|target| invalid_assignment_target(target).is_some()) + { + let value_errors = self.errors.split_off(value_errors_start); + if let Some((target, rhs_end)) = self.comparison_like_assignment(&targets, &value.expr) + { + // test_err assign_stmt_comparison_like_target + // f() = 1 + // f(), b = 1 + // a, (x < y) = 1 if z else 2 + if target.is_name_expr() { + self.add_error( + ParseErrorType::AssignmentInsteadOfComparison, + TextRange::new(target.start(), rhs_end), + ); + } else { + self.add_error( + ParseErrorType::InvalidAssignmentTarget { + kind: ExpressionKind::of(target), + maybe_comparison: true, + }, + target.range(), + ); + } + } else { + for target in &targets { + // test_err assign_stmt_yield_target + // yield x = 1 + // y = yield = 1 + if matches!(target, Expr::Yield(_) | Expr::YieldFrom(_)) + && !self.is_parenthesized(target.range()) + { + self.add_error(ParseErrorType::AssignmentToYield, target); + } else { + self.validate_assignment_target(target); + } + } + } + self.errors.extend(value_errors); } ast::StmtAssign { @@ -1400,7 +1462,10 @@ impl<'src> Parser<'src> { // pass += 1 // x += pass // (x + y) += 1 - self.add_error(ParseErrorType::InvalidAugmentedAssignmentTarget, &target); + self.add_error( + ParseErrorType::InvalidAugmentedAssignmentTarget(ExpressionKind::of(&target.expr)), + &target, + ); } helpers::set_expr_ctx(&mut target.expr, ExprContext::Store); @@ -1796,7 +1861,36 @@ impl<'src> Parser<'src> { }; let name = if self.eat(TokenKind::As) { - if self.at_identifier_or_soft_keyword() { + let checkpoint = self.checkpoint(); + // An unparenthesized tuple of exception types is reported on its own. + let invalid_target = if unparenthesized_types_start.is_none() + && self.at_expr() + && !(self.at_identifier_or_soft_keyword() && self.peek() == TokenKind::Colon) + { + let target = self.parse_conditional_expression_or_higher(); + if self.at(TokenKind::Colon) { + Some(target.expr) + } else { + self.rewind(checkpoint); + None + } + } else { + None + }; + if let Some(target) = invalid_target { + // test_err except_stmt_invalid_as_name + // try: ... + // except Exception as x.y: ... + // except* Exception as f(): ... + self.add_error( + ParseErrorType::InvalidExceptTarget { + kind: ExpressionKind::of(&target), + star: block_kind.is_star(), + }, + &target, + ); + Some(invalid_target_identifier(&target)) + } else if self.at_identifier_or_soft_keyword() { // test_ok except_stmt_as_name_soft_keyword // try: ... // except Exception as match: ... @@ -1923,7 +2017,7 @@ impl<'src> Parser<'src> { // for await x in z: ... // for yield x in y: ... // for [x, 1, y, *["a"]] in z: ... - self.validate_assignment_target(&target.expr); + self.validate_for_target(&target.expr); // test_err for_stmt_missing_in_keyword // for a b: ... @@ -3889,6 +3983,96 @@ impl<'src> Parser<'src> { } } + /// Returns the target of an invalid assignment that is reported as a possible comparison, and + /// the end of the expression it would be compared with. + /// + /// This is the last element of the first target (or the first target itself) when it is a + /// `bitwise_or` expression directly followed by `=`, and the expression after that `=` starts + /// with a `bitwise_or` expression that is not followed by `=` or `:=`. + fn comparison_like_assignment<'a>( + &self, + targets: &'a [Expr], + value: &Expr, + ) -> Option<(&'a Expr, TextSize)> { + let first = targets.first()?; + let target = match first { + Expr::Tuple(tuple) if !tuple.parenthesized => tuple.elts.last()?, + _ => first, + }; + if self.token_kind_after(self.parenthesized_end(target.range())) != TokenKind::Equal + || !self.is_bitwise_or(target) + || self.starts_with_display_or_constant(target) + { + return None; + } + let rhs = self.bitwise_or_prefix(targets.get(1).unwrap_or(value))?; + if matches!( + self.token_kind_after(self.parenthesized_end(rhs.range())), + TokenKind::Equal | TokenKind::ColonEqual + ) { + return None; + } + Some((target, rhs.end())) + } + + /// Returns `true` if `expr` is a `bitwise_or` expression or any parenthesized expression. + fn is_bitwise_or(&self, expr: &Expr) -> bool { + if self.is_parenthesized(expr.range()) { + return true; + } + match expr { + Expr::Compare(_) + | Expr::BoolOp(_) + | Expr::Lambda(_) + | Expr::If(_) + | Expr::Named(_) + | Expr::Yield(_) + | Expr::YieldFrom(_) + | Expr::Starred(_) => false, + Expr::UnaryOp(unary) => unary.op != UnaryOp::Not, + Expr::Tuple(tuple) => tuple.parenthesized, + Expr::Generator(generator) => generator.parenthesized, + _ => true, + } + } + + /// Returns `true` if `expr` starts with a list or tuple display, a parenthesized generator + /// expression, `True`, `False` or `None`. + fn starts_with_display_or_constant(&self, mut expr: &Expr) -> bool { + loop { + if self.is_parenthesized(expr.range()) { + return false; + } + expr = match expr { + Expr::Call(call) => &call.func, + Expr::Attribute(attribute) => &attribute.value, + Expr::Subscript(subscript) => &subscript.value, + Expr::BinOp(bin_op) => &bin_op.left, + Expr::List(_) | Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) => return true, + Expr::Tuple(tuple) => return tuple.parenthesized, + Expr::Generator(generator) => return generator.parenthesized, + _ => return false, + }; + } + } + + /// Returns the `bitwise_or` expression that `expr` starts with, if any. + fn bitwise_or_prefix<'a>(&self, mut expr: &'a Expr) -> Option<&'a Expr> { + loop { + if self.is_parenthesized(expr.range()) { + return Some(expr); + } + expr = match expr { + Expr::Tuple(tuple) if !tuple.parenthesized => tuple.elts.first()?, + Expr::Compare(compare) => compare.operands.first()?, + Expr::BoolOp(bool_op) => bool_op.values.first()?, + Expr::If(if_expr) => &if_expr.body, + _ if self.is_bitwise_or(expr) => return Some(expr), + _ => return None, + }; + } + } + /// Validate that the given expression is a valid assignment target. /// /// If the expression is a list or tuple, then validate each element in the list. @@ -3904,7 +4088,63 @@ impl<'src> Parser<'src> { } } Expr::Name(_) | Expr::Attribute(_) | Expr::Subscript(_) => {} - _ => self.add_error(ParseErrorType::InvalidAssignmentTarget, expr.range()), + _ => self.add_error( + ParseErrorType::InvalidAssignmentTarget { + kind: ExpressionKind::of(expr), + maybe_comparison: false, + }, + expr.range(), + ), + } + } + + /// Validate that the given expression is a valid target of a `for` statement or + /// comprehension. + /// + /// A comparison is not reported as an invalid target, because the `in` that follows the + /// target could belong to it. Without an invalid target, the token where the target stops + /// being one is reported instead. + pub(super) fn validate_for_target(&mut self, target: &Expr) { + let elements = match target { + Expr::Tuple(tuple) if !tuple.parenthesized => &tuple.elts[..], + _ => std::slice::from_ref(target), + }; + let mut comparison_end = None; + for element in elements { + match invalid_for_target(element) { + ForTarget::Valid => {} + ForTarget::Invalid(expr) => { + self.add_error( + ParseErrorType::InvalidAssignmentTarget { + kind: ExpressionKind::of(expr), + maybe_comparison: false, + }, + expr, + ); + return; + } + ForTarget::Comparison(compare) => { + // test_err for_stmt_comparison_target + // for x == y in z: ... + // for (x in y), z in w: ... + comparison_end.get_or_insert_with(|| match &compare.operands[..] { + [left, ..] + if compare.range() == element.range() + && !self.is_parenthesized(element.range()) => + { + self.parenthesized_end(left.range()) + } + _ => self.parenthesized_end(element.range()), + }); + } + } + } + if let Some(end) = comparison_end { + let (_, range) = self.token_after(end); + self.add_error( + ParseErrorType::OtherError("invalid syntax".to_string()), + range, + ); } } @@ -3920,11 +4160,15 @@ impl<'src> Parser<'src> { ), expr, ), - Expr::Tuple(_) => self.add_error( + // An unparenthesized tuple is reported at its first element. + Expr::Tuple(tuple) => self.add_error( ParseErrorType::OtherError( "only single target (not tuple) can be annotated".to_string(), ), - expr, + match tuple.elts.first() { + Some(first) if !tuple.parenthesized => first.range(), + _ => tuple.range(), + }, ), Expr::Name(_) | Expr::Attribute(_) | Expr::Subscript(_) => {} _ => self.add_error(ParseErrorType::InvalidAnnotatedAssignmentTarget, expr), @@ -3944,7 +4188,10 @@ impl<'src> Parser<'src> { } } Expr::Name(_) | Expr::Attribute(_) | Expr::Subscript(_) => {} - _ => self.add_error(ParseErrorType::InvalidDeleteTarget, expr), + _ => self.add_error( + ParseErrorType::InvalidDeleteTarget(ExpressionKind::of(expr)), + expr, + ), } } @@ -4112,6 +4359,71 @@ impl<'src> Parser<'src> { } } +/// Returns the identifier that stands in for an invalid binding target expression. +pub(super) fn invalid_target_identifier(target: &Expr) -> ast::Identifier { + ast::Identifier { + id: match target { + Expr::Name(name) => name.id.clone(), + _ => Name::empty(), + }, + range: target.range(), + node_index: AtomicNodeIndex::NONE, + } +} + +/// How an expression stands as the target of a `for` statement or comprehension. +enum ForTarget<'a> { + Valid, + Invalid(&'a Expr), + /// The target has no invalid expression, but contains this comparison. + Comparison(&'a ast::ExprCompare), +} + +/// Returns the first expression in `expr` that is not a valid `for` target. +/// +/// A comparison whose first operator is `in` is checked through its left operand. +fn invalid_for_target(expr: &Expr) -> ForTarget<'_> { + match expr { + Expr::Starred(ast::ExprStarred { value, .. }) => invalid_for_target(value), + Expr::List(ast::ExprList { elts, .. }) | Expr::Tuple(ast::ExprTuple { elts, .. }) => { + let mut result = ForTarget::Valid; + for elt in elts { + match invalid_for_target(elt) { + ForTarget::Valid => {} + invalid @ ForTarget::Invalid(_) => return invalid, + comparison @ ForTarget::Comparison(_) => { + if matches!(result, ForTarget::Valid) { + result = comparison; + } + } + } + } + result + } + Expr::Compare(compare) => match (compare.ops.first(), compare.operands.first()) { + (Some(ast::CmpOp::In), Some(left)) => match invalid_for_target(left) { + ForTarget::Valid => ForTarget::Comparison(compare), + other => other, + }, + _ => ForTarget::Comparison(compare), + }, + Expr::Name(_) | Expr::Attribute(_) | Expr::Subscript(_) => ForTarget::Valid, + _ => ForTarget::Invalid(expr), + } +} + +/// Returns the first expression in `expr` that is not a valid assignment target. +fn invalid_assignment_target(expr: &Expr) -> Option<&Expr> { + match expr { + Expr::Starred(ast::ExprStarred { value, .. }) => invalid_assignment_target(value), + Expr::List(ast::ExprList { elts, .. }) | Expr::Tuple(ast::ExprTuple { elts, .. }) => { + elts.iter().find_map(invalid_assignment_target) + } + Expr::Name(_) | Expr::Attribute(_) | Expr::Subscript(_) => None, + _ => Some(expr), + } +} + #[derive(Copy, Clone)] enum Clause { ElIf, diff --git a/crates/ruff_python_parser/src/token_source.rs b/crates/ruff_python_parser/src/token_source.rs index 98d8a03965010c..7df04f60a517bb 100644 --- a/crates/ruff_python_parser/src/token_source.rs +++ b/crates/ruff_python_parser/src/token_source.rs @@ -203,6 +203,11 @@ impl<'src> TokenSource<'src> { self.tokens.truncate(tokens_position); } + /// Returns the tokens bumped so far, including the trivia tokens. + pub(crate) fn bumped(&self) -> &[Token] { + &self.tokens + } + /// Returns a slice of [`Token`] that are within the given `range`. pub(crate) fn in_range(&self, range: TextRange) -> &[Token] { let start = self diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap index 25b317e827f654..e8b531d998cd0e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@ann_assign_stmt_invalid_target.py.snap @@ -543,7 +543,7 @@ Module( 3 | *x: int = 1, 2 4 | # Tuple assignment 5 | x,: int = 1 - | ^^ Syntax Error: only single target (not tuple) can be annotated + | ^ Syntax Error: only single target (not tuple) can be annotated 6 | x, y: int = 1, 2 7 | (x, y): int = 1, 2 | @@ -553,7 +553,7 @@ Module( 4 | # Tuple assignment 5 | x,: int = 1 6 | x, y: int = 1, 2 - | ^^^^ Syntax Error: only single target (not tuple) can be annotated + | ^ Syntax Error: only single target (not tuple) can be annotated 7 | (x, y): int = 1, 2 8 | # List assignment | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_comparison_like_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_comparison_like_target.py.snap new file mode 100644 index 00000000000000..1fe9492a31f2bf --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_comparison_like_target.py.snap @@ -0,0 +1,233 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/assign_stmt_comparison_like_target.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..46, + body: [ + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 0..7, + targets: [ + Call( + ExprCall { + node_index: NodeIndex(None), + range: 0..3, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 1..3, + node_index: NodeIndex(None), + args: [], + keywords: [], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + ], + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 6..7, + value: Int( + 1, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 8..18, + targets: [ + Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 8..14, + elts: [ + Call( + ExprCall { + node_index: NodeIndex(None), + range: 8..11, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 8..9, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 9..11, + node_index: NodeIndex(None), + args: [], + keywords: [], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 13..14, + id: Name("b"), + ctx: Store, + }, + ), + ], + ctx: Store, + parenthesized: false, + runtime_elts: None, + }, + ), + ], + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 17..18, + value: Int( + 1, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 19..45, + targets: [ + Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 19..29, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 19..20, + id: Name("a"), + ctx: Store, + }, + ), + Compare( + ExprCompare { + node_index: NodeIndex(None), + range: 23..28, + ops: [ + Lt, + ], + operands: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 23..24, + id: Name("x"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 27..28, + id: Name("y"), + ctx: Load, + }, + ), + ], + runtime_comparators: None, + }, + ), + ], + ctx: Store, + parenthesized: false, + runtime_elts: None, + }, + ), + ], + value: If( + ExprIf { + node_index: NodeIndex(None), + range: 32..45, + test: Name( + ExprName { + node_index: NodeIndex(None), + range: 37..38, + id: Name("z"), + ctx: Load, + }, + ), + body: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 32..33, + value: Int( + 1, + ), + }, + ), + orelse: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 44..45, + value: Int( + 2, + ), + }, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f() = 1 + | ^^^ Syntax Error: cannot assign to function call here. Maybe you meant '==' instead of '='? +2 | f(), b = 1 +3 | a, (x < y) = 1 if z else 2 + | + + + | +1 | f() = 1 +2 | f(), b = 1 + | ^^^^^ Syntax Error: invalid syntax. Maybe you meant '==' or ':=' instead of '='? +3 | a, (x < y) = 1 if z else 2 + | + + + | +1 | f() = 1 +2 | f(), b = 1 +3 | a, (x < y) = 1 if z else 2 + | ^^^^^ Syntax Error: cannot assign to comparison here. Maybe you meant '==' instead of '='? diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap index fe4f41f658a360..b2415f98978cf1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_invalid_target.py.snap @@ -253,7 +253,7 @@ Module( | 1 | 1 = 1 - | ^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal here. Maybe you meant '==' instead of '='? 2 | x = 1 = 2 3 | x = 1 = y = 2 = z | @@ -262,7 +262,7 @@ Module( | 1 | 1 = 1 2 | x = 1 = 2 - | ^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal 3 | x = 1 = y = 2 = z 4 | ["a", "b"] = ["a", "b"] | @@ -272,7 +272,7 @@ Module( 1 | 1 = 1 2 | x = 1 = 2 3 | x = 1 = y = 2 = z - | ^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal 4 | ["a", "b"] = ["a", "b"] | @@ -281,7 +281,7 @@ Module( 1 | 1 = 1 2 | x = 1 = 2 3 | x = 1 = y = 2 = z - | ^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal 4 | ["a", "b"] = ["a", "b"] | @@ -290,11 +290,11 @@ Module( 2 | x = 1 = 2 3 | x = 1 = y = 2 = z 4 | ["a", "b"] = ["a", "b"] - | ^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: cannot assign to literal | 2 | x = 1 = 2 3 | x = 1 = y = 2 = z 4 | ["a", "b"] = ["a", "b"] - | ^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: cannot assign to literal diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_yield_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_yield_target.py.snap new file mode 100644 index 00000000000000..203cfad1cc519a --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_yield_target.py.snap @@ -0,0 +1,101 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/assign_stmt_yield_target.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..26, + body: [ + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 0..11, + targets: [ + Yield( + ExprYield { + node_index: NodeIndex(None), + range: 0..7, + value: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 6..7, + id: Name("x"), + ctx: Load, + }, + ), + ), + }, + ), + ], + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 10..11, + value: Int( + 1, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 12..25, + targets: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 12..13, + id: Name("y"), + ctx: Store, + }, + ), + Yield( + ExprYield { + node_index: NodeIndex(None), + range: 16..21, + value: None, + }, + ), + ], + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 24..25, + value: Int( + 1, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | yield x = 1 + | ^^^^^^^ Syntax Error: assignment to yield expression not possible +2 | y = yield = 1 + | + + + | +1 | yield x = 1 +2 | y = yield = 1 + | ^^^^^ Syntax Error: assignment to yield expression not possible diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap index cf8dfad9a5753a..a10af425537d1c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_invalid_target.py.snap @@ -207,7 +207,7 @@ Module( | 1 | 1 += 1 - | ^ Syntax Error: invalid augmented assignment target + | ^ Syntax Error: 'literal' is an illegal expression for augmented assignment 2 | "a" += "b" 3 | *x += 1 | @@ -216,7 +216,7 @@ Module( | 1 | 1 += 1 2 | "a" += "b" - | ^^^ Syntax Error: invalid augmented assignment target + | ^^^ Syntax Error: 'literal' is an illegal expression for augmented assignment 3 | *x += 1 4 | pass += 1 | @@ -226,7 +226,7 @@ Module( 1 | 1 += 1 2 | "a" += "b" 3 | *x += 1 - | ^^ Syntax Error: invalid augmented assignment target + | ^^ Syntax Error: 'starred' is an illegal expression for augmented assignment 4 | pass += 1 5 | x += pass | @@ -255,4 +255,4 @@ Module( 4 | pass += 1 5 | x += pass 6 | (x + y) += 1 - | ^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^ Syntax Error: 'expression' is an illegal expression for augmented assignment diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_unparenthesized_tuple_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_unparenthesized_tuple_target.py.snap new file mode 100644 index 00000000000000..6b735eb496622e --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@aug_assign_stmt_unparenthesized_tuple_target.py.snap @@ -0,0 +1,65 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/aug_assign_stmt_unparenthesized_tuple_target.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..10, + body: [ + AugAssign( + StmtAugAssign { + node_index: NodeIndex(None), + range: 0..9, + target: Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 0..4, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("a"), + ctx: Store, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("b"), + ctx: Store, + }, + ), + ], + ctx: Store, + parenthesized: false, + runtime_elts: None, + }, + ), + op: Add, + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 8..9, + value: Int( + 1, + ), + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | a, b += 1 + | ^^^^ Syntax Error: 'tuple' is an illegal expression for augmented assignment diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_as_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_as_name.py.snap new file mode 100644 index 00000000000000..b93b588d89c7a1 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_as_name.py.snap @@ -0,0 +1,144 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/except_stmt_invalid_as_name.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..68, + body: [ + Try( + StmtTry { + node_index: NodeIndex(None), + range: 0..67, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 5..8, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 5..8, + }, + ), + }, + ), + ], + handlers: [ + ExceptHandler( + ExceptHandlerExceptHandler { + range: 9..37, + node_index: NodeIndex(None), + type_: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 16..25, + id: Name("Exception"), + ctx: Load, + }, + ), + ), + name: Some( + Identifier { + id: Name(""), + range: 29..32, + node_index: NodeIndex(None), + }, + ), + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 34..37, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 34..37, + }, + ), + }, + ), + ], + runtime_body: None, + }, + ), + ExceptHandler( + ExceptHandlerExceptHandler { + range: 38..67, + node_index: NodeIndex(None), + type_: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 46..55, + id: Name("Exception"), + ctx: Load, + }, + ), + ), + name: Some( + Identifier { + id: Name(""), + range: 59..62, + node_index: NodeIndex(None), + }, + ), + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 64..67, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 64..67, + }, + ), + }, + ), + ], + runtime_body: None, + }, + ), + ], + orelse: [], + finalbody: [], + is_star: false, + runtime_body: None, + runtime_handlers: None, + runtime_orelse: None, + runtime_finalbody: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | try: ... +2 | except Exception as x.y: ... + | ^^^ Syntax Error: cannot use except statement with attribute +3 | except* Exception as f(): ... + | + + + | +1 | try: ... +2 | except Exception as x.y: ... +3 | except* Exception as f(): ... + | ^^^ Syntax Error: cannot use except* statement with function call + + + | +1 | try: ... +2 | except Exception as x.y: ... +3 | except* Exception as f(): ... + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap index cd6f5595f919b7..22dda6ee2d414c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__multiple_equals.py.snap @@ -122,7 +122,7 @@ Module( | 1 | # This is not JavaScript 2 | x === y - | ^^^^ Syntax Error: invalid assignment target + | ^^^^ Syntax Error: cannot assign to comparison 3 | x !== y | @@ -138,4 +138,4 @@ Module( 1 | # This is not JavaScript 2 | x === y 3 | x !== y - | ^^^^ Syntax Error: invalid assignment target + | ^^^^ Syntax Error: cannot assign to comparison diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap index b7404c9d4d25f5..b7b273711f1a1d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__comprehension.py.snap @@ -887,7 +887,7 @@ Module( | 1 | # Invalid target 2 | {x: y for 1 in y} - | ^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal 3 | {x: y for 'a' in y} 4 | {x: y for call() in y} | @@ -897,7 +897,7 @@ Module( 1 | # Invalid target 2 | {x: y for 1 in y} 3 | {x: y for 'a' in y} - | ^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: cannot assign to literal 4 | {x: y for call() in y} 5 | {x: y for {a, b} in y} | @@ -907,7 +907,7 @@ Module( 2 | {x: y for 1 in y} 3 | {x: y for 'a' in y} 4 | {x: y for call() in y} - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to function call 5 | {x: y for {a, b} in y} | @@ -916,7 +916,7 @@ Module( 3 | {x: y for 'a' in y} 4 | {x: y for call() in y} 5 | {x: y for {a, b} in y} - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to set display 6 | 7 | # Invalid iter | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap index ed05f054752da5..6c440db3638dad 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap @@ -1146,7 +1146,7 @@ Module( | 1 | # Invalid target 2 | [x for 1 in y] - | ^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal 3 | [x for 'a' in y] 4 | [x for call() in y] | @@ -1156,7 +1156,7 @@ Module( 1 | # Invalid target 2 | [x for 1 in y] 3 | [x for 'a' in y] - | ^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: cannot assign to literal 4 | [x for call() in y] 5 | [x for {a, b} in y] | @@ -1166,7 +1166,7 @@ Module( 2 | [x for 1 in y] 3 | [x for 'a' in y] 4 | [x for call() in y] - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to function call 5 | [x for {a, b} in y] | @@ -1175,7 +1175,7 @@ Module( 3 | [x for 'a' in y] 4 | [x for call() in y] 5 | [x for {a, b} in y] - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to set display 6 | 7 | # Invalid iter | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap index 26ead6f1e7db38..b8a093b6549d5b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap @@ -536,4 +536,4 @@ Module( 8 | [*x if True else y, z] 9 | [*lambda x: x, z] 10 | [*x := 2, z] - | ^^ Syntax Error: assignment expression target must be an identifier + | ^^ Syntax Error: cannot use assignment expressions with starred diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap index faa2bcbde3ab9a..3b4aa0bfef47a2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__named__invalid_target.py.snap @@ -208,7 +208,7 @@ Module( 1 | # Assignment expression target can only be an identifier 2 | 3 | (x.y := 1) - | ^^^ Syntax Error: assignment expression target must be an identifier + | ^^^ Syntax Error: cannot use assignment expressions with attribute 4 | (x[y] := 1) 5 | (*x := 1) | @@ -217,7 +217,7 @@ Module( | 3 | (x.y := 1) 4 | (x[y] := 1) - | ^^^^ Syntax Error: assignment expression target must be an identifier + | ^^^^ Syntax Error: cannot use assignment expressions with subscript 5 | (*x := 1) 6 | ([x, y] := [1, 2]) | @@ -227,7 +227,7 @@ Module( 3 | (x.y := 1) 4 | (x[y] := 1) 5 | (*x := 1) - | ^^ Syntax Error: assignment expression target must be an identifier + | ^^ Syntax Error: cannot use assignment expressions with starred 6 | ([x, y] := [1, 2]) | @@ -236,4 +236,4 @@ Module( 4 | (x[y] := 1) 5 | (*x := 1) 6 | ([x, y] := [1, 2]) - | ^^^^^^ Syntax Error: assignment expression target must be an identifier + | ^^^^^^ Syntax Error: cannot use assignment expressions with list diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap index 315cc313132361..1b60f04ed22090 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple_starred_expr.py.snap @@ -1441,14 +1441,14 @@ Module( 8 | (*x if True else y, z, *x if True else y) 9 | (*lambda x: x, z, *lambda x: x) 10 | (*x := 2, z, *x := 2) - | ^^ Syntax Error: assignment expression target must be an identifier + | ^^ Syntax Error: cannot use assignment expressions with starred | 8 | (*x if True else y, z, *x if True else y) 9 | (*lambda x: x, z, *lambda x: x) 10 | (*x := 2, z, *x := 2) - | ^^ Syntax Error: assignment expression target must be an identifier + | ^^ Syntax Error: cannot use assignment expressions with starred | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap index fd5274b8087900..50b2b255e19751 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__comprehension.py.snap @@ -767,7 +767,7 @@ Module( | 1 | # Invalid target 2 | {x for 1 in y} - | ^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal 3 | {x for 'a' in y} 4 | {x for call() in y} | @@ -777,7 +777,7 @@ Module( 1 | # Invalid target 2 | {x for 1 in y} 3 | {x for 'a' in y} - | ^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: cannot assign to literal 4 | {x for call() in y} 5 | {x for {a, b} in y} | @@ -787,7 +787,7 @@ Module( 2 | {x for 1 in y} 3 | {x for 'a' in y} 4 | {x for call() in y} - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to function call 5 | {x for {a, b} in y} | @@ -796,7 +796,7 @@ Module( 3 | {x for 'a' in y} 4 | {x for call() in y} 5 | {x for {a, b} in y} - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to set display 6 | 7 | # Invalid iter | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap index b1e5aa0a9ddf9e..16fb46fc6f36ad 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap @@ -528,4 +528,4 @@ Module( 8 | {*x if True else y, z} 9 | {*lambda x: x, z} 10 | {*x := 2, z} - | ^^ Syntax Error: assignment expression target must be an identifier + | ^^ Syntax Error: cannot use assignment expressions with starred diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap index 0c7a4a965bf53f..bd19ee9a423c3f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__invalid_slice_element.py.snap @@ -337,4 +337,4 @@ Module( | 11 | # Mixed starred expression and named expression 12 | x[*x := 1] - | ^^ Syntax Error: assignment expression target must be an identifier + | ^^ Syntax Error: cannot use assignment expressions with starred diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_comparison_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_comparison_target.py.snap new file mode 100644 index 00000000000000..d00e1d8f58d289 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_comparison_target.py.snap @@ -0,0 +1,173 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/for_stmt_comparison_target.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..47, + body: [ + For( + StmtFor { + node_index: NodeIndex(None), + range: 0..20, + is_async: false, + target: Compare( + ExprCompare { + node_index: NodeIndex(None), + range: 4..10, + ops: [ + Eq, + ], + operands: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 4..5, + id: Name("x"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 9..10, + id: Name("y"), + ctx: Load, + }, + ), + ], + runtime_comparators: None, + }, + ), + iter: Name( + ExprName { + node_index: NodeIndex(None), + range: 14..15, + id: Name("z"), + ctx: Load, + }, + ), + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 17..20, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 17..20, + }, + ), + }, + ), + ], + orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, + }, + ), + For( + StmtFor { + node_index: NodeIndex(None), + range: 21..46, + is_async: false, + target: Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 25..36, + elts: [ + Compare( + ExprCompare { + node_index: NodeIndex(None), + range: 26..32, + ops: [ + In, + ], + operands: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 26..27, + id: Name("x"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 31..32, + id: Name("y"), + ctx: Load, + }, + ), + ], + runtime_comparators: None, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 35..36, + id: Name("z"), + ctx: Store, + }, + ), + ], + ctx: Store, + parenthesized: false, + runtime_elts: None, + }, + ), + iter: Name( + ExprName { + node_index: NodeIndex(None), + range: 40..41, + id: Name("w"), + ctx: Load, + }, + ), + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 43..46, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 43..46, + }, + ), + }, + ), + ], + orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | for x == y in z: ... + | ^^ Syntax Error: invalid syntax +2 | for (x in y), z in w: ... + | + + + | +1 | for x == y in z: ... +2 | for (x in y), z in w: ... + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap index 4868e5900595ec..b700a322772195 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap @@ -473,7 +473,7 @@ Module( | 1 | for 1 in x: ... - | ^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal 2 | for "a" in x: ... 3 | for *x and y in z: ... | @@ -482,7 +482,7 @@ Module( | 1 | for 1 in x: ... 2 | for "a" in x: ... - | ^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: cannot assign to literal 3 | for *x and y in z: ... 4 | for *x | y in z: ... | @@ -492,7 +492,7 @@ Module( 1 | for 1 in x: ... 2 | for "a" in x: ... 3 | for *x and y in z: ... - | ^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^ Syntax Error: cannot assign to expression 4 | for *x | y in z: ... 5 | for await x in z: ... | @@ -502,7 +502,7 @@ Module( 2 | for "a" in x: ... 3 | for *x and y in z: ... 4 | for *x | y in z: ... - | ^^^^^ Syntax Error: invalid assignment target + | ^^^^^ Syntax Error: cannot assign to expression 5 | for await x in z: ... 6 | for yield x in y: ... | @@ -512,7 +512,7 @@ Module( 3 | for *x and y in z: ... 4 | for *x | y in z: ... 5 | for await x in z: ... - | ^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^ Syntax Error: cannot assign to await expression 6 | for yield x in y: ... 7 | for [x, 1, y, *["a"]] in z: ... | @@ -540,14 +540,7 @@ Module( 5 | for await x in z: ... 6 | for yield x in y: ... 7 | for [x, 1, y, *["a"]] in z: ... - | ^ Syntax Error: invalid assignment target - - - | -5 | for await x in z: ... -6 | for yield x in y: ... -7 | for [x, 1, y, *["a"]] in z: ... - | ^^^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap index d0142929330e98..88baa07aa045ba 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_binary_expr.py.snap @@ -358,7 +358,7 @@ Module( | 1 | for x not in y in z: ... - | ^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: invalid syntax 2 | for x == y in z: ... 3 | for x or y in z: ... | @@ -367,7 +367,7 @@ Module( | 1 | for x not in y in z: ... 2 | for x == y in z: ... - | ^^^^^^ Syntax Error: invalid assignment target + | ^^ Syntax Error: invalid syntax 3 | for x or y in z: ... 4 | for -x in y: ... | @@ -377,7 +377,7 @@ Module( 1 | for x not in y in z: ... 2 | for x == y in z: ... 3 | for x or y in z: ... - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to expression 4 | for -x in y: ... 5 | for not x in y: ... | @@ -387,7 +387,7 @@ Module( 2 | for x == y in z: ... 3 | for x or y in z: ... 4 | for -x in y: ... - | ^^ Syntax Error: invalid assignment target + | ^^ Syntax Error: cannot assign to expression 5 | for not x in y: ... 6 | for x | y in z: ... | @@ -397,7 +397,7 @@ Module( 3 | for x or y in z: ... 4 | for -x in y: ... 5 | for not x in y: ... - | ^^^^^ Syntax Error: invalid assignment target + | ^^^^^ Syntax Error: cannot assign to expression 6 | for x | y in z: ... | @@ -406,4 +406,4 @@ Module( 4 | for -x in y: ... 5 | for not x in y: ... 6 | for x | y in z: ... - | ^^^^^ Syntax Error: invalid assignment target + | ^^^^^ Syntax Error: cannot assign to expression diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap index 4b3b5321714606..0fdd84ebcbdd5c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target_in_keyword.py.snap @@ -482,7 +482,7 @@ Module( | 1 | for d(x in y) in target: ... - | ^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^ Syntax Error: cannot assign to function call 2 | for (x in y)() in iter: ... 3 | for (x in y) in iter: ... | @@ -491,7 +491,7 @@ Module( | 1 | for d(x in y) in target: ... 2 | for (x in y)() in iter: ... - | ^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^ Syntax Error: cannot assign to function call 3 | for (x in y) in iter: ... 4 | for (x in y, z) in iter: ... | @@ -501,7 +501,7 @@ Module( 1 | for d(x in y) in target: ... 2 | for (x in y)() in iter: ... 3 | for (x in y) in iter: ... - | ^^^^^^ Syntax Error: invalid assignment target + | ^^ Syntax Error: invalid syntax 4 | for (x in y, z) in iter: ... 5 | for [x in y, z] in iter: ... | @@ -511,7 +511,7 @@ Module( 2 | for (x in y)() in iter: ... 3 | for (x in y) in iter: ... 4 | for (x in y, z) in iter: ... - | ^^^^^^ Syntax Error: invalid assignment target + | ^^ Syntax Error: invalid syntax 5 | for [x in y, z] in iter: ... 6 | for {x in y, z} in iter: ... | @@ -521,7 +521,7 @@ Module( 3 | for (x in y) in iter: ... 4 | for (x in y, z) in iter: ... 5 | for [x in y, z] in iter: ... - | ^^^^^^ Syntax Error: invalid assignment target + | ^^ Syntax Error: invalid syntax 6 | for {x in y, z} in iter: ... | @@ -530,4 +530,4 @@ Module( 4 | for (x in y, z) in iter: ... 5 | for [x in y, z] in iter: ... 6 | for {x in y, z} in iter: ... - | ^^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^^ Syntax Error: cannot assign to set display diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_invalid_asname.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_invalid_asname.py.snap new file mode 100644 index 00000000000000..1c5f452b47088f --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_alias_invalid_asname.py.snap @@ -0,0 +1,89 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/import_alias_invalid_asname.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..41, + body: [ + Import( + StmtImport { + node_index: NodeIndex(None), + range: 0..15, + names: [ + Alias { + range: 7..15, + node_index: NodeIndex(None), + name: Identifier { + id: Name("x"), + range: 7..8, + node_index: NodeIndex(None), + }, + asname: Some( + Identifier { + id: Name(""), + range: 12..15, + node_index: NodeIndex(None), + }, + ), + }, + ], + is_lazy: false, + }, + ), + ImportFrom( + StmtImportFrom { + node_index: NodeIndex(None), + range: 16..40, + module: Some( + Identifier { + id: Name("x"), + range: 21..22, + node_index: NodeIndex(None), + }, + ), + names: [ + Alias { + range: 31..39, + node_index: NodeIndex(None), + name: Identifier { + id: Name("y"), + range: 31..32, + node_index: NodeIndex(None), + }, + asname: Some( + Identifier { + id: Name(""), + range: 36..39, + node_index: NodeIndex(None), + }, + ), + }, + ], + level: 0, + is_lazy: false, + runtime_level: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | import x as y.z + | ^^^ Syntax Error: cannot use attribute as import target +2 | from x import (y as z()) + | + + + | +1 | import x as y.z +2 | from x import (y as z()) + | ^^^ Syntax Error: cannot use function call as import target diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap index 649c79fccae3a0..be6c694972b64c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_del_target.py.snap @@ -232,7 +232,7 @@ Module( | 1 | del x + 1 - | ^^^^^ Syntax Error: invalid syntax + | ^^^^^ Syntax Error: cannot delete expression 2 | del {'x': 1} 3 | del {'x', 'y'} | @@ -241,7 +241,7 @@ Module( | 1 | del x + 1 2 | del {'x': 1} - | ^^^^^^^^ Syntax Error: invalid syntax + | ^^^^^^^^ Syntax Error: cannot delete dict literal 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" | @@ -251,7 +251,7 @@ Module( 1 | del x + 1 2 | del {'x': 1} 3 | del {'x', 'y'} - | ^^^^^^^^^^ Syntax Error: invalid syntax + | ^^^^^^^^^^ Syntax Error: cannot delete set display 4 | del None, True, False, 1, 1.0, "abc" | @@ -260,39 +260,39 @@ Module( 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^^ Syntax Error: invalid syntax + | ^^^^ Syntax Error: cannot delete None | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^^ Syntax Error: invalid syntax + | ^^^^ Syntax Error: cannot delete True | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^^^ Syntax Error: invalid syntax + | ^^^^^ Syntax Error: cannot delete False | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: cannot delete literal | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^ Syntax Error: invalid syntax + | ^^^ Syntax Error: cannot delete literal | 2 | del {'x': 1} 3 | del {'x', 'y'} 4 | del None, True, False, 1, 1.0, "abc" - | ^^^^^ Syntax Error: invalid syntax + | ^^^^^ Syntax Error: cannot delete literal diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_as_pattern_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_as_pattern_invalid_target.py.snap new file mode 100644 index 00000000000000..017219643e6284 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_as_pattern_invalid_target.py.snap @@ -0,0 +1,156 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/match_as_pattern_invalid_target.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..55, + body: [ + Match( + StmtMatch { + node_index: NodeIndex(None), + range: 0..54, + subject: Name( + ExprName { + node_index: NodeIndex(None), + range: 6..7, + id: Name("x"), + ctx: Load, + }, + ), + cases: [ + MatchCase { + range: 13..31, + node_index: NodeIndex(None), + pattern: MatchAs( + PatternMatchAs { + node_index: NodeIndex(None), + range: 18..26, + pattern: Some( + MatchAs( + PatternMatchAs { + node_index: NodeIndex(None), + range: 18..19, + pattern: None, + name: Some( + Identifier { + id: Name("y"), + range: 18..19, + node_index: NodeIndex(None), + }, + ), + }, + ), + ), + name: Some( + Identifier { + id: Name(""), + range: 23..26, + node_index: NodeIndex(None), + }, + ), + }, + ), + guard: None, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 28..31, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 28..31, + }, + ), + }, + ), + ], + runtime_body: None, + }, + MatchCase { + range: 36..54, + node_index: NodeIndex(None), + pattern: MatchAs( + PatternMatchAs { + node_index: NodeIndex(None), + range: 41..49, + pattern: Some( + MatchAs( + PatternMatchAs { + node_index: NodeIndex(None), + range: 41..42, + pattern: None, + name: Some( + Identifier { + id: Name("y"), + range: 41..42, + node_index: NodeIndex(None), + }, + ), + }, + ), + ), + name: Some( + Identifier { + id: Name(""), + range: 46..49, + node_index: NodeIndex(None), + }, + ), + }, + ), + guard: None, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 51..54, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 51..54, + }, + ), + }, + ), + ], + runtime_body: None, + }, + ], + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | match x: +2 | case y as z.w: ... + | ^^^ Syntax Error: cannot use attribute as pattern target +3 | case y as f(): ... + | + + + | +1 | match x: +2 | case y as z.w: ... +3 | case y as f(): ... + | ^^^ Syntax Error: cannot use function call as pattern target + + +## Semantic Syntax Errors + + | +1 | match x: +2 | case y as z.w: ... + | ^ Syntax Error: name capture `y` makes remaining patterns unreachable +3 | case y as f(): ... + | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap index 40b653667d7d19..bca0dd356f2689 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_assignment_targets.py.snap @@ -1715,7 +1715,7 @@ Module( 3 | # rejected by the parser. e.g., `5 = 3`, `5 += 3`, `(5): int = 3`. 4 | 5 | 5 = 3 - | ^ Syntax Error: invalid assignment target + | ^ Syntax Error: cannot assign to literal here. Maybe you meant '==' instead of '='? 6 | 7 | 5 += 3 | @@ -1725,7 +1725,7 @@ Module( 5 | 5 = 3 6 | 7 | 5 += 3 - | ^ Syntax Error: invalid augmented assignment target + | ^ Syntax Error: 'literal' is an illegal expression for augmented assignment 8 | 9 | (5): int = 3 | @@ -1744,7 +1744,7 @@ Module( | 11 | # Now we exhaustively test all possible cases where assignment can fail. 12 | x or y = 42 - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to expression 13 | (x := 5) = 42 14 | x + y = 42 | @@ -1754,7 +1754,7 @@ Module( 11 | # Now we exhaustively test all possible cases where assignment can fail. 12 | x or y = 42 13 | (x := 5) = 42 - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to named expression here. Maybe you meant '==' instead of '='? 14 | x + y = 42 15 | -x = 42 | @@ -1764,7 +1764,7 @@ Module( 12 | x or y = 42 13 | (x := 5) = 42 14 | x + y = 42 - | ^^^^^ Syntax Error: invalid assignment target + | ^^^^^ Syntax Error: cannot assign to expression here. Maybe you meant '==' instead of '='? 15 | -x = 42 16 | (lambda _: 1) = 42 | @@ -1774,7 +1774,7 @@ Module( 13 | (x := 5) = 42 14 | x + y = 42 15 | -x = 42 - | ^^ Syntax Error: invalid assignment target + | ^^ Syntax Error: cannot assign to expression here. Maybe you meant '==' instead of '='? 16 | (lambda _: 1) = 42 17 | a if b else c = 42 | @@ -1784,7 +1784,7 @@ Module( 14 | x + y = 42 15 | -x = 42 16 | (lambda _: 1) = 42 - | ^^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^^ Syntax Error: cannot assign to lambda here. Maybe you meant '==' instead of '='? 17 | a if b else c = 42 18 | {"a": 5} = 42 | @@ -1794,7 +1794,7 @@ Module( 15 | -x = 42 16 | (lambda _: 1) = 42 17 | a if b else c = 42 - | ^^^^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^^^^ Syntax Error: cannot assign to conditional expression 18 | {"a": 5} = 42 19 | {a} = 42 | @@ -1804,7 +1804,7 @@ Module( 16 | (lambda _: 1) = 42 17 | a if b else c = 42 18 | {"a": 5} = 42 - | ^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^ Syntax Error: cannot assign to dict literal here. Maybe you meant '==' instead of '='? 19 | {a} = 42 20 | [x for x in xs] = 42 | @@ -1814,7 +1814,7 @@ Module( 17 | a if b else c = 42 18 | {"a": 5} = 42 19 | {a} = 42 - | ^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: cannot assign to set display here. Maybe you meant '==' instead of '='? 20 | [x for x in xs] = 42 21 | {x for x in xs} = 42 | @@ -1824,7 +1824,7 @@ Module( 18 | {"a": 5} = 42 19 | {a} = 42 20 | [x for x in xs] = 42 - | ^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: cannot assign to list comprehension here. Maybe you meant '==' instead of '='? 21 | {x for x in xs} = 42 22 | {x: x * 2 for x in xs} = 42 | @@ -1834,7 +1834,7 @@ Module( 19 | {a} = 42 20 | [x for x in xs] = 42 21 | {x for x in xs} = 42 - | ^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: cannot assign to set comprehension here. Maybe you meant '==' instead of '='? 22 | {x: x * 2 for x in xs} = 42 23 | (x for x in xs) = 42 | @@ -1844,7 +1844,7 @@ Module( 20 | [x for x in xs] = 42 21 | {x for x in xs} = 42 22 | {x: x * 2 for x in xs} = 42 - | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot assign to dict comprehension here. Maybe you meant '==' instead of '='? 23 | (x for x in xs) = 42 24 | await x = 42 | @@ -1854,7 +1854,7 @@ Module( 21 | {x for x in xs} = 42 22 | {x: x * 2 for x in xs} = 42 23 | (x for x in xs) = 42 - | ^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: cannot assign to generator expression 24 | await x = 42 25 | (yield x) = 42 | @@ -1864,7 +1864,7 @@ Module( 22 | {x: x * 2 for x in xs} = 42 23 | (x for x in xs) = 42 24 | await x = 42 - | ^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^ Syntax Error: cannot assign to await expression here. Maybe you meant '==' instead of '='? 25 | (yield x) = 42 26 | (yield from xs) = 42 | @@ -1874,7 +1874,7 @@ Module( 23 | (x for x in xs) = 42 24 | await x = 42 25 | (yield x) = 42 - | ^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^ Syntax Error: cannot assign to yield expression here. Maybe you meant '==' instead of '='? 26 | (yield from xs) = 42 27 | a < b < c = 42 | @@ -1884,7 +1884,7 @@ Module( 24 | await x = 42 25 | (yield x) = 42 26 | (yield from xs) = 42 - | ^^^^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^^^^ Syntax Error: cannot assign to yield expression here. Maybe you meant '==' instead of '='? 27 | a < b < c = 42 28 | foo() = 42 | @@ -1894,7 +1894,7 @@ Module( 25 | (yield x) = 42 26 | (yield from xs) = 42 27 | a < b < c = 42 - | ^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^ Syntax Error: cannot assign to comparison 28 | foo() = 42 | @@ -1903,7 +1903,7 @@ Module( 26 | (yield from xs) = 42 27 | a < b < c = 42 28 | foo() = 42 - | ^^^^^ Syntax Error: invalid assignment target + | ^^^^^ Syntax Error: cannot assign to function call here. Maybe you meant '==' instead of '='? 29 | 30 | f"{quux}" = 42 | @@ -1913,7 +1913,7 @@ Module( 28 | foo() = 42 29 | 30 | f"{quux}" = 42 - | ^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^ Syntax Error: cannot assign to f-string expression here. Maybe you meant '==' instead of '='? 31 | f"{foo} and {bar}" = 42 | @@ -1921,7 +1921,7 @@ Module( | 30 | f"{quux}" = 42 31 | f"{foo} and {bar}" = 42 - | ^^^^^^^^^^^^^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^^^^^^^^^^^^^ Syntax Error: cannot assign to f-string expression here. Maybe you meant '==' instead of '='? 32 | 33 | "foo" = 42 | @@ -1931,7 +1931,7 @@ Module( 31 | f"{foo} and {bar}" = 42 32 | 33 | "foo" = 42 - | ^^^^^ Syntax Error: invalid assignment target + | ^^^^^ Syntax Error: cannot assign to literal here. Maybe you meant '==' instead of '='? 34 | b"foo" = 42 35 | 123 = 42 | @@ -1940,7 +1940,7 @@ Module( | 33 | "foo" = 42 34 | b"foo" = 42 - | ^^^^^^ Syntax Error: invalid assignment target + | ^^^^^^ Syntax Error: cannot assign to literal here. Maybe you meant '==' instead of '='? 35 | 123 = 42 36 | True = 42 | @@ -1950,7 +1950,7 @@ Module( 33 | "foo" = 42 34 | b"foo" = 42 35 | 123 = 42 - | ^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: cannot assign to literal here. Maybe you meant '==' instead of '='? 36 | True = 42 37 | None = 42 | @@ -1960,7 +1960,7 @@ Module( 34 | b"foo" = 42 35 | 123 = 42 36 | True = 42 - | ^^^^ Syntax Error: invalid assignment target + | ^^^^ Syntax Error: cannot assign to True 37 | None = 42 38 | ... = 42 | @@ -1970,7 +1970,7 @@ Module( 35 | 123 = 42 36 | True = 42 37 | None = 42 - | ^^^^ Syntax Error: invalid assignment target + | ^^^^ Syntax Error: cannot assign to None 38 | ... = 42 39 | *foo() = 42 | @@ -1980,7 +1980,7 @@ Module( 36 | True = 42 37 | None = 42 38 | ... = 42 - | ^^^ Syntax Error: invalid assignment target + | ^^^ Syntax Error: cannot assign to ellipsis here. Maybe you meant '==' instead of '='? 39 | *foo() = 42 40 | [x, foo(), y] = [42, 42, 42] | @@ -1990,7 +1990,7 @@ Module( 37 | None = 42 38 | ... = 42 39 | *foo() = 42 - | ^^^^^ Syntax Error: invalid assignment target + | ^^^^^ Syntax Error: cannot assign to function call 40 | [x, foo(), y] = [42, 42, 42] 41 | [[a, b], [[42]], d] = [[1, 2], [[3]], 4] | @@ -2000,7 +2000,7 @@ Module( 38 | ... = 42 39 | *foo() = 42 40 | [x, foo(), y] = [42, 42, 42] - | ^^^^^ Syntax Error: invalid assignment target + | ^^^^^ Syntax Error: cannot assign to function call 41 | [[a, b], [[42]], d] = [[1, 2], [[3]], 4] 42 | (x, foo(), y) = (42, 42, 42) | @@ -2010,7 +2010,7 @@ Module( 39 | *foo() = 42 40 | [x, foo(), y] = [42, 42, 42] 41 | [[a, b], [[42]], d] = [[1, 2], [[3]], 4] - | ^^ Syntax Error: invalid assignment target + | ^^ Syntax Error: cannot assign to literal 42 | (x, foo(), y) = (42, 42, 42) | @@ -2019,7 +2019,7 @@ Module( 40 | [x, foo(), y] = [42, 42, 42] 41 | [[a, b], [[42]], d] = [[1, 2], [[3]], 4] 42 | (x, foo(), y) = (42, 42, 42) - | ^^^^^ Syntax Error: invalid assignment target + | ^^^^^ Syntax Error: cannot assign to function call ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap index 6ce032a501f159..773c008590dfe9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__invalid_augmented_assignment_target.py.snap @@ -1509,7 +1509,7 @@ Module( 2 | # assignment targets. 3 | 4 | x or y += 42 - | ^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^ Syntax Error: 'expression' is an illegal expression for augmented assignment 5 | (x := 5) += 42 6 | x + y += 42 | @@ -1518,7 +1518,7 @@ Module( | 4 | x or y += 42 5 | (x := 5) += 42 - | ^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^ Syntax Error: 'named expression' is an illegal expression for augmented assignment 6 | x + y += 42 7 | -x += 42 | @@ -1528,7 +1528,7 @@ Module( 4 | x or y += 42 5 | (x := 5) += 42 6 | x + y += 42 - | ^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^ Syntax Error: 'expression' is an illegal expression for augmented assignment 7 | -x += 42 8 | (lambda _: 1) += 42 | @@ -1538,7 +1538,7 @@ Module( 5 | (x := 5) += 42 6 | x + y += 42 7 | -x += 42 - | ^^ Syntax Error: invalid augmented assignment target + | ^^ Syntax Error: 'expression' is an illegal expression for augmented assignment 8 | (lambda _: 1) += 42 9 | a if b else c += 42 | @@ -1548,7 +1548,7 @@ Module( 6 | x + y += 42 7 | -x += 42 8 | (lambda _: 1) += 42 - | ^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^ Syntax Error: 'lambda' is an illegal expression for augmented assignment 9 | a if b else c += 42 10 | {"a": 5} += 42 | @@ -1558,7 +1558,7 @@ Module( 7 | -x += 42 8 | (lambda _: 1) += 42 9 | a if b else c += 42 - | ^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^ Syntax Error: 'conditional expression' is an illegal expression for augmented assignment 10 | {"a": 5} += 42 11 | {a} += 42 | @@ -1568,7 +1568,7 @@ Module( 8 | (lambda _: 1) += 42 9 | a if b else c += 42 10 | {"a": 5} += 42 - | ^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^ Syntax Error: 'dict literal' is an illegal expression for augmented assignment 11 | {a} += 42 12 | [x for x in xs] += 42 | @@ -1578,7 +1578,7 @@ Module( 9 | a if b else c += 42 10 | {"a": 5} += 42 11 | {a} += 42 - | ^^^ Syntax Error: invalid augmented assignment target + | ^^^ Syntax Error: 'set display' is an illegal expression for augmented assignment 12 | [x for x in xs] += 42 13 | {x for x in xs} += 42 | @@ -1588,7 +1588,7 @@ Module( 10 | {"a": 5} += 42 11 | {a} += 42 12 | [x for x in xs] += 42 - | ^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: 'list comprehension' is an illegal expression for augmented assignment 13 | {x for x in xs} += 42 14 | {x: x * 2 for x in xs} += 42 | @@ -1598,7 +1598,7 @@ Module( 11 | {a} += 42 12 | [x for x in xs] += 42 13 | {x for x in xs} += 42 - | ^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: 'set comprehension' is an illegal expression for augmented assignment 14 | {x: x * 2 for x in xs} += 42 15 | (x for x in xs) += 42 | @@ -1608,7 +1608,7 @@ Module( 12 | [x for x in xs] += 42 13 | {x for x in xs} += 42 14 | {x: x * 2 for x in xs} += 42 - | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: 'dict comprehension' is an illegal expression for augmented assignment 15 | (x for x in xs) += 42 16 | await x += 42 | @@ -1618,7 +1618,7 @@ Module( 13 | {x for x in xs} += 42 14 | {x: x * 2 for x in xs} += 42 15 | (x for x in xs) += 42 - | ^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^^^ Syntax Error: 'generator expression' is an illegal expression for augmented assignment 16 | await x += 42 17 | (yield x) += 42 | @@ -1628,7 +1628,7 @@ Module( 14 | {x: x * 2 for x in xs} += 42 15 | (x for x in xs) += 42 16 | await x += 42 - | ^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^ Syntax Error: 'await expression' is an illegal expression for augmented assignment 17 | (yield x) += 42 18 | (yield from xs) += 42 | @@ -1638,7 +1638,7 @@ Module( 15 | (x for x in xs) += 42 16 | await x += 42 17 | (yield x) += 42 - | ^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^ Syntax Error: 'yield expression' is an illegal expression for augmented assignment 18 | (yield from xs) += 42 19 | a < b < c += 42 | @@ -1648,7 +1648,7 @@ Module( 16 | await x += 42 17 | (yield x) += 42 18 | (yield from xs) += 42 - | ^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^ Syntax Error: 'yield expression' is an illegal expression for augmented assignment 19 | a < b < c += 42 20 | foo() += 42 | @@ -1658,7 +1658,7 @@ Module( 17 | (yield x) += 42 18 | (yield from xs) += 42 19 | a < b < c += 42 - | ^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^ Syntax Error: 'comparison' is an illegal expression for augmented assignment 20 | foo() += 42 | @@ -1667,7 +1667,7 @@ Module( 18 | (yield from xs) += 42 19 | a < b < c += 42 20 | foo() += 42 - | ^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^ Syntax Error: 'function call' is an illegal expression for augmented assignment 21 | 22 | f"{quux}" += 42 | @@ -1677,7 +1677,7 @@ Module( 20 | foo() += 42 21 | 22 | f"{quux}" += 42 - | ^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^ Syntax Error: 'f-string expression' is an illegal expression for augmented assignment 23 | f"{foo} and {bar}" += 42 | @@ -1685,7 +1685,7 @@ Module( | 22 | f"{quux}" += 42 23 | f"{foo} and {bar}" += 42 - | ^^^^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^^^^^^ Syntax Error: 'f-string expression' is an illegal expression for augmented assignment 24 | 25 | "foo" += 42 | @@ -1695,7 +1695,7 @@ Module( 23 | f"{foo} and {bar}" += 42 24 | 25 | "foo" += 42 - | ^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^ Syntax Error: 'literal' is an illegal expression for augmented assignment 26 | b"foo" += 42 27 | 123 += 42 | @@ -1704,7 +1704,7 @@ Module( | 25 | "foo" += 42 26 | b"foo" += 42 - | ^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^ Syntax Error: 'literal' is an illegal expression for augmented assignment 27 | 123 += 42 28 | True += 42 | @@ -1714,7 +1714,7 @@ Module( 25 | "foo" += 42 26 | b"foo" += 42 27 | 123 += 42 - | ^^^ Syntax Error: invalid augmented assignment target + | ^^^ Syntax Error: 'literal' is an illegal expression for augmented assignment 28 | True += 42 29 | None += 42 | @@ -1724,7 +1724,7 @@ Module( 26 | b"foo" += 42 27 | 123 += 42 28 | True += 42 - | ^^^^ Syntax Error: invalid augmented assignment target + | ^^^^ Syntax Error: 'True' is an illegal expression for augmented assignment 29 | None += 42 30 | ... += 42 | @@ -1734,7 +1734,7 @@ Module( 27 | 123 += 42 28 | True += 42 29 | None += 42 - | ^^^^ Syntax Error: invalid augmented assignment target + | ^^^^ Syntax Error: 'None' is an illegal expression for augmented assignment 30 | ... += 42 31 | *foo() += 42 | @@ -1744,7 +1744,7 @@ Module( 28 | True += 42 29 | None += 42 30 | ... += 42 - | ^^^ Syntax Error: invalid augmented assignment target + | ^^^ Syntax Error: 'ellipsis' is an illegal expression for augmented assignment 31 | *foo() += 42 32 | [x, foo(), y] += [42, 42, 42] | @@ -1754,7 +1754,7 @@ Module( 29 | None += 42 30 | ... += 42 31 | *foo() += 42 - | ^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^ Syntax Error: 'starred' is an illegal expression for augmented assignment 32 | [x, foo(), y] += [42, 42, 42] 33 | [[a, b], [[42]], d] += [[1, 2], [[3]], 4] | @@ -1764,7 +1764,7 @@ Module( 30 | ... += 42 31 | *foo() += 42 32 | [x, foo(), y] += [42, 42, 42] - | ^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^ Syntax Error: 'list' is an illegal expression for augmented assignment 33 | [[a, b], [[42]], d] += [[1, 2], [[3]], 4] 34 | (x, foo(), y) += (42, 42, 42) | @@ -1774,7 +1774,7 @@ Module( 31 | *foo() += 42 32 | [x, foo(), y] += [42, 42, 42] 33 | [[a, b], [[42]], d] += [[1, 2], [[3]], 4] - | ^^^^^^^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^^^^^^^ Syntax Error: 'list' is an illegal expression for augmented assignment 34 | (x, foo(), y) += (42, 42, 42) | @@ -1783,4 +1783,4 @@ Module( 32 | [x, foo(), y] += [42, 42, 42] 33 | [[a, b], [[42]], d] += [[1, 2], [[3]], 4] 34 | (x, foo(), y) += (42, 42, 42) - | ^^^^^^^^^^^^^ Syntax Error: invalid augmented assignment target + | ^^^^^^^^^^^^^ Syntax Error: 'tuple' is an illegal expression for augmented assignment diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap index 4b4a5d457dbe2a..4d6f4fe11199f6 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__match__invalid_class_pattern.py.snap @@ -405,6 +405,16 @@ Module( ``` ## Errors + | +1 | # Invalid keyword pattern in class argument +2 | match subject: +3 | case Foo(x as y = 1): + | ^ Syntax Error: cannot use name as pattern target +4 | pass +5 | case Foo(x | y = 1): + | + + | 1 | # Invalid keyword pattern in class argument 2 | match subject: From 36919b62fa1b32c57b429de93c7aa0f4b2572164 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 5 Oct 2026 04:20:46 +0900 Subject: [PATCH 13/20] Report parameter, argument, star and dictionary errors with CPython messages - Parameters: missing default values, `**kwargs` defaults, repeated `*`, bare `*` ranges, parenthesized parameters, missing comma between `/` and `*`, and bounds or constraints on TypeVarTuple and ParamSpec. - Arguments: invalid keyword names, `**x=` and `*x=` assignments, missing keyword values, keyword values followed by `for`, and the positions of ordering errors. - Stars: `*` without an expression at the start of a display, argument or slice, and parenthesized `*x` and `**x`. - Missing commas between expressions inside brackets. - Dictionaries: missing `:` after a later key (new `ExpectedColonAfterDictionaryKey`), missing values and starred values. Assisted-by: Claude Code:claude-opus-5-5 --- .../inline/err/args_invalid_keyword_name.py | 3 + .../inline/err/args_keyword_generator.py | 1 + .../err/args_keyword_unpacking_assignment.py | 1 + .../inline/err/args_missing_keyword_value.py | 2 + .../err/args_parenthesized_keyword_name.py | 1 + .../err/args_positional_after_keyword.py | 2 + .../err/dict_missing_colon_after_key.py | 3 + .../inline/err/dict_missing_value.py | 2 + .../inline/err/dict_starred_value.py | 2 + .../err/missing_comma_between_expressions.py | 4 + .../inline/err/params_parenthesized.py | 3 + .../params_star_after_slash_without_comma.py | 2 + .../err/parenthesized_double_starred_expr.py | 1 + .../inline/err/parenthesized_starred_expr.py | 1 + .../starred_missing_expression_in_brackets.py | 2 + crates/ruff_python_parser/src/error.rs | 11 + .../src/parser/expression.rs | 353 ++++++++++++++++-- crates/ruff_python_parser/src/parser/mod.rs | 93 ++++- .../src/parser/statement.rs | 214 ++++++++--- ...d_syntax@args_invalid_keyword_name.py.snap | 187 ++++++++++ ...alid_syntax@args_keyword_generator.py.snap | 114 ++++++ ...@args_keyword_unpacking_assignment.py.snap | 65 ++++ ..._syntax@args_missing_keyword_value.py.snap | 162 ++++++++ ...ax@args_parenthesized_keyword_name.py.snap | 78 ++++ ...ntax@args_positional_after_keyword.py.snap | 152 ++++++++ ...unparenthesized_generator_argument.py.snap | 2 +- ...ntax@comma_separated_missing_comma.py.snap | 2 +- ...ted_missing_comma_between_elements.py.snap | 6 + ...yntax@decorator_invalid_expression.py.snap | 4 +- ...yntax@dict_missing_colon_after_key.py.snap | 281 ++++++++++++++ .../invalid_syntax@dict_missing_value.py.snap | 155 ++++++++ .../invalid_syntax@dict_starred_value.py.snap | 121 ++++++ ...essions__arguments__double_starred.py.snap | 2 +- ...ons__arguments__invalid_expression.py.snap | 4 +- ...uments__invalid_keyword_expression.py.snap | 2 +- ...ressions__arguments__invalid_order.py.snap | 17 +- ...ressions__arguments__missing_comma.py.snap | 5 + ...ons__arguments__missing_expression.py.snap | 10 +- ...syntax@expressions__await__recover.py.snap | 2 +- ...tax@expressions__dict__double_star.py.snap | 10 + ...ressions__dict__named_expression_0.py.snap | 10 + ...ressions__dict__named_expression_1.py.snap | 20 + ..._syntax@expressions__dict__recover.py.snap | 52 +-- ...sions__lambda_duplicate_parameters.py.snap | 2 +- ..._syntax@expressions__list__recover.py.snap | 11 +- ...__list__star_expression_precedence.py.snap | 2 +- ...ions__parenthesized__parenthesized.py.snap | 2 +- ...@expressions__parenthesized__tuple.py.snap | 27 ++ ...d_syntax@expressions__set__recover.py.snap | 11 +- ...s__set__star_expression_precedence.py.snap | 2 +- ...sions__subscript__unclosed_slice_1.py.snap | 18 + ...xpressions__yield__star_expression.py.snap | 2 +- ...x@function_def_invalid_return_expr.py.snap | 2 +- ...nction_def_unclosed_parameter_list.py.snap | 9 + ...ntax@match_stmt_invalid_guard_expr.py.snap | 2 +- ...ax@match_stmt_invalid_subject_expr.py.snap | 2 +- ...@missing_comma_between_expressions.py.snap | 345 +++++++++++++++++ ...valid_syntax@param_missing_default.py.snap | 4 +- ..._syntax@param_with_invalid_default.py.snap | 2 +- ...param_with_invalid_star_annotation.py.snap | 2 +- ...rams_expected_after_star_separator.py.snap | 2 +- ...@params_kwarg_after_star_separator.py.snap | 2 +- ...tax@params_multiple_star_separator.py.snap | 4 +- ...lid_syntax@params_multiple_varargs.py.snap | 6 +- ...nvalid_syntax@params_parenthesized.py.snap | 304 +++++++++++++++ ...ams_star_after_slash_without_comma.py.snap | 175 +++++++++ ...ms_star_separator_after_star_param.py.snap | 4 +- ...ax@params_var_keyword_with_default.py.snap | 2 +- ...params_var_positional_with_default.py.snap | 20 +- ...@parenthesized_double_starred_expr.py.snap | 36 ++ ...id_syntax@parenthesized_kwarg_py38.py.snap | 27 ++ ..._syntax@parenthesized_starred_expr.py.snap | 43 +++ ...ict_unpacking_comprehensions_py315.py.snap | 17 +- ...x@re_lexing__fstring_format_spec_1.py.snap | 19 + ...re_lexing__triple_quoted_fstring_1.py.snap | 15 +- .../invalid_syntax@re_lexing__ty_1828.py.snap | 21 ++ ...red_missing_expression_in_brackets.py.snap | 122 ++++++ ..._syntax@starred_starred_expression.py.snap | 4 +- ...s__with__ambiguous_lpar_with_items.py.snap | 6 +- ...syntax@type_param_param_spec_bound.py.snap | 46 +-- ...ax@type_param_type_var_tuple_bound.py.snap | 46 +-- ...erminated_fstring_newline_recovery.py.snap | 12 + ..._items_parenthesized_missing_comma.py.snap | 36 ++ 83 files changed, 3322 insertions(+), 256 deletions(-) create mode 100644 crates/ruff_python_parser/resources/inline/err/args_invalid_keyword_name.py create mode 100644 crates/ruff_python_parser/resources/inline/err/args_keyword_generator.py create mode 100644 crates/ruff_python_parser/resources/inline/err/args_keyword_unpacking_assignment.py create mode 100644 crates/ruff_python_parser/resources/inline/err/args_missing_keyword_value.py create mode 100644 crates/ruff_python_parser/resources/inline/err/args_parenthesized_keyword_name.py create mode 100644 crates/ruff_python_parser/resources/inline/err/args_positional_after_keyword.py create mode 100644 crates/ruff_python_parser/resources/inline/err/dict_missing_colon_after_key.py create mode 100644 crates/ruff_python_parser/resources/inline/err/dict_missing_value.py create mode 100644 crates/ruff_python_parser/resources/inline/err/dict_starred_value.py create mode 100644 crates/ruff_python_parser/resources/inline/err/missing_comma_between_expressions.py create mode 100644 crates/ruff_python_parser/resources/inline/err/params_parenthesized.py create mode 100644 crates/ruff_python_parser/resources/inline/err/params_star_after_slash_without_comma.py create mode 100644 crates/ruff_python_parser/resources/inline/err/parenthesized_double_starred_expr.py create mode 100644 crates/ruff_python_parser/resources/inline/err/parenthesized_starred_expr.py create mode 100644 crates/ruff_python_parser/resources/inline/err/starred_missing_expression_in_brackets.py create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_invalid_keyword_name.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_keyword_generator.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_keyword_unpacking_assignment.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_missing_keyword_value.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_parenthesized_keyword_name.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_positional_after_keyword.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_missing_colon_after_key.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_missing_value.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_starred_value.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_between_expressions.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_parenthesized.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash_without_comma.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_double_starred_expr.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_starred_expr.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_missing_expression_in_brackets.py.snap diff --git a/crates/ruff_python_parser/resources/inline/err/args_invalid_keyword_name.py b/crates/ruff_python_parser/resources/inline/err/args_invalid_keyword_name.py new file mode 100644 index 00000000000000..29e331688b88c7 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/args_invalid_keyword_name.py @@ -0,0 +1,3 @@ +f(a.b=1) +f(True=1) +f(*a=1) diff --git a/crates/ruff_python_parser/resources/inline/err/args_keyword_generator.py b/crates/ruff_python_parser/resources/inline/err/args_keyword_generator.py new file mode 100644 index 00000000000000..6dde52f2b4e22a --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/args_keyword_generator.py @@ -0,0 +1 @@ +f(a=x for x in y) diff --git a/crates/ruff_python_parser/resources/inline/err/args_keyword_unpacking_assignment.py b/crates/ruff_python_parser/resources/inline/err/args_keyword_unpacking_assignment.py new file mode 100644 index 00000000000000..1764568463b4d2 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/args_keyword_unpacking_assignment.py @@ -0,0 +1 @@ +f(**a=1) diff --git a/crates/ruff_python_parser/resources/inline/err/args_missing_keyword_value.py b/crates/ruff_python_parser/resources/inline/err/args_missing_keyword_value.py new file mode 100644 index 00000000000000..47d1f08a7b205e --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/args_missing_keyword_value.py @@ -0,0 +1,2 @@ +f(a=) +f(a, b=, c) diff --git a/crates/ruff_python_parser/resources/inline/err/args_parenthesized_keyword_name.py b/crates/ruff_python_parser/resources/inline/err/args_parenthesized_keyword_name.py new file mode 100644 index 00000000000000..1e1207aa414b06 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/args_parenthesized_keyword_name.py @@ -0,0 +1 @@ +f((a)=1) diff --git a/crates/ruff_python_parser/resources/inline/err/args_positional_after_keyword.py b/crates/ruff_python_parser/resources/inline/err/args_positional_after_keyword.py new file mode 100644 index 00000000000000..cfafe7e7745ea6 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/args_positional_after_keyword.py @@ -0,0 +1,2 @@ +f(a=1, b) +f(**a, b, **c) diff --git a/crates/ruff_python_parser/resources/inline/err/dict_missing_colon_after_key.py b/crates/ruff_python_parser/resources/inline/err/dict_missing_colon_after_key.py new file mode 100644 index 00000000000000..809a28071f4538 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/dict_missing_colon_after_key.py @@ -0,0 +1,3 @@ +{a: 1, b} +{a: 1, b c: 2} +{**a, b + c} diff --git a/crates/ruff_python_parser/resources/inline/err/dict_missing_value.py b/crates/ruff_python_parser/resources/inline/err/dict_missing_value.py new file mode 100644 index 00000000000000..925407e867387a --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/dict_missing_value.py @@ -0,0 +1,2 @@ +{a: } +{a: 1, b: , c: 2} diff --git a/crates/ruff_python_parser/resources/inline/err/dict_starred_value.py b/crates/ruff_python_parser/resources/inline/err/dict_starred_value.py new file mode 100644 index 00000000000000..f345f63df8da7f --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/dict_starred_value.py @@ -0,0 +1,2 @@ +{a: *b} +{a: 1, b: *c} diff --git a/crates/ruff_python_parser/resources/inline/err/missing_comma_between_expressions.py b/crates/ruff_python_parser/resources/inline/err/missing_comma_between_expressions.py new file mode 100644 index 00000000000000..633843284c832b --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/missing_comma_between_expressions.py @@ -0,0 +1,4 @@ +[a b] +f(x, a.b c) +x[1 + 2 3] +f"{a b}" diff --git a/crates/ruff_python_parser/resources/inline/err/params_parenthesized.py b/crates/ruff_python_parser/resources/inline/err/params_parenthesized.py new file mode 100644 index 00000000000000..c0d60ed64b50d1 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/params_parenthesized.py @@ -0,0 +1,3 @@ +def foo(a, (b, c)): ... +def foo((a)): ... +lambda (a,): ... diff --git a/crates/ruff_python_parser/resources/inline/err/params_star_after_slash_without_comma.py b/crates/ruff_python_parser/resources/inline/err/params_star_after_slash_without_comma.py new file mode 100644 index 00000000000000..14cd9e999c94d8 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/params_star_after_slash_without_comma.py @@ -0,0 +1,2 @@ +def foo(a, /*, b): ... +lambda a, /*, b: ... diff --git a/crates/ruff_python_parser/resources/inline/err/parenthesized_double_starred_expr.py b/crates/ruff_python_parser/resources/inline/err/parenthesized_double_starred_expr.py new file mode 100644 index 00000000000000..ddbdc295d32d97 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/parenthesized_double_starred_expr.py @@ -0,0 +1 @@ +(**x) diff --git a/crates/ruff_python_parser/resources/inline/err/parenthesized_starred_expr.py b/crates/ruff_python_parser/resources/inline/err/parenthesized_starred_expr.py new file mode 100644 index 00000000000000..1eedfe39c394f9 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/parenthesized_starred_expr.py @@ -0,0 +1 @@ +(*x) diff --git a/crates/ruff_python_parser/resources/inline/err/starred_missing_expression_in_brackets.py b/crates/ruff_python_parser/resources/inline/err/starred_missing_expression_in_brackets.py new file mode 100644 index 00000000000000..8a70988fab4f02 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/starred_missing_expression_in_brackets.py @@ -0,0 +1,2 @@ +f(x, *) +[*, 1] diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index 11b4260e6a84cd..0e11515d0f82fd 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -171,6 +171,11 @@ pub enum ParseErrorType { NonDefaultParamAfterDefaultParam, /// A default value was found for a `*` or `**` parameter. VarParameterWithDefault, + /// A default value was found for a `**` parameter. + VarKeywordParameterWithDefault, + /// A dictionary key after the first item is not followed by a `:`. The error range is the + /// last character of the key. + ExpectedColonAfterDictionaryKey, /// An invalid expression was found in the assignment target. `maybe_comparison` is set when /// the `=` after it may have been meant as `==`. @@ -491,6 +496,12 @@ impl std::fmt::Display for ParseErrorType { ParseErrorType::ExpectedKeywordParam => { f.write_str("named arguments must follow bare *") } + ParseErrorType::VarKeywordParameterWithDefault => { + f.write_str("var-keyword argument cannot have default value") + } + ParseErrorType::ExpectedColonAfterDictionaryKey => { + f.write_str("':' expected after dictionary key") + } ParseErrorType::VarParameterWithDefault => { f.write_str("var-positional argument cannot have default value") } diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 8b68ca49d50b9d..9e308a2055b339 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -8,7 +8,7 @@ use ruff_python_ast::token::TokenKind; use ruff_python_ast::{ self as ast, AnyStringFlags, AtomicNodeIndex, BoolOp, CmpOp, ConversionFlag, Expr, ExprContext, FString, InterpolatedStringElement, InterpolatedStringElements, IpyEscapeKind, Number, - Operator, OperatorPrecedence, StringFlags, TString, UnaryOp, + Operator, OperatorPrecedence, PythonVersion, StringFlags, TString, UnaryOp, }; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; @@ -23,11 +23,15 @@ use crate::string::{ }; use crate::token_set::TokenSet; use crate::{ - ExpressionKind, InterpolatedStringErrorType, Mode, ParseErrorType, UnsupportedSyntaxError, - UnsupportedSyntaxErrorKind, + ExpressionKind, InterpolatedStringErrorType, Mode, ParseError, ParseErrorType, + UnsupportedSyntaxError, UnsupportedSyntaxErrorKind, }; -use super::{InterpolatedStringElementsKind, Parenthesized, RecoveryContextKind}; +use super::{Bracket, InterpolatedStringElementsKind, Parenthesized, RecoveryContextKind}; + +/// The message for a keyword argument whose name is not a plain name. +const EXPRESSION_CONTAINS_ASSIGNMENT: &str = + "expression cannot contain assignment, perhaps you meant \"==\"?"; /// A token set consisting of a newline or end of file. const NEWLINE_EOF_SET: TokenSet = TokenSet::new([TokenKind::Newline, TokenKind::EndOfFile]); @@ -208,6 +212,15 @@ impl<'src> Parser<'src> { pub(super) fn parse_conditional_expression_or_higher_impl( &mut self, context: ExpressionContext, + ) -> ParsedExpr { + let parsed_expr = self.parse_conditional_expression_without_comma_check(context); + self.check_missing_comma(&parsed_expr); + parsed_expr + } + + fn parse_conditional_expression_without_comma_check( + &mut self, + context: ExpressionContext, ) -> ParsedExpr { if self.at(TokenKind::Lambda) { Expr::Lambda(self.parse_lambda_expr()).into() @@ -223,6 +236,62 @@ impl<'src> Parser<'src> { } } + /// Reports a missing comma when an expression inside brackets is directly followed by + /// another expression. + /// + /// The error is not reported when the first expression is a name followed by a string (an + /// invalid string prefix), starts with a soft keyword (including `_`), or is the name `print` + /// or `exec`. + fn check_missing_comma(&mut self, first: &ParsedExpr) { + // test_err missing_comma_between_expressions + // [a b] + // f(x, a.b c) + // x[1 + 2 3] + // f"{a b}" + if !self.at_expr() + || self.at(TokenKind::Yield) + || matches!( + first.expr, + Expr::Starred(_) + | Expr::Yield(_) + | Expr::YieldFrom(_) + | Expr::Lambda(_) + | Expr::If(_) + | Expr::Named(_) + ) + { + return; + } + if let Expr::Name(name) = &first.expr { + if !first.is_parenthesized + && (matches!(name.id.as_str(), "print" | "exec") + || matches!( + self.current_token_kind(), + TokenKind::String | TokenKind::FStringStart | TokenKind::TStringStart + )) + { + return; + } + } + // Soft keywords are bumped as names. + let (first_kind, first_range) = self.token_after(first.start()); + if (first_kind == TokenKind::Identifier + && matches!(self.src_text(first_range), "_" | "case" | "match" | "type")) + || self.bracket_level() == 0 + { + return; + } + + let checkpoint = self.checkpoint(); + let second = self.parse_conditional_expression_or_higher(); + let range = TextRange::new(first.start(), second.end()); + self.rewind(checkpoint); + self.add_error( + ParseErrorType::OtherError("invalid syntax. Perhaps you forgot a comma?".to_string()), + range, + ); + } + /// Parses every Python expression except unparenthesized tuples, named expressions, /// and `if` expression. /// @@ -433,7 +502,8 @@ impl<'src> Parser<'src> { /// /// [Python grammar]: https://docs.python.org/3/reference/grammar.html fn parse_expression_with_bitwise_or_precedence(&mut self) -> ParsedExpr { - let parsed_expr = self.parse_conditional_expression_or_higher(); + let parsed_expr = + self.parse_conditional_expression_without_comma_check(ExpressionContext::default()); if parsed_expr.is_parenthesized { // Parentheses resets the precedence, so we don't need to validate it. @@ -739,12 +809,27 @@ impl<'src> Parser<'src> { let keywords_snapshot = self.keyword_scratch.snapshot(); let mut seen_keyword_argument = false; // foo = 1 let mut seen_keyword_unpacking = false; // **foo + // The first positional argument after a keyword argument, reported where the arguments + // end, and the number of errors before it. + let mut positional_after_keyword: Option<(ParseErrorType, usize)> = None; let has_trailing_comma = self.parse_comma_separated_list(RecoveryContextKind::Arguments, |parser| { let argument_start = parser.node_start(); if parser.eat(TokenKind::DoubleStar) { - let value = parser.parse_conditional_expression_or_higher(); + let mut value = parser.parse_conditional_expression_or_higher(); + + if parser.eat(TokenKind::Equal) { + // test_err args_keyword_unpacking_assignment + // f(**a=1) + value = parser.parse_conditional_expression_or_higher(); + parser.add_error( + ParseErrorType::OtherError( + "cannot assign to keyword argument unpacking".to_string(), + ), + TextRange::new(argument_start, value.end()), + ); + } parser.keyword_scratch.push(ast::Keyword { arg: None, @@ -781,17 +866,39 @@ impl<'src> Parser<'src> { if seen_keyword_unpacking && parsed_expr.is_unparenthesized_starred_expr() { + // The error starts at the comma before the argument. + let start = parser + .token_before(parsed_expr.start()) + .filter(|(kind, _)| *kind == TokenKind::Comma) + .map_or(parsed_expr.start(), |(_, range)| range.start()); parser.add_error( ParseErrorType::InvalidArgumentUnpackingOrder, - &parsed_expr, + TextRange::new(start, parsed_expr.end()), ); } } } let arg_range = parser.node_range(start); + let equal_range = parser.current_token_range(); if parser.eat(TokenKind::Equal) { seen_keyword_argument = true; + let keyword_target_range = + TextRange::new(parsed_expr.start(), equal_range.end()); + if parsed_expr.is_parenthesized + && parsed_expr.is_name_expr() + && parser.options.target_version >= PythonVersion::PY38 + { + // test_err args_parenthesized_keyword_name + // f((a)=1) + parser.add_error( + ParseErrorType::OtherError( + EXPRESSION_CONTAINS_ASSIGNMENT.to_string(), + ), + keyword_target_range, + ); + } + let unpacking = parsed_expr.is_unparenthesized_starred_expr(); let arg = if let ParsedExpr { expr: Expr::Name(ident_expr), is_parenthesized, @@ -823,10 +930,29 @@ impl<'src> Parser<'src> { // TODO(dhruvmanila): Parser shouldn't drop the `parsed_expr` if it's // not a name expression. We could add the expression into `args` but // that means the error is a missing comma instead. - parser.add_error( - ParseErrorType::OtherError("expected a parameter name".to_string()), - &parsed_expr, - ); + + // test_err args_invalid_keyword_name + // f(a.b=1) + // f(True=1) + // f(*a=1) + let message = match &parsed_expr.expr { + _ if unpacking => None, + Expr::BooleanLiteral(_) | Expr::NoneLiteral(_) + if !parsed_expr.is_parenthesized => + { + Some(format!( + "cannot assign to {}", + ExpressionKind::of(&parsed_expr.expr) + )) + } + _ => Some(EXPRESSION_CONTAINS_ASSIGNMENT.to_string()), + }; + if let Some(message) = message { + parser.add_error( + ParseErrorType::OtherError(message), + keyword_target_range, + ); + } ast::Identifier { id: Name::empty(), range: parsed_expr.range(), @@ -834,8 +960,43 @@ impl<'src> Parser<'src> { } }; + if arg.is_valid() + && (parser.at(TokenKind::Comma) || parser.at(TokenKind::Rpar)) + { + // test_err args_missing_keyword_value + // f(a=) + // f(a, b=, c) + parser.add_error( + ParseErrorType::OtherError( + "expected argument value expression".to_string(), + ), + TextRange::new(arg.start(), equal_range.end()), + ); + } + let value = parser.parse_conditional_expression_or_higher(); + if unpacking { + parser.add_error( + ParseErrorType::OtherError( + "cannot assign to iterable argument unpacking".to_string(), + ), + TextRange::new(arg.start(), value.end()), + ); + } else if arg.is_valid() + && matches!( + parser.current_token_kind(), + TokenKind::For | TokenKind::Async + ) + { + // test_err args_keyword_generator + // f(a=x for x in y) + parser.add_error( + ParseErrorType::AssignmentInsteadOfComparison, + TextRange::new(arg.start(), equal_range.end()), + ); + } + parser.keyword_scratch.push(ast::Keyword { arg: Some(arg), value: value.expr, @@ -843,17 +1004,19 @@ impl<'src> Parser<'src> { node_index: AtomicNodeIndex::NONE, }); } else { - if !parsed_expr.is_unparenthesized_starred_expr() { + if !parsed_expr.is_unparenthesized_starred_expr() + && positional_after_keyword.is_none() + { if seen_keyword_unpacking { - parser.add_error( + positional_after_keyword = Some(( ParseErrorType::PositionalAfterKeywordUnpacking, - &parsed_expr, - ); + parser.errors.len(), + )); } else if seen_keyword_argument { - parser.add_error( + positional_after_keyword = Some(( ParseErrorType::PositionalAfterKeywordArgument, - &parsed_expr, - ); + parser.errors.len(), + )); } } parser.expr_scratch.push(parsed_expr.expr); @@ -861,6 +1024,19 @@ impl<'src> Parser<'src> { } }); + if let Some((error, index)) = positional_after_keyword { + // test_err args_positional_after_keyword + // f(a=1, b) + // f(**a, b, **c) + self.errors.insert( + index, + ParseError { + error, + location: self.current_token_range(), + }, + ); + } + self.expect(TokenKind::Rpar); let keywords = self.keyword_scratch.take_thin_vec(keywords_snapshot); @@ -2262,6 +2438,7 @@ impl<'src> Parser<'src> { } } + let colon_range = self.current_token_range(); self.bump(TokenKind::Colon); let value = if self.at(TokenKind::DoubleStar) { let unpack_start = self.node_start(); @@ -2273,7 +2450,7 @@ impl<'src> Parser<'src> { ); value } else { - self.parse_conditional_expression_or_higher() + self.parse_dictionary_value(colon_range) }; if matches!(self.current_token_kind(), TokenKind::Async | TokenKind::For) { @@ -2325,6 +2502,28 @@ impl<'src> Parser<'src> { .into(); } + if self.at(TokenKind::DoubleStar) { + let double_star_range = self.current_token_range(); + let checkpoint = self.checkpoint(); + self.bump(TokenKind::DoubleStar); + if self.at_expr() { + let mut parsed_expr = self.parse_conditional_expression_or_higher(); + if self.eat(TokenKind::Rpar) { + // test_err parenthesized_double_starred_expr + // (**x) + self.add_error( + ParseErrorType::OtherError( + "cannot use double starred expression here".to_string(), + ), + double_star_range, + ); + parsed_expr.is_parenthesized = true; + return parsed_expr; + } + } + self.rewind(checkpoint); + } + // Use the more general rule of the three to parse the first element // and limit it later. let mut parsed_expr = self.parse_named_expression_or_higher( @@ -2369,7 +2568,18 @@ impl<'src> Parser<'src> { _ => { // grammar: `group` if parsed_expr.expr.is_starred_expr() { - self.add_error(ParseErrorType::InvalidStarredExpressionUsage, &parsed_expr); + if self.at(TokenKind::Rpar) { + // test_err parenthesized_starred_expr + // (*x) + self.add_error( + ParseErrorType::OtherError( + "cannot use starred expression here".to_string(), + ), + &parsed_expr, + ); + } else { + self.add_error(ParseErrorType::InvalidStarredExpressionUsage, &parsed_expr); + } } self.expect(TokenKind::Rpar); @@ -2524,12 +2734,29 @@ impl<'src> Parser<'src> { value: parser.parse_expression_with_bitwise_or_precedence().expr, }); } else { - let key = parser.parse_conditional_expression_or_higher().expr; + // A missing comma is not reported in a key after the first item. + let key = parser + .parse_conditional_expression_without_comma_check(ExpressionContext::default()) + .expr; + if !parser.at(TokenKind::Colon) { + // test_err dict_missing_colon_after_key + // {a: 1, b} + // {a: 1, b c: 2} + // {**a, b + c} + let end = key.end(); + let last_char = parser.src_text(key.range()).chars().last(); + let start = end - last_char.map_or(TextSize::default(), TextSize::of); + parser.add_error( + ParseErrorType::ExpectedColonAfterDictionaryKey, + TextRange::new(start, end), + ); + } + let colon_range = parser.current_token_range(); parser.expect(TokenKind::Colon); items.push(ast::DictItem { key: Some(key), - value: parser.parse_conditional_expression_or_higher().expr, + value: parser.parse_dictionary_value(colon_range).expr, }); } }); @@ -2546,6 +2773,36 @@ impl<'src> Parser<'src> { } } + /// Parses the value of a dictionary item after the `:` at `colon_range`. + fn parse_dictionary_value(&mut self, colon_range: TextRange) -> ParsedExpr { + if self.at_ts(TokenSet::new([TokenKind::Rbrace, TokenKind::Comma])) { + // test_err dict_missing_value + // {a: } + // {a: 1, b: , c: 2} + self.add_error( + ParseErrorType::OtherError( + "expression expected after dictionary key and ':'".to_string(), + ), + colon_range, + ); + } else if self.at(TokenKind::Star) { + // test_err dict_starred_value + // {a: *b} + // {a: 1, b: *c} + let star_start = self.node_start(); + self.bump(TokenKind::Star); + let value = self.parse_expression_with_bitwise_or_precedence(); + self.add_error( + ParseErrorType::OtherError( + "cannot use a starred expression in a dictionary value".to_string(), + ), + TextRange::new(star_start, value.end()), + ); + return value; + } + self.parse_conditional_expression_or_higher() + } + /// Parses a list of comprehension generators. /// /// These are the `for` and `async for` clauses in a comprehension, optionally @@ -2710,6 +2967,21 @@ impl<'src> Parser<'src> { } } + /// Returns `true` if a `*` starting at `star_start` is at the start of a parenthesized + /// expression, list, set or dictionary, or of a call argument or subscript slice. + fn is_star_expression_position(&self, star_start: TextSize) -> bool { + let previous = self.token_before(star_start).map(|(kind, _)| kind); + match self.innermost_bracket() { + Some(bracket) => { + matches!( + previous, + Some(TokenKind::Lpar | TokenKind::Lsqb | TokenKind::Lbrace) + ) || (bracket == Bracket::CallOrSubscript && previous == Some(TokenKind::Comma)) + } + None => false, + } + } + /// Parses a starred expression with the given precedence. /// /// The expression is parsed with the highest precedence. If the precedence @@ -2730,6 +3002,17 @@ impl<'src> Parser<'src> { let start = self.node_start(); self.bump(TokenKind::Star); + if (!self.at_expr() || self.at(TokenKind::Star)) && self.is_star_expression_position(start) + { + // test_err starred_missing_expression_in_brackets + // f(x, *) + // [*, 1] + self.add_error( + ParseErrorType::OtherError("Invalid star expression".to_string()), + self.current_token_range(), + ); + } + let parsed_expr = match context.starred_expression_precedence() { StarredExpressionPrecedence::Conditional => self .parse_conditional_expression_or_higher_impl( @@ -3042,15 +3325,23 @@ impl<'src> Parser<'src> { // sum(x for x in range(10), 5) // total(1, 2, x for x in range(5), 6) // sum(x for x in range(10),) - let error = match context { - ArgumentsContext::Call => { - ParseErrorType::UnparenthesizedGeneratorExpression - } - ArgumentsContext::ClassDefinition => { - ParseErrorType::OtherError("invalid syntax".to_owned()) - } - }; - self.add_error(error, range); + if matches!(context, ArgumentsContext::ClassDefinition) + && !has_trailing_comma + && arguments.len() == 1 + { + // A class definition with only the generator expression is reported at + // its `for`. + let elt_end = arg.as_generator_expr().map_or(range.start(), |generator| { + self.parenthesized_end(generator.elt.range()) + }); + let (_, for_range) = self.token_after(elt_end); + self.add_error( + ParseErrorType::OtherError("invalid syntax".to_owned()), + for_range, + ); + } else { + self.add_error(ParseErrorType::UnparenthesizedGeneratorExpression, range); + } } } } diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index 81f42fed2ee5d4..dba7e60aaedf0e 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -126,6 +126,15 @@ pub(crate) struct Parser<'src> { elif_else_scratch: ScratchBuffer, } +/// A bracket that encloses part of an expression. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Bracket { + /// The arguments of a call or the slices of a subscript. + CallOrSubscript, + /// A parenthesized expression, list, set or dictionary. + Display, +} + impl<'src> Parser<'src> { /// Create a new parser for the given source code. pub(crate) fn new(source: &'src str, options: ParseOptions) -> Self { @@ -362,6 +371,87 @@ impl<'src> Parser<'src> { (after_kind == TokenKind::Rpar).then(|| TextRange::new(before.start(), after_range.end())) } + /// Returns the kind and range of the last non-trivia token that starts before `offset`. + fn token_before(&self, offset: TextSize) -> Option<(TokenKind, TextRange)> { + let tokens = self.tokens.bumped(); + tokens[..tokens.partition_point(|token| token.start() < offset)] + .iter() + .rev() + .find(|token| !token.kind().is_trivia()) + .map(|token| (token.kind(), token.range())) + } + + /// Returns how many brackets enclose the tokens bumped so far. + fn bracket_level(&self) -> usize { + let mut level = 0usize; + for token in self.tokens.bumped() { + match token.kind() { + TokenKind::Lpar | TokenKind::Lsqb | TokenKind::Lbrace => level += 1, + TokenKind::Rpar | TokenKind::Rsqb | TokenKind::Rbrace => { + level = level.saturating_sub(1); + } + _ => {} + } + } + level + } + + /// Returns the innermost bracket enclosing the tokens bumped so far, or `None` if there is + /// none or it starts an f-string or t-string replacement field. + fn innermost_bracket(&self) -> Option { + #[derive(PartialEq)] + enum Opener { + Bracket(Bracket), + InterpolatedString, + ReplacementField, + } + let mut openers = Vec::new(); + let mut previous = TokenKind::Unknown; + for token in self.tokens.bumped() { + if token.kind().is_trivia() { + continue; + } + match token.kind() { + TokenKind::FStringStart | TokenKind::TStringStart => { + openers.push(Opener::InterpolatedString); + } + TokenKind::Lbrace if openers.last() == Some(&Opener::InterpolatedString) => { + openers.push(Opener::ReplacementField); + } + TokenKind::Lpar | TokenKind::Lsqb + if matches!( + previous, + TokenKind::Identifier + | TokenKind::String + | TokenKind::FStringEnd + | TokenKind::TStringEnd + | TokenKind::Rpar + | TokenKind::Rsqb + | TokenKind::Rbrace + ) || previous.is_soft_keyword() => + { + openers.push(Opener::Bracket(Bracket::CallOrSubscript)); + } + TokenKind::Lpar | TokenKind::Lsqb | TokenKind::Lbrace => { + openers.push(Opener::Bracket(Bracket::Display)); + } + TokenKind::Rpar + | TokenKind::Rsqb + | TokenKind::Rbrace + | TokenKind::FStringEnd + | TokenKind::TStringEnd => { + openers.pop(); + } + _ => {} + } + previous = token.kind(); + } + match openers.pop() { + Some(Opener::Bracket(bracket)) => Some(bracket), + _ => None, + } + } + /// Returns the kind of the first non-trivia token that starts at or after `offset`. fn token_kind_after(&self, offset: TextSize) -> TokenKind { self.token_after(offset).0 @@ -1586,9 +1676,10 @@ impl RecoveryContextKind { RecoveryContextKind::DeleteTargets => p.at_expr(), RecoveryContextKind::Identifiers => p.at_identifier_or_soft_keyword(), RecoveryContextKind::Parameters(_) => { + // A `(` is an element only to report parenthesized parameters. matches!( p.current_token_kind(), - TokenKind::Star | TokenKind::DoubleStar | TokenKind::Slash + TokenKind::Star | TokenKind::DoubleStar | TokenKind::Slash | TokenKind::Lpar ) || p.at_identifier_or_soft_keyword() } RecoveryContextKind::WithItems(_) => p.at_expr(), diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index ff0bce286bcc44..f156f78f5af2b8 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -3425,6 +3425,7 @@ impl<'src> Parser<'src> { ) -> ast::ParameterWithDefault { let parameter = self.parse_parameter(start, function_kind, AllowStarAnnotation::No); + let equal_range = self.current_token_range(); let default = if self.eat(TokenKind::Equal) { if self.at_expr() { // test_ok param_with_default @@ -3442,10 +3443,17 @@ impl<'src> Parser<'src> { // test_err param_missing_default // def foo(x=): ... // def foo(x: int = ): ... - self.add_error( - ParseErrorType::ExpectedExpression, - self.current_token_range(), - ); + if self.at(TokenKind::Rpar) || self.at(TokenKind::Comma) { + self.add_error( + ParseErrorType::OtherError("expected default value expression".to_string()), + equal_range, + ); + } else { + self.add_error( + ParseErrorType::ExpectedExpression, + self.current_token_range(), + ); + } None } } else { @@ -3485,8 +3493,8 @@ impl<'src> Parser<'src> { let mut seen_keyword_only_separator = false; // `*` let mut seen_keyword_only_param_after_separator = false; - // Range of the keyword only separator if it's the last parameter in the list. - let mut last_keyword_only_separator_range = None; + // Whether only parameters without a default have been seen. + let mut only_parameters_without_default = true; self.parse_comma_separated_list(RecoveryContextKind::Parameters(function_kind), |parser| { let param_start = parser.node_start(); @@ -3500,7 +3508,32 @@ impl<'src> Parser<'src> { ); } + let only_parameters_without_default_before = only_parameters_without_default; + only_parameters_without_default = false; + match parser.current_token_kind() { + TokenKind::Lpar => { + // test_err params_parenthesized + // def foo(a, (b, c)): ... + // def foo((a)): ... + // lambda (a,): ... + let range = parser + .parenthesized_parameters_range(function_kind) + .filter(|_| only_parameters_without_default_before); + let message = if range.is_none() { + "invalid syntax" + } else if matches!(function_kind, FunctionKind::Lambda) { + "Lambda expression parameters cannot be parenthesized" + } else { + "Function parameters cannot be parenthesized" + }; + let lpar_range = parser.current_token_range(); + parser.add_error( + ParseErrorType::OtherError(message.to_string()), + range.unwrap_or(lpar_range), + ); + parser.bump(TokenKind::Lpar); + } TokenKind::Star => { let star_range = parser.current_token_range(); parser.bump(TokenKind::Star); @@ -3513,7 +3546,6 @@ impl<'src> Parser<'src> { function_kind, AllowStarAnnotation::Yes, ); - let param_star_range = parser.node_range(star_range.start()); if parser.at(TokenKind::Equal) { // test_err params_var_positional_with_default @@ -3534,7 +3566,7 @@ impl<'src> Parser<'src> { ParseErrorType::OtherError( "* argument may appear only once".to_string(), ), - param_star_range, + star_range, ); } @@ -3543,37 +3575,37 @@ impl<'src> Parser<'src> { if parameters.vararg.is_none() { parameters.vararg = Some(Box::new(param)); } - - last_keyword_only_separator_range = None; } else { - if seen_keyword_only_separator { + if seen_keyword_only_separator || parameters.vararg.is_some() { // test_err params_multiple_star_separator // def foo(a, *, *, b): ... // def foo(a, *, b, c, *): ... - parser.add_error( - ParseErrorType::OtherError( - "only one '*' separator allowed".to_string(), - ), - star_range, - ); - } - if parameters.vararg.is_some() { // test_err params_star_separator_after_star_param // def foo(a, *args, *, b): ... // def foo(a, *args, b, c, *): ... + let message = if parser.at(TokenKind::Comma) { + "* argument may appear only once" + } else { + "invalid syntax" + }; parser.add_error( - ParseErrorType::OtherError( - "keyword-only parameter separator not allowed \ - after '*' parameter" - .to_string(), - ), + ParseErrorType::OtherError(message.to_string()), star_range, ); + } else if let Some(range) = + parser.bare_star_error_range(function_kind, star_range) + { + // test_err params_expected_after_star_separator + // def foo(*): ... + // def foo(*,): ... + // def foo(a, *): ... + // def foo(a, *,): ... + // def foo(*, **kwargs): ... + parser.add_error(ParseErrorType::ExpectedKeywordParam, range); } seen_keyword_only_separator = true; - last_keyword_only_separator_range = Some(star_range); } } TokenKind::DoubleStar => { @@ -3599,31 +3631,37 @@ impl<'src> Parser<'src> { // test_err params_var_keyword_with_default // def foo(a, **kwargs={'b': 1, 'c': 2}): ... parser.add_error( - ParseErrorType::VarParameterWithDefault, + ParseErrorType::VarKeywordParameterWithDefault, parser.current_token_range(), ); } - if seen_keyword_only_separator && !seen_keyword_only_param_after_separator { - // test_ok params_seen_keyword_only_param_after_star - // def foo(*, a, **kwargs): ... - // def foo(*, a=10, **kwargs): ... - - // test_err params_kwarg_after_star_separator - // def foo(*, **kwargs): ... - parser.add_error( - ParseErrorType::ExpectedKeywordParam, - param_double_star_range, - ); - } + // test_ok params_seen_keyword_only_param_after_star + // def foo(*, a, **kwargs): ... + // def foo(*, a=10, **kwargs): ... + // test_err params_kwarg_after_star_separator + // def foo(*, **kwargs): ... parameters.kwarg = Some(Box::new(param)); - last_keyword_only_separator_range = None; } TokenKind::Slash => { let slash_range = parser.current_token_range(); parser.bump(TokenKind::Slash); + if parser.at(TokenKind::Star) + && !parser.parameter_scratch.is_empty(¶meters_snapshot) + { + // test_err params_star_after_slash_without_comma + // def foo(a, /*, b): ... + // lambda a, /*, b: ... + parser.add_error( + ParseErrorType::OtherError( + "expected comma between / and *".to_string(), + ), + parser.current_token_range(), + ); + } + if parser.parameter_scratch.is_empty(¶meters_snapshot) && parameters.vararg.is_none() && parameters.kwarg.is_none() @@ -3684,8 +3722,6 @@ impl<'src> Parser<'src> { slash_range, ); } - - last_keyword_only_separator_range = None; } _ if parser.at_identifier_or_soft_keyword() => { let param = parser.parse_parameter_with_default(param_start, function_kind); @@ -3707,13 +3743,14 @@ impl<'src> Parser<'src> { } seen_default_param |= param.default.is_some(); + only_parameters_without_default = + only_parameters_without_default_before && param.default.is_none(); if seen_keyword_only_separator { seen_keyword_only_param_after_separator = true; } parser.parameter_scratch.push(param); - last_keyword_only_separator_range = None; } _ => { // This corresponds to the expected token kinds for `is_list_element`. @@ -3722,16 +3759,6 @@ impl<'src> Parser<'src> { } }); - if let Some(star_range) = last_keyword_only_separator_range { - // test_err params_expected_after_star_separator - // def foo(*): ... - // def foo(*,): ... - // def foo(a, *): ... - // def foo(a, *,): ... - // def foo(*, **kwargs): ... - self.add_error(ParseErrorType::ExpectedKeywordParam, star_range); - } - if matches!(function_kind, FunctionKind::FunctionDef) { self.expect(TokenKind::Rpar); } @@ -3753,6 +3780,87 @@ impl<'src> Parser<'src> { parameters } + /// Parses and reports a bound or constraints after a `TypeVarTuple` or `ParamSpec` name, if + /// there is one. The AST has no place for them. + fn parse_variadic_type_param_bound(&mut self, kind: &str) { + if !self.at(TokenKind::Colon) + || !(EXPR_SET.contains(self.peek()) || self.peek().is_soft_keyword()) + { + return; + } + let start = self.current_token_range().start(); + self.bump(TokenKind::Colon); + let bound = self.parse_conditional_expression_or_higher(); + let what = if bound.expr.is_tuple_expr() { + "constraints" + } else { + "bound" + }; + self.add_error( + ParseErrorType::OtherError(format!("cannot use {what} with {kind}")), + TextRange::new(start, bound.end()), + ); + } + + /// Returns the range of the error for a bare `*` separator not followed by a keyword-only + /// parameter, if there is one. The parser is positioned right after the `*`. + fn bare_star_error_range( + &mut self, + function_kind: FunctionKind, + star_range: TextRange, + ) -> Option { + let terminator = function_kind.list_terminator(); + if self.at(terminator) { + return Some(match function_kind { + FunctionKind::FunctionDef => star_range, + FunctionKind::Lambda => self.current_token_range(), + }); + } + if !self.at(TokenKind::Comma) + || !matches!(self.peek(), kind if kind == terminator || kind == TokenKind::DoubleStar) + { + return None; + } + Some(match function_kind { + FunctionKind::FunctionDef => star_range, + FunctionKind::Lambda => { + let checkpoint = self.checkpoint(); + self.bump(TokenKind::Comma); + let range = self.current_token_range(); + self.rewind(checkpoint); + range + } + }) + } + + /// Returns the range from the current `(` to its `)` if they enclose only parameters + /// without a default (or names, for a lambda), separated by commas. + fn parenthesized_parameters_range(&mut self, function_kind: FunctionKind) -> Option { + let checkpoint = self.checkpoint(); + let start = self.current_token_range().start(); + self.bump(TokenKind::Lpar); + let mut range = None; + while self.at_identifier_or_soft_keyword() { + self.bump_any(); + if matches!(function_kind, FunctionKind::FunctionDef) && self.eat(TokenKind::Colon) { + if !self.at_expr() { + break; + } + self.parse_conditional_expression_or_higher(); + } + let comma = self.eat(TokenKind::Comma); + if self.at(TokenKind::Rpar) { + range = Some(TextRange::new(start, self.current_token_range().end())); + break; + } + if !comma { + break; + } + } + self.rewind(checkpoint); + range + } + /// Try to parse a type parameter list. If the parser is not at the start of a /// type parameter list, return `None`. /// @@ -3819,6 +3927,7 @@ impl<'src> Parser<'src> { // type X[T, *Ts = int] = int if self.eat(TokenKind::Star) { let name = self.parse_identifier(); + self.parse_variadic_type_param_bound("TypeVarTuple"); let default = if self.eat(TokenKind::Equal) { if self.at_expr() { @@ -3864,6 +3973,7 @@ impl<'src> Parser<'src> { // type X[T, **P = int] = int } else if self.eat(TokenKind::DoubleStar) { let name = self.parse_identifier(); + self.parse_variadic_type_param_bound("ParamSpec"); let default = if self.eat(TokenKind::Equal) { if self.at_expr() { diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_invalid_keyword_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_invalid_keyword_name.py.snap new file mode 100644 index 00000000000000..bbbb1b7033b596 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_invalid_keyword_name.py.snap @@ -0,0 +1,187 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/args_invalid_keyword_name.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..27, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..8, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 0..8, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 1..8, + node_index: NodeIndex(None), + args: [], + keywords: [ + Keyword { + range: 2..7, + node_index: NodeIndex(None), + arg: Some( + Identifier { + id: Name(""), + range: 2..5, + node_index: NodeIndex(None), + }, + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 6..7, + value: Int( + 1, + ), + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 9..18, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 9..18, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 9..10, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 10..18, + node_index: NodeIndex(None), + args: [], + keywords: [ + Keyword { + range: 11..17, + node_index: NodeIndex(None), + arg: Some( + Identifier { + id: Name(""), + range: 11..15, + node_index: NodeIndex(None), + }, + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 16..17, + value: Int( + 1, + ), + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 19..26, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 19..26, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 19..20, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 20..26, + node_index: NodeIndex(None), + args: [], + keywords: [ + Keyword { + range: 21..25, + node_index: NodeIndex(None), + arg: Some( + Identifier { + id: Name(""), + range: 21..23, + node_index: NodeIndex(None), + }, + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 24..25, + value: Int( + 1, + ), + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f(a.b=1) + | ^^^^ Syntax Error: expression cannot contain assignment, perhaps you meant "=="? +2 | f(True=1) +3 | f(*a=1) + | + + + | +1 | f(a.b=1) +2 | f(True=1) + | ^^^^^ Syntax Error: cannot assign to True +3 | f(*a=1) + | + + + | +1 | f(a.b=1) +2 | f(True=1) +3 | f(*a=1) + | ^^^^ Syntax Error: cannot assign to iterable argument unpacking diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_keyword_generator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_keyword_generator.py.snap new file mode 100644 index 00000000000000..e32a5c7b91b84b --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_keyword_generator.py.snap @@ -0,0 +1,114 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/args_keyword_generator.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..18, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 0..5, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 1..5, + node_index: NodeIndex(None), + args: [], + keywords: [ + Keyword { + range: 2..5, + node_index: NodeIndex(None), + arg: Some( + Identifier { + id: Name("a"), + range: 2..3, + node_index: NodeIndex(None), + }, + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 4..5, + id: Name("x"), + ctx: Load, + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + For( + StmtFor { + node_index: NodeIndex(None), + range: 6..16, + is_async: false, + target: Name( + ExprName { + node_index: NodeIndex(None), + range: 10..11, + id: Name("x"), + ctx: Store, + }, + ), + iter: Name( + ExprName { + node_index: NodeIndex(None), + range: 15..16, + id: Name("y"), + ctx: Load, + }, + ), + body: [], + orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f(a=x for x in y) + | ^^ Syntax Error: invalid syntax. Maybe you meant '==' or ':=' instead of '='? + + + | +1 | f(a=x for x in y) + | ^^^ Syntax Error: invalid syntax + + + | +1 | f(a=x for x in y) + | ^ Syntax Error: unmatched ')' + + + | +1 | f(a=x for x in y) + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_keyword_unpacking_assignment.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_keyword_unpacking_assignment.py.snap new file mode 100644 index 00000000000000..28957d93aaaf3b --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_keyword_unpacking_assignment.py.snap @@ -0,0 +1,65 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/args_keyword_unpacking_assignment.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..9, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..8, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 0..8, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 1..8, + node_index: NodeIndex(None), + args: [], + keywords: [ + Keyword { + range: 2..7, + node_index: NodeIndex(None), + arg: None, + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 6..7, + value: Int( + 1, + ), + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f(**a=1) + | ^^^^^ Syntax Error: cannot assign to keyword argument unpacking diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_missing_keyword_value.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_missing_keyword_value.py.snap new file mode 100644 index 00000000000000..b797653ca2344e --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_missing_keyword_value.py.snap @@ -0,0 +1,162 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/args_missing_keyword_value.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..18, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 0..5, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 1..5, + node_index: NodeIndex(None), + args: [], + keywords: [ + Keyword { + range: 2..4, + node_index: NodeIndex(None), + arg: Some( + Identifier { + id: Name("a"), + range: 2..3, + node_index: NodeIndex(None), + }, + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 4..4, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 6..17, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 6..17, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 6..7, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 7..17, + node_index: NodeIndex(None), + args: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 8..9, + id: Name("a"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 15..16, + id: Name("c"), + ctx: Load, + }, + ), + ], + keywords: [ + Keyword { + range: 11..13, + node_index: NodeIndex(None), + arg: Some( + Identifier { + id: Name("b"), + range: 11..12, + node_index: NodeIndex(None), + }, + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 13..13, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f(a=) + | ^^ Syntax Error: expected argument value expression +2 | f(a, b=, c) + | + + + | +1 | f(a=) + | ^ Syntax Error: invalid syntax +2 | f(a, b=, c) + | + + + | +1 | f(a=) +2 | f(a, b=, c) + | ^^ Syntax Error: expected argument value expression + + + | +1 | f(a=) +2 | f(a, b=, c) + | ^ Syntax Error: invalid syntax + + + | +1 | f(a=) +2 | f(a, b=, c) + | ^ Syntax Error: positional argument follows keyword argument diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_parenthesized_keyword_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_parenthesized_keyword_name.py.snap new file mode 100644 index 00000000000000..dbd15ff722b7e3 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_parenthesized_keyword_name.py.snap @@ -0,0 +1,78 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/args_parenthesized_keyword_name.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..9, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..8, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 0..8, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 1..8, + node_index: NodeIndex(None), + args: [], + keywords: [ + Keyword { + range: 2..7, + node_index: NodeIndex(None), + arg: Some( + Identifier { + id: Name("a"), + range: 3..4, + node_index: NodeIndex(None), + }, + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 6..7, + value: Int( + 1, + ), + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f((a)=1) + | ^^^ Syntax Error: expression cannot contain assignment, perhaps you meant "=="? + + +## Unsupported Syntax Errors + + | +1 | f((a)=1) + | ^^^ Syntax Error: cannot use parenthesized keyword argument name on Python 3.14 (syntax was removed in Python 3.8) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_positional_after_keyword.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_positional_after_keyword.py.snap new file mode 100644 index 00000000000000..87f31a0b909a41 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@args_positional_after_keyword.py.snap @@ -0,0 +1,152 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/args_positional_after_keyword.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..25, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..9, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 0..9, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 1..9, + node_index: NodeIndex(None), + args: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 7..8, + id: Name("b"), + ctx: Load, + }, + ), + ], + keywords: [ + Keyword { + range: 2..5, + node_index: NodeIndex(None), + arg: Some( + Identifier { + id: Name("a"), + range: 2..3, + node_index: NodeIndex(None), + }, + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 4..5, + value: Int( + 1, + ), + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 10..24, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 10..24, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 10..11, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 11..24, + node_index: NodeIndex(None), + args: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 17..18, + id: Name("b"), + ctx: Load, + }, + ), + ], + keywords: [ + Keyword { + range: 12..15, + node_index: NodeIndex(None), + arg: None, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 14..15, + id: Name("a"), + ctx: Load, + }, + ), + }, + Keyword { + range: 20..23, + node_index: NodeIndex(None), + arg: None, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 22..23, + id: Name("c"), + ctx: Load, + }, + ), + }, + ], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f(a=1, b) + | ^ Syntax Error: positional argument follows keyword argument +2 | f(**a, b, **c) + | + + + | +1 | f(a=1, b) +2 | f(**a, b, **c) + | ^ Syntax Error: positional argument follows keyword argument unpacking diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap index 950e45933a75df..927826751b1b0f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@class_def_unparenthesized_generator_argument.py.snap @@ -100,4 +100,4 @@ Module( | 1 | class Foo(base for base in bases): ... - | ^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: invalid syntax + | ^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap index 5146d3006b35ba..29ef81650517f3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma.py.snap @@ -76,4 +76,4 @@ Module( | 1 | call(**x := 1) - | ^ Syntax Error: positional argument follows keyword argument unpacking + | ^ Syntax Error: positional argument follows keyword argument unpacking diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap index 936a5d05e97fcd..5adda17c8f7b69 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comma_separated_missing_comma_between_elements.py.snap @@ -60,6 +60,12 @@ Module( ``` ## Errors + | +1 | # The comma between the first two elements is expected in `parse_list_expression`. +2 | [0, 1 2] + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + | 1 | # The comma between the first two elements is expected in `parse_list_expression`. 2 | [0, 1 2] diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap index 404c8bc00b692c..27d75f322a1bf7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@decorator_invalid_expression.py.snap @@ -167,7 +167,7 @@ Module( | 1 | @*x 2 | @(*x) - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here 3 | @((*x)) 4 | @yield x | @@ -177,7 +177,7 @@ Module( 1 | @*x 2 | @(*x) 3 | @((*x)) - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here 4 | @yield x 5 | @yield from x | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_missing_colon_after_key.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_missing_colon_after_key.py.snap new file mode 100644 index 00000000000000..edded4500888b9 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_missing_colon_after_key.py.snap @@ -0,0 +1,281 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/dict_missing_colon_after_key.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..38, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..9, + value: Dict( + ExprDict { + node_index: NodeIndex(None), + range: 0..9, + items: [ + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 1..2, + id: Name("a"), + ctx: Load, + }, + ), + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 4..5, + value: Int( + 1, + ), + }, + ), + }, + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 7..8, + id: Name("b"), + ctx: Load, + }, + ), + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 8..8, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ], + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 10..24, + value: Dict( + ExprDict { + node_index: NodeIndex(None), + range: 10..24, + items: [ + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 11..12, + id: Name("a"), + ctx: Load, + }, + ), + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 14..15, + value: Int( + 1, + ), + }, + ), + }, + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 17..18, + id: Name("b"), + ctx: Load, + }, + ), + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 19..20, + id: Name("c"), + ctx: Load, + }, + ), + }, + DictItem { + key: Some( + NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 22..23, + value: Int( + 2, + ), + }, + ), + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 23..23, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ], + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 25..37, + value: Dict( + ExprDict { + node_index: NodeIndex(None), + range: 25..37, + items: [ + DictItem { + key: None, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 28..29, + id: Name("a"), + ctx: Load, + }, + ), + }, + DictItem { + key: Some( + BinOp( + ExprBinOp { + node_index: NodeIndex(None), + range: 31..36, + left: Name( + ExprName { + node_index: NodeIndex(None), + range: 31..32, + id: Name("b"), + ctx: Load, + }, + ), + op: Add, + right: Name( + ExprName { + node_index: NodeIndex(None), + range: 35..36, + id: Name("c"), + ctx: Load, + }, + ), + }, + ), + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 36..36, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ], + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | {a: 1, b} + | ^ Syntax Error: ':' expected after dictionary key +2 | {a: 1, b c: 2} +3 | {**a, b + c} + | + + + | +1 | {a: 1, b} + | ^ Syntax Error: invalid syntax +2 | {a: 1, b c: 2} +3 | {**a, b + c} + | + + + | +1 | {a: 1, b} +2 | {a: 1, b c: 2} + | ^ Syntax Error: ':' expected after dictionary key +3 | {**a, b + c} + | + + + | +1 | {a: 1, b} +2 | {a: 1, b c: 2} + | ^ Syntax Error: invalid syntax +3 | {**a, b + c} + | + + + | +1 | {a: 1, b} +2 | {a: 1, b c: 2} + | ^ Syntax Error: invalid syntax +3 | {**a, b + c} + | + + + | +1 | {a: 1, b} +2 | {a: 1, b c: 2} + | ^ Syntax Error: ':' expected after dictionary key +3 | {**a, b + c} + | + + + | +1 | {a: 1, b} +2 | {a: 1, b c: 2} + | ^ Syntax Error: invalid syntax +3 | {**a, b + c} + | + + + | +1 | {a: 1, b} +2 | {a: 1, b c: 2} +3 | {**a, b + c} + | ^ Syntax Error: ':' expected after dictionary key + + + | +1 | {a: 1, b} +2 | {a: 1, b c: 2} +3 | {**a, b + c} + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_missing_value.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_missing_value.py.snap new file mode 100644 index 00000000000000..40aee762b38414 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_missing_value.py.snap @@ -0,0 +1,155 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/dict_missing_value.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..24, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: Dict( + ExprDict { + node_index: NodeIndex(None), + range: 0..5, + items: [ + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 1..2, + id: Name("a"), + ctx: Load, + }, + ), + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..3, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ], + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 6..23, + value: Dict( + ExprDict { + node_index: NodeIndex(None), + range: 6..23, + items: [ + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 7..8, + id: Name("a"), + ctx: Load, + }, + ), + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 10..11, + value: Int( + 1, + ), + }, + ), + }, + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 13..14, + id: Name("b"), + ctx: Load, + }, + ), + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 15..15, + id: Name(""), + ctx: Invalid, + }, + ), + }, + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 18..19, + id: Name("c"), + ctx: Load, + }, + ), + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 21..22, + value: Int( + 2, + ), + }, + ), + }, + ], + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | {a: } + | ^ Syntax Error: expression expected after dictionary key and ':' +2 | {a: 1, b: , c: 2} + | + + + | +1 | {a: } + | ^ Syntax Error: invalid syntax +2 | {a: 1, b: , c: 2} + | + + + | +1 | {a: } +2 | {a: 1, b: , c: 2} + | ^ Syntax Error: expression expected after dictionary key and ':' + + + | +1 | {a: } +2 | {a: 1, b: , c: 2} + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_starred_value.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_starred_value.py.snap new file mode 100644 index 00000000000000..a820ac13f8bfcd --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@dict_starred_value.py.snap @@ -0,0 +1,121 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/dict_starred_value.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..22, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..7, + value: Dict( + ExprDict { + node_index: NodeIndex(None), + range: 0..7, + items: [ + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 1..2, + id: Name("a"), + ctx: Load, + }, + ), + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 5..6, + id: Name("b"), + ctx: Load, + }, + ), + }, + ], + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 8..21, + value: Dict( + ExprDict { + node_index: NodeIndex(None), + range: 8..21, + items: [ + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 9..10, + id: Name("a"), + ctx: Load, + }, + ), + ), + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 12..13, + value: Int( + 1, + ), + }, + ), + }, + DictItem { + key: Some( + Name( + ExprName { + node_index: NodeIndex(None), + range: 15..16, + id: Name("b"), + ctx: Load, + }, + ), + ), + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 19..20, + id: Name("c"), + ctx: Load, + }, + ), + }, + ], + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | {a: *b} + | ^^ Syntax Error: cannot use a starred expression in a dictionary value +2 | {a: 1, b: *c} + | + + + | +1 | {a: *b} +2 | {a: 1, b: *c} + | ^^ Syntax Error: cannot use a starred expression in a dictionary value diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap index 32313905023003..9acbe20b1e6e9d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__double_starred.py.snap @@ -254,4 +254,4 @@ Module( 3 | call(***x) 4 | 5 | call(**x := 1) - | ^ Syntax Error: positional argument follows keyword argument unpacking + | ^ Syntax Error: positional argument follows keyword argument unpacking diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap index 8c53336af733ba..fb0e814c002a40 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_expression.py.snap @@ -205,7 +205,7 @@ Module( | 1 | call(x + y = 1) - | ^^^^^ Syntax Error: expected a parameter name + | ^^^^^^^ Syntax Error: expression cannot contain assignment, perhaps you meant "=="? 2 | call(x := 1 = 1) | @@ -213,7 +213,7 @@ Module( | 1 | call(x + y = 1) 2 | call(x := 1 = 1) - | ^^^^^^ Syntax Error: expected a parameter name + | ^^^^^^^^ Syntax Error: expression cannot contain assignment, perhaps you meant "=="? 3 | 4 | call(yield x) | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap index 796dc13c4b6a00..54353f24d1c1ac 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_keyword_expression.py.snap @@ -267,4 +267,4 @@ Module( 2 | call(x = yield from y) 3 | call(x = *y) 4 | call(x = (*y)) - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap index b555c7b7aa882c..e2c3a5b5da3661 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__invalid_order.py.snap @@ -315,7 +315,7 @@ Module( | 1 | call(**kwargs, x) - | ^ Syntax Error: positional argument follows keyword argument unpacking + | ^ Syntax Error: positional argument follows keyword argument unpacking 2 | call(x=1, y) 3 | call(x=1, **kwargs, y) | @@ -324,7 +324,7 @@ Module( | 1 | call(**kwargs, x) 2 | call(x=1, y) - | ^ Syntax Error: positional argument follows keyword argument + | ^ Syntax Error: positional argument follows keyword argument 3 | call(x=1, **kwargs, y) 4 | call(**kwargs, *args) | @@ -334,7 +334,7 @@ Module( 1 | call(**kwargs, x) 2 | call(x=1, y) 3 | call(x=1, **kwargs, y) - | ^ Syntax Error: positional argument follows keyword argument unpacking + | ^ Syntax Error: positional argument follows keyword argument unpacking 4 | call(**kwargs, *args) 5 | call(**kwargs, (*args)) | @@ -344,7 +344,7 @@ Module( 2 | call(x=1, y) 3 | call(x=1, **kwargs, y) 4 | call(**kwargs, *args) - | ^^^^^ Syntax Error: iterable argument unpacking follows keyword argument unpacking + | ^^^^^^^ Syntax Error: iterable argument unpacking follows keyword argument unpacking 5 | call(**kwargs, (*args)) | @@ -353,4 +353,11 @@ Module( 3 | call(x=1, **kwargs, y) 4 | call(**kwargs, *args) 5 | call(**kwargs, (*args)) - | ^ Syntax Error: invalid syntax + | ^^^^^ Syntax Error: cannot use starred expression here + + + | +3 | call(x=1, **kwargs, y) +4 | call(**kwargs, *args) +5 | call(**kwargs, (*args)) + | ^ Syntax Error: positional argument follows keyword argument unpacking diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap index 50b7e158734c67..b3351a3ad9e543 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_comma.py.snap @@ -62,6 +62,11 @@ Module( ``` ## Errors + | +1 | call(x y) + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + | 1 | call(x y) | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap index d4784379987aee..f85ff1cd649e84 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__arguments__missing_expression.py.snap @@ -177,6 +177,14 @@ Module( | + | +1 | call( = 1) +2 | call(x = ) + | ^^^ Syntax Error: expected argument value expression +3 | call(*, y) + | + + | 1 | call( = 1) 2 | call(x = ) @@ -189,7 +197,7 @@ Module( 1 | call( = 1) 2 | call(x = ) 3 | call(*, y) - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: Invalid star expression 4 | 5 | foo | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap index cbc87bb567e168..ed6ac5cb1ccb03 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__await__recover.py.snap @@ -310,7 +310,7 @@ Module( 7 | # Starred expressions 8 | await *x 9 | await (*x) - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here 10 | 11 | # Invalid expression as per precedence | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap index af79ff2c0105bc..c4aa7c000ac49f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__double_star.py.snap @@ -568,6 +568,16 @@ Module( | + | +2 | # the ones which are higher than that. +3 | +4 | {**x := 1} + | ^ Syntax Error: ':' expected after dictionary key +5 | {a: 1, **x if True else y} +6 | {**lambda x: x, b: 2} + | + + | 2 | # the ones which are higher than that. 3 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap index beb0558afddcfb..fdbf54ca690d48 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_0.py.snap @@ -147,6 +147,16 @@ Module( | + | +1 | # Unparenthesized named expression not allowed in key +2 | +3 | {x := 1: y, z := 2: a} + | ^ Syntax Error: ':' expected after dictionary key +4 | +5 | x + y + | + + | 1 | # Unparenthesized named expression not allowed in key 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap index cfe52f2a965bd2..94ca222e057482 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__named_expression_1.py.snap @@ -153,6 +153,16 @@ Module( | + | +1 | # Unparenthesized named expression not allowed in value +2 | +3 | {x: y := 1, z: a := 2} + | ^ Syntax Error: ':' expected after dictionary key +4 | +5 | x + y + | + + | 1 | # Unparenthesized named expression not allowed in value 2 | @@ -173,6 +183,16 @@ Module( | + | +1 | # Unparenthesized named expression not allowed in value +2 | +3 | {x: y := 1, z: a := 2} + | ^ Syntax Error: ':' expected after dictionary key +4 | +5 | x + y + | + + | 1 | # Unparenthesized named expression not allowed in value 2 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap index e48cabd9ff4a63..796fb7a196f4f2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__dict__recover.py.snap @@ -425,18 +425,11 @@ Module( }, ), ), - value: Starred( - ExprStarred { + value: Name( + ExprName { node_index: NodeIndex(None), - range: 335..337, - value: Name( - ExprName { - node_index: NodeIndex(None), - range: 336..337, - id: Name("y"), - ctx: Load, - }, - ), + range: 336..337, + id: Name("y"), ctx: Load, }, ), @@ -452,18 +445,11 @@ Module( }, ), ), - value: Starred( - ExprStarred { + value: Name( + ExprName { node_index: NodeIndex(None), - range: 342..344, - value: Name( - ExprName { - node_index: NodeIndex(None), - range: 343..344, - id: Name("a"), - ctx: Load, - }, - ), + range: 343..344, + id: Name("a"), ctx: Load, }, ), @@ -511,6 +497,15 @@ Module( | + | + 9 | # Missing comma +10 | {1: 2 3: 4} + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +11 | +12 | # No value + | + + | 9 | # Missing comma 10 | {1: 2 3: 4} @@ -520,6 +515,15 @@ Module( | + | +12 | # No value +13 | {1: } + | ^ Syntax Error: expression expected after dictionary key and ':' +14 | +15 | # No value for double star unpacking + | + + | 12 | # No value 13 | {1: } @@ -567,11 +571,11 @@ Module( 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} 24 | {x: *y, z: *a} - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use a starred expression in a dictionary value | 22 | # Star expression not allowed here 23 | {*x: y, z: a, *b: c} 24 | {x: *y, z: *a} - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use a starred expression in a dictionary value diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap index 6a43d14bf84a22..8cf86cd9ed3f85 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__lambda_duplicate_parameters.py.snap @@ -364,7 +364,7 @@ Module( 7 | lambda a, *a: 1 8 | 9 | lambda a, *, **a: 1 - | ^^^ Syntax Error: named arguments must follow bare * + | ^^ Syntax Error: named arguments must follow bare * ## Semantic Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap index 1a303bc6724fc8..caf5d1719e37ba 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__recover.py.snap @@ -311,6 +311,15 @@ Module( | + | + 9 | # Missing comma +10 | [1 2] + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +11 | +12 | # Dictionary element in a list + | + + | 9 | # Missing comma 10 | [1 2] @@ -352,4 +361,4 @@ Module( 18 | [1; 2] 19 | 20 | [*] - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: Invalid star expression diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap index b8a093b6549d5b..c77c0e1f75344e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__star_expression_precedence.py.snap @@ -468,7 +468,7 @@ Module( 1 | # For list expression, the minimum binding power of star expression is bitwise or. 2 | 3 | [(*x), y] - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here 4 | [*x in y, z] 5 | [*not x, z] | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap index ff04483ea7702a..7cf4d13ea2f5e3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__parenthesized.py.snap @@ -70,7 +70,7 @@ Module( | 1 | # Starred expression isn't allowed in a parenthesized expression. 2 | (*x) - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here 3 | 4 | # Unparenthesized named expression is allowed. | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap index c96a4fa6182585..a95e99b7fb82d1 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__parenthesized__tuple.py.snap @@ -319,6 +319,33 @@ Module( | + | + 9 | # Missing comma +10 | (1 2) + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +11 | +12 | # Dictionary element in a list + | + + + | + 9 | # Missing comma +10 | (1 2) + | ^ Syntax Error: invalid syntax +11 | +12 | # Dictionary element in a list + | + + + | + 9 | # Missing comma +10 | (1 2) + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +11 | +12 | # Dictionary element in a list + | + + | 9 | # Missing comma 10 | (1 2) diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap index 1bd56589652e25..b6cccf1cfdfbdf 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__recover.py.snap @@ -308,6 +308,15 @@ Module( | + | +11 | # Missing comma +12 | {1 2} + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +13 | +14 | # Dictionary element in a list + | + + | 11 | # Missing comma 12 | {1 2} @@ -340,4 +349,4 @@ Module( 20 | {1; 2} 21 | 22 | [*] - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: Invalid star expression diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap index 16fb46fc6f36ad..04dd3fcf4b5192 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__set__star_expression_precedence.py.snap @@ -460,7 +460,7 @@ Module( 1 | # For set expression, the minimum binding power of star expression is bitwise or. 2 | 3 | {(*x), y} - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here 4 | {*x in y, z} 5 | {*not x, z} | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap index 32cf45551af895..018a25f6a33161 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__subscript__unclosed_slice_1.py.snap @@ -121,6 +121,24 @@ Module( | + | +1 | / x[:: +2 | | +3 | | def foo(): + | |_________^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +4 | pass + | + + + | +1 | x[:: +2 | +3 | def foo(): + | ^^^ Syntax Error: invalid syntax +4 | pass + | + + | 3 | def foo(): 4 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap index 41d6dad95ccc06..0f6e443aee7006 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap @@ -115,7 +115,7 @@ Module( | 1 | # Cannot use starred expression here 2 | yield (*x) - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here 3 | 4 | yield *x and y, z | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap index 44155c830fefd5..935b03a851be6c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_invalid_return_expr.py.snap @@ -206,7 +206,7 @@ Module( | 1 | def foo() -> *int: ... 2 | def foo() -> (*int): ... - | ^ Syntax Error: invalid syntax + | ^^^^ Syntax Error: cannot use starred expression here 3 | def foo() -> yield x: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap index 13772a6e79d773..f8abd4406ab645 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@function_def_unclosed_parameter_list.py.snap @@ -285,6 +285,15 @@ Module( | + | +2 | def foo(): +3 | return 42 +4 | def foo(a: int, b: str + | ____________________^ +5 | | x = 10 + | |_^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + | 3 | return 42 4 | def foo(a: int, b: str diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap index d3933468e58806..ea8224a19ce58f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_guard_expr.py.snap @@ -229,7 +229,7 @@ Module( 2 | case y if *a: ... 3 | match x: 4 | case y if (*a): ... - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here 5 | match x: 6 | case y if yield x: ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap index 28a6a77837f6cd..28f7e72ed16c7e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@match_stmt_invalid_subject_expr.py.snap @@ -210,7 +210,7 @@ Module( | 1 | match (*x): - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use starred expression here 2 | case _: ... 3 | # Starred expression precedence test | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_between_expressions.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_between_expressions.py.snap new file mode 100644 index 00000000000000..00d5e77c45de10 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_between_expressions.py.snap @@ -0,0 +1,345 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/missing_comma_between_expressions.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..38, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: List( + ExprList { + node_index: NodeIndex(None), + range: 0..5, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 1..2, + id: Name("a"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("b"), + ctx: Load, + }, + ), + ], + ctx: Load, + runtime_elts: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 6..17, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 6..17, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 6..7, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 7..17, + node_index: NodeIndex(None), + args: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 8..9, + id: Name("x"), + ctx: Load, + }, + ), + Attribute( + ExprAttribute { + node_index: NodeIndex(None), + range: 11..14, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 11..12, + id: Name("a"), + ctx: Load, + }, + ), + attr: Identifier { + id: Name("b"), + range: 13..14, + node_index: NodeIndex(None), + }, + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 15..16, + id: Name("c"), + ctx: Load, + }, + ), + ], + keywords: [], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 18..28, + value: Subscript( + ExprSubscript { + node_index: NodeIndex(None), + range: 18..28, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 18..19, + id: Name("x"), + ctx: Load, + }, + ), + slice: Slice( + ExprSlice { + node_index: NodeIndex(None), + range: 20..27, + lower: Some( + BinOp( + ExprBinOp { + node_index: NodeIndex(None), + range: 20..25, + left: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 20..21, + value: Int( + 1, + ), + }, + ), + op: Add, + right: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 24..25, + value: Int( + 2, + ), + }, + ), + }, + ), + ), + upper: Some( + NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 26..27, + value: Int( + 3, + ), + }, + ), + ), + step: None, + }, + ), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 29..33, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 29..33, + value: FStringValue { + inner: Single( + FString { + range: 29..33, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 31..33, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 32..33, + id: Name("a"), + ctx: Load, + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: true, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 34..35, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 34..35, + id: Name("b"), + ctx: Load, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | [a b] + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +2 | f(x, a.b c) +3 | x[1 + 2 3] + | + + + | +1 | [a b] + | ^ Syntax Error: invalid syntax +2 | f(x, a.b c) +3 | x[1 + 2 3] + | + + + | +1 | [a b] +2 | f(x, a.b c) + | ^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +3 | x[1 + 2 3] +4 | f"{a b}" + | + + + | +1 | [a b] +2 | f(x, a.b c) + | ^ Syntax Error: invalid syntax +3 | x[1 + 2 3] +4 | f"{a b}" + | + + + | +1 | [a b] +2 | f(x, a.b c) +3 | x[1 + 2 3] + | ^^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +4 | f"{a b}" + | + + + | +1 | [a b] +2 | f(x, a.b c) +3 | x[1 + 2 3] + | ^ Syntax Error: invalid syntax +4 | f"{a b}" + | + + + | +2 | f(x, a.b c) +3 | x[1 + 2 3] +4 | f"{a b}" + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + + | +2 | f(x, a.b c) +3 | x[1 + 2 3] +4 | f"{a b}" + | ^ Syntax Error: f-string: expecting '}' + + + | +2 | f(x, a.b c) +3 | x[1 + 2 3] +4 | f"{a b}" + | ^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + + | +2 | f(x, a.b c) +3 | x[1 + 2 3] +4 | f"{a b}" + | ^ Syntax Error: invalid syntax + + + | +2 | f(x, a.b c) +3 | x[1 + 2 3] +4 | f"{a b}" + | ^ Syntax Error: f-string: single '}' is not allowed + + + | +2 | f(x, a.b c) +3 | x[1 + 2 3] +4 | f"{a b}" + | ^ Syntax Error: invalid syntax + + + | +2 | f(x, a.b c) +3 | x[1 + 2 3] +4 | f"{a b}" + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap index c61c0414417458..1b0d8f4daf3897 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_missing_default.py.snap @@ -150,7 +150,7 @@ Module( | 1 | def foo(x=): ... - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: expected default value expression 2 | def foo(x: int = ): ... | @@ -158,4 +158,4 @@ Module( | 1 | def foo(x=): ... 2 | def foo(x: int = ): ... - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: expected default value expression diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap index 7ede5849703ba5..65bb8204e63f31 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_default.py.snap @@ -260,7 +260,7 @@ Module( | 1 | def foo(x=*int): ... 2 | def foo(x=(*int)): ... - | ^ Syntax Error: invalid syntax + | ^^^^ Syntax Error: cannot use starred expression here 3 | def foo(x=yield y): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap index 681dfc4e4a26c7..877e513a78cca3 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@param_with_invalid_star_annotation.py.snap @@ -357,7 +357,7 @@ Module( | 1 | def foo(*args: *): ... 2 | def foo(*args: (*tuple[int])): ... - | ^ Syntax Error: invalid syntax + | ^^^^^^^^^^^ Syntax Error: cannot use starred expression here 3 | def foo(*args: *int or str): ... 4 | def foo(*args: *yield x): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap index 042452802cbe58..175c0be3a5043c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_expected_after_star_separator.py.snap @@ -321,4 +321,4 @@ Module( 3 | def foo(a, *): ... 4 | def foo(a, *,): ... 5 | def foo(*, **kwargs): ... - | ^^^^^^^^ Syntax Error: named arguments must follow bare * + | ^ Syntax Error: named arguments must follow bare * diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap index c7da40158fd6b5..78f55dffc2357c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_kwarg_after_star_separator.py.snap @@ -75,4 +75,4 @@ Module( | 1 | def foo(*, **kwargs): ... - | ^^^^^^^^ Syntax Error: named arguments must follow bare * + | ^ Syntax Error: named arguments must follow bare * diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap index 8e14cf8368bd46..0eae1926d14b3e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_star_separator.py.snap @@ -194,7 +194,7 @@ Module( | 1 | def foo(a, *, *, b): ... - | ^ Syntax Error: only one '*' separator allowed + | ^ Syntax Error: * argument may appear only once 2 | def foo(a, *, b, c, *): ... | @@ -202,4 +202,4 @@ Module( | 1 | def foo(a, *, *, b): ... 2 | def foo(a, *, b, c, *): ... - | ^ Syntax Error: only one '*' separator allowed + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap index 18e892330561d5..3bbb3eb982e0d9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_multiple_varargs.py.snap @@ -312,7 +312,7 @@ Module( | 1 | def foo(a, *, *args, b): ... - | ^^^^^ Syntax Error: * argument may appear only once + | ^ Syntax Error: * argument may appear only once 2 | # def foo(a, *, b, c, *args): ... 3 | def foo(a, *args1, *args2, b): ... | @@ -322,7 +322,7 @@ Module( 1 | def foo(a, *, *args, b): ... 2 | # def foo(a, *, b, c, *args): ... 3 | def foo(a, *args1, *args2, b): ... - | ^^^^^^ Syntax Error: * argument may appear only once + | ^ Syntax Error: * argument may appear only once 4 | def foo(a, *args1, b, c, *args2): ... | @@ -331,4 +331,4 @@ Module( 2 | # def foo(a, *, b, c, *args): ... 3 | def foo(a, *args1, *args2, b): ... 4 | def foo(a, *args1, b, c, *args2): ... - | ^^^^^^ Syntax Error: * argument may appear only once + | ^ Syntax Error: * argument may appear only once diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_parenthesized.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_parenthesized.py.snap new file mode 100644 index 00000000000000..9a8ac38a4cc5a1 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_parenthesized.py.snap @@ -0,0 +1,304 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/params_parenthesized.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..59, + body: [ + FunctionDef( + StmtFunctionDef { + node_index: NodeIndex(None), + range: 0..17, + is_async: false, + decorator_list: [], + name: Identifier { + id: Name("foo"), + range: 4..7, + node_index: NodeIndex(None), + }, + type_params: None, + parameters: Parameters { + range: 7..17, + node_index: NodeIndex(None), + posonlyargs: [], + args: [ + ParameterWithDefault { + range: 8..9, + node_index: NodeIndex(None), + parameter: Parameter { + range: 8..9, + node_index: NodeIndex(None), + name: Identifier { + id: Name("a"), + range: 8..9, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ParameterWithDefault { + range: 12..13, + node_index: NodeIndex(None), + parameter: Parameter { + range: 12..13, + node_index: NodeIndex(None), + name: Identifier { + id: Name("b"), + range: 12..13, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ParameterWithDefault { + range: 15..16, + node_index: NodeIndex(None), + parameter: Parameter { + range: 15..16, + node_index: NodeIndex(None), + name: Identifier { + id: Name("c"), + range: 15..16, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ], + vararg: None, + kwonlyargs: [], + kwarg: None, + runtime_defaults: None, + }, + returns: None, + body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 20..23, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 20..23, + }, + ), + }, + ), + FunctionDef( + StmtFunctionDef { + node_index: NodeIndex(None), + range: 24..35, + is_async: false, + decorator_list: [], + name: Identifier { + id: Name("foo"), + range: 28..31, + node_index: NodeIndex(None), + }, + type_params: None, + parameters: Parameters { + range: 31..35, + node_index: NodeIndex(None), + posonlyargs: [], + args: [ + ParameterWithDefault { + range: 33..34, + node_index: NodeIndex(None), + parameter: Parameter { + range: 33..34, + node_index: NodeIndex(None), + name: Identifier { + id: Name("a"), + range: 33..34, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ], + vararg: None, + kwonlyargs: [], + kwarg: None, + runtime_defaults: None, + }, + returns: None, + body: [], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 38..41, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 38..41, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 42..58, + value: Lambda( + ExprLambda { + node_index: NodeIndex(None), + range: 42..58, + parameters: Some( + Parameters { + range: 49..53, + node_index: NodeIndex(None), + posonlyargs: [], + args: [ + ParameterWithDefault { + range: 50..51, + node_index: NodeIndex(None), + parameter: Parameter { + range: 50..51, + node_index: NodeIndex(None), + name: Identifier { + id: Name("a"), + range: 50..51, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ], + vararg: None, + kwonlyargs: [], + kwarg: None, + runtime_defaults: None, + }, + ), + body: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 55..58, + }, + ), + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | def foo(a, (b, c)): ... + | ^^^^^^ Syntax Error: Function parameters cannot be parenthesized +2 | def foo((a)): ... +3 | lambda (a,): ... + | + + + | +1 | def foo(a, (b, c)): ... + | ^ Syntax Error: invalid syntax +2 | def foo((a)): ... +3 | lambda (a,): ... + | + + + | +1 | def foo(a, (b, c)): ... + | ^ Syntax Error: invalid syntax +2 | def foo((a)): ... +3 | lambda (a,): ... + | + + + | +1 | def foo(a, (b, c)): ... + | ^ Syntax Error: invalid syntax +2 | def foo((a)): ... +3 | lambda (a,): ... + | + + + | +1 | def foo(a, (b, c)): ... +2 | def foo((a)): ... + | ^^^ Syntax Error: Function parameters cannot be parenthesized +3 | lambda (a,): ... + | + + + | +1 | def foo(a, (b, c)): ... +2 | def foo((a)): ... + | ^ Syntax Error: invalid syntax +3 | lambda (a,): ... + | + + + | +1 | def foo(a, (b, c)): ... +2 | def foo((a)): ... + | ^ Syntax Error: invalid syntax +3 | lambda (a,): ... + | + + + | +1 | def foo(a, (b, c)): ... +2 | def foo((a)): ... + | ^ Syntax Error: invalid syntax +3 | lambda (a,): ... + | + + + | +1 | def foo(a, (b, c)): ... +2 | def foo((a)): ... +3 | lambda (a,): ... + | ^^^^ Syntax Error: Lambda expression parameters cannot be parenthesized + + + | +1 | def foo(a, (b, c)): ... +2 | def foo((a)): ... +3 | lambda (a,): ... + | ^ Syntax Error: invalid syntax + + + | +1 | def foo(a, (b, c)): ... +2 | def foo((a)): ... +3 | lambda (a,): ... + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash_without_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash_without_comma.py.snap new file mode 100644 index 00000000000000..6b6ce76f842937 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_after_slash_without_comma.py.snap @@ -0,0 +1,175 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/params_star_after_slash_without_comma.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..44, + body: [ + FunctionDef( + StmtFunctionDef { + node_index: NodeIndex(None), + range: 0..22, + is_async: false, + decorator_list: [], + name: Identifier { + id: Name("foo"), + range: 4..7, + node_index: NodeIndex(None), + }, + type_params: None, + parameters: Parameters { + range: 7..17, + node_index: NodeIndex(None), + posonlyargs: [ + ParameterWithDefault { + range: 8..9, + node_index: NodeIndex(None), + parameter: Parameter { + range: 8..9, + node_index: NodeIndex(None), + name: Identifier { + id: Name("a"), + range: 8..9, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ], + args: [], + vararg: None, + kwonlyargs: [ + ParameterWithDefault { + range: 15..16, + node_index: NodeIndex(None), + parameter: Parameter { + range: 15..16, + node_index: NodeIndex(None), + name: Identifier { + id: Name("b"), + range: 15..16, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ], + kwarg: None, + runtime_defaults: None, + }, + returns: None, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 19..22, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 19..22, + }, + ), + }, + ), + ], + runtime_decorator_list: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 23..43, + value: Lambda( + ExprLambda { + node_index: NodeIndex(None), + range: 23..43, + parameters: Some( + Parameters { + range: 30..38, + node_index: NodeIndex(None), + posonlyargs: [ + ParameterWithDefault { + range: 30..31, + node_index: NodeIndex(None), + parameter: Parameter { + range: 30..31, + node_index: NodeIndex(None), + name: Identifier { + id: Name("a"), + range: 30..31, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ], + args: [], + vararg: None, + kwonlyargs: [ + ParameterWithDefault { + range: 37..38, + node_index: NodeIndex(None), + parameter: Parameter { + range: 37..38, + node_index: NodeIndex(None), + name: Identifier { + id: Name("b"), + range: 37..38, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ], + kwarg: None, + runtime_defaults: None, + }, + ), + body: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 40..43, + }, + ), + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | def foo(a, /*, b): ... + | ^ Syntax Error: expected comma between / and * +2 | lambda a, /*, b: ... + | + + + | +1 | def foo(a, /*, b): ... +2 | lambda a, /*, b: ... + | ^ Syntax Error: expected comma between / and * diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap index f2595929b94341..79e4b1a4578bf7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_star_separator_after_star_param.py.snap @@ -220,7 +220,7 @@ Module( | 1 | def foo(a, *args, *, b): ... - | ^ Syntax Error: keyword-only parameter separator not allowed after '*' parameter + | ^ Syntax Error: * argument may appear only once 2 | def foo(a, *args, b, c, *): ... | @@ -228,4 +228,4 @@ Module( | 1 | def foo(a, *args, *, b): ... 2 | def foo(a, *args, b, c, *): ... - | ^ Syntax Error: keyword-only parameter separator not allowed after '*' parameter + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap index 911d6a2c5fc6aa..aff252185e913b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_keyword_with_default.py.snap @@ -176,7 +176,7 @@ Module( | 1 | def foo(a, **kwargs={'b': 1, 'c': 2}): ... - | ^ Syntax Error: var-positional argument cannot have default value + | ^ Syntax Error: var-keyword argument cannot have default value | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap index 40bc0067cd3a66..b3111adddb8608 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@params_var_positional_with_default.py.snap @@ -13,7 +13,7 @@ Module( FunctionDef( StmtFunctionDef { node_index: NodeIndex(None), - range: 0..23, + range: 0..22, is_async: false, decorator_list: [], name: Identifier { @@ -23,7 +23,7 @@ Module( }, type_params: None, parameters: Parameters { - range: 7..17, + range: 7..18, node_index: NodeIndex(None), posonlyargs: [], args: [ @@ -68,11 +68,11 @@ Module( Expr( StmtExpr { node_index: NodeIndex(None), - range: 17..23, + range: 18..22, value: Tuple( ExprTuple { node_index: NodeIndex(None), - range: 17..23, + range: 18..22, elts: [ NumberLiteral( ExprNumberLiteral { @@ -94,7 +94,7 @@ Module( ), ], ctx: Load, - parenthesized: true, + parenthesized: false, runtime_elts: None, }, ), @@ -136,6 +136,16 @@ Module( | ^ Syntax Error: invalid syntax + | +1 | def foo(a, *args=(1, 2)): ... + | ^ Syntax Error: invalid syntax + + + | +1 | def foo(a, *args=(1, 2)): ... + | ^ Syntax Error: invalid syntax + + | 1 | def foo(a, *args=(1, 2)): ... | ^ Syntax Error: unmatched ')' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_double_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_double_starred_expr.py.snap new file mode 100644 index 00000000000000..bc0ad8f573c904 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_double_starred_expr.py.snap @@ -0,0 +1,36 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/parenthesized_double_starred_expr.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..6, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("x"), + ctx: Load, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | (**x) + | ^^ Syntax Error: cannot use double starred expression here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap index 37d650beb442f4..a7ad9c0cad0ec9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_kwarg_py38.py.snap @@ -162,6 +162,33 @@ Module( }, ) ``` +## Errors + + | +1 | # parse_options: {"target-version": "3.8"} +2 | f((a)=1) + | ^^^ Syntax Error: expression cannot contain assignment, perhaps you meant "=="? +3 | f((a) = 1) +4 | f( ( a ) = 1) + | + + + | +1 | # parse_options: {"target-version": "3.8"} +2 | f((a)=1) +3 | f((a) = 1) + | ^^^^ Syntax Error: expression cannot contain assignment, perhaps you meant "=="? +4 | f( ( a ) = 1) + | + + + | +2 | f((a)=1) +3 | f((a) = 1) +4 | f( ( a ) = 1) + | ^^^^^ Syntax Error: expression cannot contain assignment, perhaps you meant "=="? + + ## Unsupported Syntax Errors | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_starred_expr.py.snap new file mode 100644 index 00000000000000..7220ca81d80594 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@parenthesized_starred_expr.py.snap @@ -0,0 +1,43 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/parenthesized_starred_expr.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..5, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..4, + value: Starred( + ExprStarred { + node_index: NodeIndex(None), + range: 1..3, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 2..3, + id: Name("x"), + ctx: Load, + }, + ), + ctx: Load, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | (*x) + | ^^ Syntax Error: cannot use starred expression here diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap index 7532827636dfdd..5a2c48211dcd08 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@pep_798_invalid_dict_unpacking_comprehensions_py315.py.snap @@ -110,18 +110,11 @@ Module( }, ), ), - value: Starred( - ExprStarred { + value: Name( + ExprName { node_index: NodeIndex(None), - range: 74..76, - value: Name( - ExprName { - node_index: NodeIndex(None), - range: 75..76, - id: Name("v"), - ctx: Load, - }, - ), + range: 75..76, + id: Name("v"), ctx: Load, }, ), @@ -344,7 +337,7 @@ Module( 1 | # parse_options: {"target-version": "3.15"} 2 | {*k: v for k, v in items} 3 | {k: *v for k, v in items} - | ^ Syntax Error: invalid syntax + | ^^ Syntax Error: cannot use a starred expression in a dictionary value 4 | {**k: v for k, v in items} 5 | {k: **v for k, v in items} | 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 57bea42adbb5ed..514341167e9738 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 @@ -424,6 +424,17 @@ Module( | + | +3 | # https://github.com/astral-sh/ruff/issues/12004 +4 | +5 | / f'middle {'string':\ +6 | | 'format spec'} + | |_______________^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +7 | +8 | f'middle {'string':\\ + | + + | 5 | f'middle {'string':\ 6 | 'format spec'} @@ -496,6 +507,14 @@ Module( | ^ Syntax Error: f-string: expecting '}' + | + 9 | 'format spec'} +10 | +11 | / f'middle {'string':\\\ +12 | | 'format spec'} + | |_______________^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + | 11 | f'middle {'string':\\\ 12 | 'format spec'} diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap index aaadf59c35f59d..95840adce9e707 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_1.py.snap @@ -75,9 +75,12 @@ Module( ## Errors | -5 | f"""hello {x # comment -6 | y = 1 - | ^ Syntax Error: f-string: expecting '}' +3 | # https://github.com/astral-sh/ruff/issues/11929 +4 | +5 | f"""hello {x # comment + | ____________^ +6 | | y = 1 + | |_^ Syntax Error: invalid syntax. Perhaps you forgot a comma? | @@ -89,6 +92,12 @@ Module( | + | +5 | f"""hello {x # comment +6 | y = 1 + | ^ Syntax Error: f-string: expecting '}' + + | 3 | # https://github.com/astral-sh/ruff/issues/11929 4 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap index b5bb933fbb7339..3701134b56052a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap @@ -216,6 +216,27 @@ Module( | + | +1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 +2 | (c: int = 1,f"""{d=[ + | _____________^ +3 | | def a( + | |______^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +4 | class A: +5 | pass + | + + + | +1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 +2 | (c: int = 1,f"""{d=[ +3 | def a( + | ^ Syntax Error: invalid syntax +4 | class A: +5 | pass + | + + | 2 | (c: int = 1,f"""{d=[ 3 | def a( diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_missing_expression_in_brackets.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_missing_expression_in_brackets.py.snap new file mode 100644 index 00000000000000..7ef2bbcb82857f --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_missing_expression_in_brackets.py.snap @@ -0,0 +1,122 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/starred_missing_expression_in_brackets.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..15, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..7, + value: Call( + ExprCall { + node_index: NodeIndex(None), + range: 0..7, + func: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("f"), + ctx: Load, + }, + ), + arguments: Arguments { + range: 1..7, + node_index: NodeIndex(None), + args: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 2..3, + id: Name("x"), + ctx: Load, + }, + ), + Starred( + ExprStarred { + node_index: NodeIndex(None), + range: 5..6, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 6..6, + id: Name(""), + ctx: Invalid, + }, + ), + ctx: Load, + }, + ), + ], + keywords: [], + runtime_args: None, + runtime_bases: None, + }, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 8..14, + value: List( + ExprList { + node_index: NodeIndex(None), + range: 8..14, + elts: [ + Starred( + ExprStarred { + node_index: NodeIndex(None), + range: 9..10, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 10..10, + id: Name(""), + ctx: Invalid, + }, + ), + ctx: Load, + }, + ), + NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 12..13, + value: Int( + 1, + ), + }, + ), + ], + ctx: Load, + runtime_elts: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f(x, *) + | ^ Syntax Error: Invalid star expression +2 | [*, 1] + | + + + | +1 | f(x, *) +2 | [*, 1] + | ^ Syntax Error: Invalid star expression diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap index e499920e77e1a1..759013a2bea200 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@starred_starred_expression.py.snap @@ -124,7 +124,7 @@ Module( | 1 | print(* 2 | *[]) - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: Invalid star expression 3 | print(* *[]) | @@ -133,4 +133,4 @@ Module( 1 | print(* 2 | *[]) 3 | print(* *[]) - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: Invalid star expression diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap index aadfb0dd66cc02..1b11bbd7ec5afb 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statements__with__ambiguous_lpar_with_items.py.snap @@ -1701,7 +1701,7 @@ Module( 5 | with (item1, item2), as f: ... 6 | with (item1, item2), item3,: ... 7 | with (*item): ... - | ^ Syntax Error: invalid syntax + | ^^^^^ Syntax Error: cannot use starred expression here 8 | with (*item) as f: ... 9 | with (item := 10 as f): ... | @@ -1711,7 +1711,7 @@ Module( 6 | with (item1, item2), item3,: ... 7 | with (*item): ... 8 | with (*item) as f: ... - | ^ Syntax Error: invalid syntax + | ^^^^^ Syntax Error: cannot use starred expression here 9 | with (item := 10 as f): ... 10 | with (item1, item2 := 10 as f): ... | @@ -1788,7 +1788,7 @@ Module( | 14 | # Make sure the parser doesn't report the same error twice 15 | with ((*item)): ... - | ^ Syntax Error: invalid syntax + | ^^^^^ Syntax Error: cannot use starred expression here 16 | 17 | with (*x for x in iter, item): ... | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap index 3c07555e39200a..630ce68aa46059 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_param_spec_bound.py.snap @@ -13,7 +13,7 @@ Module( TypeAlias( StmtTypeAlias { node_index: NodeIndex(None), - range: 0..10, + range: 0..22, name: Name( ExprName { node_index: NodeIndex(None), @@ -24,13 +24,13 @@ Module( ), type_params: Some( TypeParams { - range: 6..10, + range: 6..16, node_index: NodeIndex(None), type_params: [ ParamSpec( TypeParamParamSpec { node_index: NodeIndex(None), - range: 7..10, + range: 7..15, name: Identifier { id: Name("T"), range: 9..10, @@ -43,34 +43,6 @@ Module( runtime_type_params: None, }, ), - value: Name( - ExprName { - node_index: NodeIndex(None), - range: 10..10, - id: Name(""), - ctx: Invalid, - }, - ), - }, - ), - Expr( - StmtExpr { - node_index: NodeIndex(None), - range: 12..15, - value: Name( - ExprName { - node_index: NodeIndex(None), - range: 12..15, - id: Name("int"), - ctx: Load, - }, - ), - }, - ), - Expr( - StmtExpr { - node_index: NodeIndex(None), - range: 19..22, value: Name( ExprName { node_index: NodeIndex(None), @@ -90,14 +62,4 @@ Module( | 1 | type X[**T: int] = int - | ^ Syntax Error: invalid syntax - - - | -1 | type X[**T: int] = int - | ^ Syntax Error: unmatched ']' - - - | -1 | type X[**T: int] = int - | ^ Syntax Error: invalid syntax + | ^^^^^ Syntax Error: cannot use bound with ParamSpec diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap index f6dc1d4a12764a..e03e2c8ffaff09 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@type_param_type_var_tuple_bound.py.snap @@ -13,7 +13,7 @@ Module( TypeAlias( StmtTypeAlias { node_index: NodeIndex(None), - range: 0..9, + range: 0..21, name: Name( ExprName { node_index: NodeIndex(None), @@ -24,13 +24,13 @@ Module( ), type_params: Some( TypeParams { - range: 6..9, + range: 6..15, node_index: NodeIndex(None), type_params: [ TypeVarTuple( TypeParamTypeVarTuple { node_index: NodeIndex(None), - range: 7..9, + range: 7..14, name: Identifier { id: Name("T"), range: 8..9, @@ -43,34 +43,6 @@ Module( runtime_type_params: None, }, ), - value: Name( - ExprName { - node_index: NodeIndex(None), - range: 9..9, - id: Name(""), - ctx: Invalid, - }, - ), - }, - ), - Expr( - StmtExpr { - node_index: NodeIndex(None), - range: 11..14, - value: Name( - ExprName { - node_index: NodeIndex(None), - range: 11..14, - id: Name("int"), - ctx: Load, - }, - ), - }, - ), - Expr( - StmtExpr { - node_index: NodeIndex(None), - range: 18..21, value: Name( ExprName { node_index: NodeIndex(None), @@ -90,14 +62,4 @@ Module( | 1 | type X[*T: int] = int - | ^ Syntax Error: invalid syntax - - - | -1 | type X[*T: int] = int - | ^ Syntax Error: unmatched ']' - - - | -1 | type X[*T: int] = int - | ^ Syntax Error: invalid syntax + | ^^^^^ Syntax Error: cannot use bound with TypeVarTuple diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap index 6a4fbb1a560d32..8c2919982a7c85 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap @@ -382,6 +382,18 @@ Module( | + | +1 | f"hello +2 | 1 + 1 +3 | f"hello {x + | __________^ +4 | | 2 + 2 + | |_____^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +5 | f"hello {x: +6 | 3 + 3 + | + + | 2 | 1 + 1 3 | f"hello {x diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap index 77a1fc598a0bbd..58a1b7e6ce3a21 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@with_items_parenthesized_missing_comma.py.snap @@ -353,6 +353,14 @@ Module( ``` ## Errors + | +1 | with (item1 item2): ... + | ^^^^^^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +2 | with (item1 as f1 item2): ... +3 | with (item1, item2 item3, item4): ... + | + + | 1 | with (item1 item2): ... | ^^^^^ Syntax Error: invalid syntax @@ -361,6 +369,15 @@ Module( | + | +1 | with (item1 item2): ... +2 | with (item1 as f1 item2): ... + | ^^^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +3 | with (item1, item2 item3, item4): ... +4 | with (item1, item2 as f1 item3, item4): ... + | + + | 1 | with (item1 item2): ... 2 | with (item1 as f1 item2): ... @@ -370,6 +387,16 @@ Module( | + | +1 | with (item1 item2): ... +2 | with (item1 as f1 item2): ... +3 | with (item1, item2 item3, item4): ... + | ^^^^^^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +4 | with (item1, item2 as f1 item3, item4): ... +5 | with (item1, item2: ... + | + + | 1 | with (item1 item2): ... 2 | with (item1 as f1 item2): ... @@ -380,6 +407,15 @@ Module( | + | +2 | with (item1 as f1 item2): ... +3 | with (item1, item2 item3, item4): ... +4 | with (item1, item2 as f1 item3, item4): ... + | ^^^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +5 | with (item1, item2: ... + | + + | 2 | with (item1 as f1 item2): ... 3 | with (item1, item2 item3, item4): ... From 4f922d2124f25a7bc27e5ee106ba6cd1677056e5 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 5 Oct 2026 05:02:24 +0900 Subject: [PATCH 14/20] Report remaining expression errors with CPython messages - `=` in a named expression position: "invalid syntax. Maybe you meant '==' or ':=' instead of '='?" or "cannot assign to X here". - Expressions between two string literals. - `pass`/`break`/`continue` before `if` and a statement after `else` in an `if` expression. - Missing `in` after comprehension targets, and unparenthesized tuple comprehension targets in lists and sets. - Invalid `:=` targets at statement level. Assisted-by: Claude Code:claude-opus-5-5 --- .../err/assignment_instead_of_comparison.py | 4 + .../inline/err/comprehension_missing_in.py | 2 + .../comprehension_unparenthesized_target.py | 2 + .../inline/err/expression_between_strings.py | 3 + .../err/if_expr_statement_after_else.py | 3 + .../named_expr_statement_invalid_target.py | 2 + .../err/statement_before_if_expression.py | 2 + .../src/parser/expression.rs | 226 ++++++++++++- .../src/parser/statement.rs | 35 +- ...x@assignment_instead_of_comparison.py.snap | 301 +++++++++++++++++ ...id_syntax@comprehension_missing_in.py.snap | 210 ++++++++++++ ...mprehension_unparenthesized_target.py.snap | 201 +++++++++++ ..._syntax@expression_between_strings.py.snap | 317 ++++++++++++++++++ ...ressions__bin_op__named_expression.py.snap | 13 + ...essions__bool_op__named_expression.py.snap | 13 + ...essions__compare__named_expression.py.snap | 13 + ...essions__if__missing_orelse_expr_0.py.snap | 2 +- ...essions__if__missing_orelse_expr_1.py.snap | 2 +- ...id_syntax@expressions__if__recover.py.snap | 6 +- ...x@expressions__list__comprehension.py.snap | 21 +- .../invalid_syntax@expressions__unary.py.snap | 5 + ...pressions__unary__named_expression.py.snap | 13 + ...yntax@if_expr_statement_after_else.py.snap | 202 +++++++++++ .../invalid_syntax@named_expr_slice.py.snap | 32 ++ ...amed_expr_statement_invalid_target.py.snap | 128 +++++++ ...tax@statement_before_if_expression.py.snap | 139 ++++++++ 26 files changed, 1884 insertions(+), 13 deletions(-) create mode 100644 crates/ruff_python_parser/resources/inline/err/assignment_instead_of_comparison.py create mode 100644 crates/ruff_python_parser/resources/inline/err/comprehension_missing_in.py create mode 100644 crates/ruff_python_parser/resources/inline/err/comprehension_unparenthesized_target.py create mode 100644 crates/ruff_python_parser/resources/inline/err/expression_between_strings.py create mode 100644 crates/ruff_python_parser/resources/inline/err/if_expr_statement_after_else.py create mode 100644 crates/ruff_python_parser/resources/inline/err/named_expr_statement_invalid_target.py create mode 100644 crates/ruff_python_parser/resources/inline/err/statement_before_if_expression.py create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@assignment_instead_of_comparison.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_in.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_unparenthesized_target.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@expression_between_strings.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_expr_statement_after_else.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_statement_invalid_target.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@statement_before_if_expression.py.snap diff --git a/crates/ruff_python_parser/resources/inline/err/assignment_instead_of_comparison.py b/crates/ruff_python_parser/resources/inline/err/assignment_instead_of_comparison.py new file mode 100644 index 00000000000000..0c63c0d80080b2 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/assignment_instead_of_comparison.py @@ -0,0 +1,4 @@ +if x = 3: ... +while x.a = 3: ... +[x, y = 1] +if x = 3 = 4: ... diff --git a/crates/ruff_python_parser/resources/inline/err/comprehension_missing_in.py b/crates/ruff_python_parser/resources/inline/err/comprehension_missing_in.py new file mode 100644 index 00000000000000..724e9394f72ba7 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/comprehension_missing_in.py @@ -0,0 +1,2 @@ +[x for x if y] +[x for a, b y] diff --git a/crates/ruff_python_parser/resources/inline/err/comprehension_unparenthesized_target.py b/crates/ruff_python_parser/resources/inline/err/comprehension_unparenthesized_target.py new file mode 100644 index 00000000000000..678f0bb59d53b4 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/comprehension_unparenthesized_target.py @@ -0,0 +1,2 @@ +[x, y for x, y in z] +{x, for x in z} diff --git a/crates/ruff_python_parser/resources/inline/err/expression_between_strings.py b/crates/ruff_python_parser/resources/inline/err/expression_between_strings.py new file mode 100644 index 00000000000000..d914f7ef4e7065 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/expression_between_strings.py @@ -0,0 +1,3 @@ +"a" b "c" +x = "a" 1 + 2 c "d" +["a" b "c"] diff --git a/crates/ruff_python_parser/resources/inline/err/if_expr_statement_after_else.py b/crates/ruff_python_parser/resources/inline/err/if_expr_statement_after_else.py new file mode 100644 index 00000000000000..864a84363ead54 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/if_expr_statement_after_else.py @@ -0,0 +1,3 @@ +x = 1 if 1 else pass +x = 1 if 1 else +x = 1 if 1 else yield 2 diff --git a/crates/ruff_python_parser/resources/inline/err/named_expr_statement_invalid_target.py b/crates/ruff_python_parser/resources/inline/err/named_expr_statement_invalid_target.py new file mode 100644 index 00000000000000..e95e2dc5d9634c --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/named_expr_statement_invalid_target.py @@ -0,0 +1,2 @@ +x + y := 1 +a.b := 1 diff --git a/crates/ruff_python_parser/resources/inline/err/statement_before_if_expression.py b/crates/ruff_python_parser/resources/inline/err/statement_before_if_expression.py new file mode 100644 index 00000000000000..7b080b1c3bc7cc --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/statement_before_if_expression.py @@ -0,0 +1,2 @@ +x = pass if 1 else 1 +pass if 1 else pass diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 9e308a2055b339..60e8081166b434 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -182,6 +182,17 @@ impl<'src> Parser<'src> { pub(super) fn parse_named_expression_or_higher( &mut self, context: ExpressionContext, + ) -> ParsedExpr { + let parsed_expr = self.parse_named_expression_without_assignment_check(context); + self.check_assignment_instead_of_comparison(&parsed_expr); + parsed_expr + } + + /// Parses a named expression or higher without reporting an `=` after it, which starts a + /// keyword argument in a call. + fn parse_named_expression_without_assignment_check( + &mut self, + context: ExpressionContext, ) -> ParsedExpr { let start = self.node_start(); let parsed_expr = self.parse_conditional_expression_or_higher_impl(context); @@ -213,11 +224,148 @@ impl<'src> Parser<'src> { &mut self, context: ExpressionContext, ) -> ParsedExpr { + if matches!( + self.current_token_kind(), + TokenKind::Pass | TokenKind::Break | TokenKind::Continue + ) { + self.check_statement_before_if_expression(); + } let parsed_expr = self.parse_conditional_expression_without_comma_check(context); - self.check_missing_comma(&parsed_expr); + if !self.check_expression_between_strings(&parsed_expr) { + self.check_missing_comma(&parsed_expr); + } parsed_expr } + /// Reports a `pass`, `break` or `continue` statement used as the body of an `if` + /// expression, as in `pass if x else y`. + pub(super) fn check_statement_before_if_expression(&mut self) { + // test_err statement_before_if_expression + // x = pass if 1 else 1 + // pass if 1 else pass + if self.peek() != TokenKind::If { + return; + } + let statement_range = self.current_token_range(); + let checkpoint = self.checkpoint(); + self.bump(self.current_token_kind()); + self.bump(TokenKind::If); + self.parse_simple_expression(ExpressionContext::default()); + let found = self.eat(TokenKind::Else) + && (self.at_expr() + || matches!( + self.current_token_kind(), + TokenKind::Pass + | TokenKind::Break + | TokenKind::Continue + | TokenKind::Return + | TokenKind::Raise + | TokenKind::Global + | TokenKind::Nonlocal + | TokenKind::Del + | TokenKind::Assert + | TokenKind::Import + | TokenKind::From + )); + self.rewind(checkpoint); + if found { + self.add_error( + ParseErrorType::OtherError( + "expected expression before 'if', but statement is given".to_string(), + ), + statement_range, + ); + } + } + + /// Reports expressions between two string literals, as in `"a" b "c"`, and returns `true` if + /// it did. + fn check_expression_between_strings(&mut self, first: &ParsedExpr) -> bool { + // test_err expression_between_strings + // "a" b "c" + // x = "a" 1 + 2 c "d" + // ["a" b "c"] + let single_string = match &first.expr { + Expr::StringLiteral(string) => !string.value.is_implicit_concatenated(), + Expr::BytesLiteral(bytes) => !bytes.value.is_implicit_concatenated(), + _ => false, + }; + if !single_string || first.is_parenthesized || !self.at_expr() || self.at(TokenKind::String) + { + return false; + } + + let checkpoint = self.checkpoint(); + let start = self.node_start(); + let mut end = start; + while self.at_expr() && !self.at(TokenKind::String) { + end = self + .parse_conditional_expression_without_comma_check(ExpressionContext::default()) + .end(); + } + let found = self.at(TokenKind::String); + self.rewind(checkpoint); + if found { + self.add_error( + ParseErrorType::OtherError( + "invalid syntax. Is this intended to be part of the string?".to_string(), + ), + TextRange::new(start, end), + ); + } + found + } + + /// Reports an `=` after a named expression where `==` or `:=` may have been meant. + fn check_assignment_instead_of_comparison(&mut self, target: &ParsedExpr) { + // test_err assignment_instead_of_comparison + // if x = 3: ... + // while x.a = 3: ... + // [x, y = 1] + // if x = 3 = 4: ... + if !self.at(TokenKind::Equal) + || !self.is_bitwise_or(&target.expr) + || self.starts_with_display_or_constant(&target.expr) + { + return; + } + + let checkpoint = self.checkpoint(); + self.bump(TokenKind::Equal); + let value_end = if self.at_expr() { + let value = self.parse_simple_expression(ExpressionContext::default()); + self.bitwise_or_prefix(&value.expr) + .filter(|value| { + !matches!( + self.token_kind_after(self.parenthesized_end(value.range())), + TokenKind::Equal | TokenKind::ColonEqual + ) + }) + .map(Ranged::end) + } else { + None + }; + self.rewind(checkpoint); + + let Some(value_end) = value_end else { + return; + }; + if target.expr.is_name_expr() && !target.is_parenthesized { + self.add_error( + ParseErrorType::AssignmentInsteadOfComparison, + TextRange::new(target.start(), value_end), + ); + } else { + self.add_error( + ParseErrorType::InvalidAssignmentTarget { + kind: ExpressionKind::of(&target.expr), + maybe_comparison: true, + }, + target.expr.range(), + ); + } + } + fn parse_conditional_expression_without_comma_check( &mut self, context: ExpressionContext, @@ -841,8 +989,9 @@ impl<'src> Parser<'src> { seen_keyword_unpacking = true; } else { let start = parser.node_start(); - let mut parsed_expr = parser - .parse_named_expression_or_higher(ExpressionContext::starred_conditional()); + let mut parsed_expr = parser.parse_named_expression_without_assignment_check( + ExpressionContext::starred_conditional(), + ); match parser.current_token_kind() { TokenKind::Async | TokenKind::For => { @@ -2646,6 +2795,7 @@ impl<'src> Parser<'src> { .expr; parser.expr_scratch.push(element); }); + self.check_unparenthesized_comprehension_target(start); self.expect(TokenKind::Rsqb); @@ -2658,6 +2808,28 @@ impl<'src> Parser<'src> { } } + /// Reports a comprehension whose target is an unparenthesized tuple, as in + /// `[x, y for x, y in z]`. The elements of the list or set starting at `start` have been + /// parsed. + fn check_unparenthesized_comprehension_target(&mut self, start: TextSize) { + // test_err comprehension_unparenthesized_target + // [x, y for x, y in z] + // {x, for x in z} + if !matches!(self.current_token_kind(), TokenKind::For | TokenKind::Async) { + return; + } + let first_start = self.token_after(start + TextSize::from(1)).1.start(); + let end = self + .token_before(self.current_token_range().start()) + .map_or(first_start, |(_, range)| range.end()); + self.add_error( + ParseErrorType::OtherError( + "did you forget parentheses around the comprehension target?".to_string(), + ), + TextRange::new(first_start, end), + ); + } + /// Parses a set expression. /// /// See: @@ -2699,6 +2871,7 @@ impl<'src> Parser<'src> { parser.expr_scratch.push(parsed_expr.expr); }); + self.check_unparenthesized_comprehension_target(start); self.expect(TokenKind::Rbrace); @@ -2846,9 +3019,37 @@ impl<'src> Parser<'src> { self.bump(TokenKind::For); } + // The targets are a list of `bitwise_or` expressions that must be followed by `in`. + let checkpoint = self.checkpoint(); + while self.at_expr() { + self.eat(TokenKind::Star); + self.parse_simple_expression(ExpressionContext::default().with_in_excluded()); + if !self.eat(TokenKind::Comma) { + break; + } + } + let missing_in = (!self.at(TokenKind::In)).then(|| self.current_token_range()); + self.rewind(checkpoint); + let errors_before_target = self.errors.len(); + let mut target = self.parse_expression_list(ExpressionContext::starred_conditional().with_in_excluded()); + if let Some(range) = missing_in { + // test_err comprehension_missing_in + // [x for x if y] + // [x for a, b y] + self.errors.insert( + errors_before_target, + ParseError { + error: ParseErrorType::OtherError( + "'in' expected after for-loop variables".to_string(), + ), + location: range, + }, + ); + } + helpers::set_expr_ctx(&mut target.expr, ExprContext::Store); self.validate_for_target(&target.expr); @@ -3249,7 +3450,24 @@ impl<'src> Parser<'src> { let test = self.parse_simple_expression(ExpressionContext::default()); - self.expect(TokenKind::Else); + if self.expect(TokenKind::Else) + && (!self.at_expr() + || matches!( + self.current_token_kind(), + TokenKind::Star | TokenKind::DoubleStar | TokenKind::Yield + )) + { + // test_err if_expr_statement_after_else + // x = 1 if 1 else pass + // x = 1 if 1 else + // x = 1 if 1 else yield 2 + self.add_error( + ParseErrorType::OtherError( + "expected expression after 'else', but statement is given".to_string(), + ), + self.current_token_range(), + ); + } // The binary-expression guard has already returned before parsing the `else` branch. let orelse = self.with_recursion(Self::parse_conditional_expression_or_higher); diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index f156f78f5af2b8..b78dba62251cfb 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -265,6 +265,12 @@ impl<'src> Parser<'src> { /// /// See: fn parse_simple_statement(&mut self) -> Stmt { + if matches!( + self.current_token_kind(), + TokenKind::Pass | TokenKind::Break | TokenKind::Continue + ) { + self.check_statement_before_if_expression(); + } match self.current_token_kind() { TokenKind::Return => Stmt::Return(self.parse_return_statement()), TokenKind::Import => { @@ -364,6 +370,29 @@ impl<'src> Parser<'src> { let parsed_expr = self.parse_expression_list(ExpressionContext::yield_or_starred_bitwise_or()); + if self.at(TokenKind::ColonEqual) { + // test_err named_expr_statement_invalid_target + // x + y := 1 + // a.b := 1 + let target = match &parsed_expr.expr { + Expr::Tuple(tuple) if !parsed_expr.is_parenthesized => tuple.elts.last(), + expr => Some(expr), + }; + if let Some(target) = target.filter(|target| { + !matches!( + target, + Expr::Name(_) | Expr::Starred(_) | Expr::Yield(_) | Expr::YieldFrom(_) + ) + }) { + self.add_error( + ParseErrorType::InvalidNamedAssignmentTarget(ExpressionKind::of( + target, + )), + target.range(), + ); + } + } + if self.at(TokenKind::Equal) { Stmt::Assign(self.parse_assign_statement(parsed_expr, start)) } else if self.at(TokenKind::Colon) { @@ -4126,7 +4155,7 @@ impl<'src> Parser<'src> { } /// Returns `true` if `expr` is a `bitwise_or` expression or any parenthesized expression. - fn is_bitwise_or(&self, expr: &Expr) -> bool { + pub(super) fn is_bitwise_or(&self, expr: &Expr) -> bool { if self.is_parenthesized(expr.range()) { return true; } @@ -4148,7 +4177,7 @@ impl<'src> Parser<'src> { /// Returns `true` if `expr` starts with a list or tuple display, a parenthesized generator /// expression, `True`, `False` or `None`. - fn starts_with_display_or_constant(&self, mut expr: &Expr) -> bool { + pub(super) fn starts_with_display_or_constant(&self, mut expr: &Expr) -> bool { loop { if self.is_parenthesized(expr.range()) { return false; @@ -4167,7 +4196,7 @@ impl<'src> Parser<'src> { } /// Returns the `bitwise_or` expression that `expr` starts with, if any. - fn bitwise_or_prefix<'a>(&self, mut expr: &'a Expr) -> Option<&'a Expr> { + pub(super) fn bitwise_or_prefix<'a>(&self, mut expr: &'a Expr) -> Option<&'a Expr> { loop { if self.is_parenthesized(expr.range()) { return Some(expr); diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assignment_instead_of_comparison.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assignment_instead_of_comparison.py.snap new file mode 100644 index 00000000000000..b983a854ab3eae --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@assignment_instead_of_comparison.py.snap @@ -0,0 +1,301 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/assignment_instead_of_comparison.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..62, + body: [ + If( + StmtIf { + node_index: NodeIndex(None), + range: 0..4, + test: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("x"), + ctx: Load, + }, + ), + body: [], + elif_else_clauses: [], + runtime_body: None, + }, + ), + AnnAssign( + StmtAnnAssign { + node_index: NodeIndex(None), + range: 7..13, + target: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 7..8, + value: Int( + 3, + ), + }, + ), + annotation: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 10..13, + }, + ), + value: None, + simple: false, + runtime_simple: None, + }, + ), + While( + StmtWhile { + node_index: NodeIndex(None), + range: 14..23, + test: Attribute( + ExprAttribute { + node_index: NodeIndex(None), + range: 20..23, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 20..21, + id: Name("x"), + ctx: Load, + }, + ), + attr: Identifier { + id: Name("a"), + range: 22..23, + node_index: NodeIndex(None), + }, + ctx: Load, + }, + ), + body: [], + orelse: [], + runtime_body: None, + runtime_orelse: None, + }, + ), + AnnAssign( + StmtAnnAssign { + node_index: NodeIndex(None), + range: 26..32, + target: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 26..27, + value: Int( + 3, + ), + }, + ), + annotation: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 29..32, + }, + ), + value: None, + simple: false, + runtime_simple: None, + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 33..43, + value: List( + ExprList { + node_index: NodeIndex(None), + range: 33..43, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 34..35, + id: Name("x"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 37..38, + id: Name("y"), + ctx: Load, + }, + ), + NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 41..42, + value: Int( + 1, + ), + }, + ), + ], + ctx: Load, + runtime_elts: None, + }, + ), + }, + ), + If( + StmtIf { + node_index: NodeIndex(None), + range: 44..48, + test: Name( + ExprName { + node_index: NodeIndex(None), + range: 47..48, + id: Name("x"), + ctx: Load, + }, + ), + body: [], + elif_else_clauses: [], + runtime_body: None, + }, + ), + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 51..56, + targets: [ + NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 51..52, + value: Int( + 3, + ), + }, + ), + ], + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 55..56, + value: Int( + 4, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 58..61, + value: EllipsisLiteral( + ExprEllipsisLiteral { + node_index: NodeIndex(None), + range: 58..61, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | if x = 3: ... + | ^^^^^ Syntax Error: invalid syntax. Maybe you meant '==' or ':=' instead of '='? +2 | while x.a = 3: ... +3 | [x, y = 1] + | + + + | +1 | if x = 3: ... + | ^ Syntax Error: invalid syntax +2 | while x.a = 3: ... +3 | [x, y = 1] + | + + + | +1 | if x = 3: ... + | ^ Syntax Error: illegal target for annotation +2 | while x.a = 3: ... +3 | [x, y = 1] + | + + + | +1 | if x = 3: ... +2 | while x.a = 3: ... + | ^^^ Syntax Error: cannot assign to attribute here. Maybe you meant '==' instead of '='? +3 | [x, y = 1] +4 | if x = 3 = 4: ... + | + + + | +1 | if x = 3: ... +2 | while x.a = 3: ... + | ^ Syntax Error: invalid syntax +3 | [x, y = 1] +4 | if x = 3 = 4: ... + | + + + | +1 | if x = 3: ... +2 | while x.a = 3: ... + | ^ Syntax Error: illegal target for annotation +3 | [x, y = 1] +4 | if x = 3 = 4: ... + | + + + | +1 | if x = 3: ... +2 | while x.a = 3: ... +3 | [x, y = 1] + | ^^^^^ Syntax Error: invalid syntax. Maybe you meant '==' or ':=' instead of '='? +4 | if x = 3 = 4: ... + | + + + | +1 | if x = 3: ... +2 | while x.a = 3: ... +3 | [x, y = 1] + | ^ Syntax Error: invalid syntax +4 | if x = 3 = 4: ... + | + + + | +2 | while x.a = 3: ... +3 | [x, y = 1] +4 | if x = 3 = 4: ... + | ^ Syntax Error: invalid syntax + + + | +2 | while x.a = 3: ... +3 | [x, y = 1] +4 | if x = 3 = 4: ... + | ^ Syntax Error: cannot assign to literal here. Maybe you meant '==' instead of '='? + + + | +2 | while x.a = 3: ... +3 | [x, y = 1] +4 | if x = 3 = 4: ... + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_in.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_in.py.snap new file mode 100644 index 00000000000000..86fe5d9fec3413 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_missing_in.py.snap @@ -0,0 +1,210 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/comprehension_missing_in.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..30, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..14, + value: ListComp( + ExprListComp { + node_index: NodeIndex(None), + range: 0..14, + elt: Name( + ExprName { + node_index: NodeIndex(None), + range: 1..2, + id: Name("x"), + ctx: Load, + }, + ), + generators: [ + Comprehension { + range: 3..13, + node_index: NodeIndex(None), + target: If( + ExprIf { + node_index: NodeIndex(None), + range: 7..13, + test: Name( + ExprName { + node_index: NodeIndex(None), + range: 12..13, + id: Name("y"), + ctx: Load, + }, + ), + body: Name( + ExprName { + node_index: NodeIndex(None), + range: 7..8, + id: Name("x"), + ctx: Load, + }, + ), + orelse: Name( + ExprName { + node_index: NodeIndex(None), + range: 13..13, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + iter: Name( + ExprName { + node_index: NodeIndex(None), + range: 13..13, + id: Name(""), + ctx: Invalid, + }, + ), + ifs: [], + is_async: false, + runtime_ifs: None, + runtime_is_async: None, + }, + ], + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 15..29, + value: ListComp( + ExprListComp { + node_index: NodeIndex(None), + range: 15..29, + elt: Name( + ExprName { + node_index: NodeIndex(None), + range: 16..17, + id: Name("x"), + ctx: Load, + }, + ), + generators: [ + Comprehension { + range: 18..28, + node_index: NodeIndex(None), + target: Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 22..28, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 22..23, + id: Name("a"), + ctx: Store, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 25..26, + id: Name("b"), + ctx: Store, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 27..28, + id: Name("y"), + ctx: Store, + }, + ), + ], + ctx: Store, + parenthesized: false, + runtime_elts: None, + }, + ), + iter: Name( + ExprName { + node_index: NodeIndex(None), + range: 28..28, + id: Name(""), + ctx: Invalid, + }, + ), + ifs: [], + is_async: false, + runtime_ifs: None, + runtime_is_async: None, + }, + ], + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | [x for x if y] + | ^^ Syntax Error: 'in' expected after for-loop variables +2 | [x for a, b y] + | + + + | +1 | [x for x if y] + | ^ Syntax Error: expected 'else' after 'if' expression +2 | [x for a, b y] + | + + + | +1 | [x for x if y] + | ^^^^^^ Syntax Error: cannot assign to conditional expression +2 | [x for a, b y] + | + + + | +1 | [x for x if y] + | ^ Syntax Error: invalid syntax +2 | [x for a, b y] + | + + + | +1 | [x for x if y] +2 | [x for a, b y] + | ^ Syntax Error: 'in' expected after for-loop variables + + + | +1 | [x for x if y] +2 | [x for a, b y] + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + + | +1 | [x for x if y] +2 | [x for a, b y] + | ^ Syntax Error: invalid syntax + + + | +1 | [x for x if y] +2 | [x for a, b y] + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_unparenthesized_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_unparenthesized_target.py.snap new file mode 100644 index 00000000000000..44f1b9f6cf7b43 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@comprehension_unparenthesized_target.py.snap @@ -0,0 +1,201 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/comprehension_unparenthesized_target.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..37, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: List( + ExprList { + node_index: NodeIndex(None), + range: 0..5, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 1..2, + id: Name("x"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 4..5, + id: Name("y"), + ctx: Load, + }, + ), + ], + ctx: Load, + runtime_elts: None, + }, + ), + }, + ), + For( + StmtFor { + node_index: NodeIndex(None), + range: 6..19, + is_async: false, + target: Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 10..14, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 10..11, + id: Name("x"), + ctx: Store, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 13..14, + id: Name("y"), + ctx: Store, + }, + ), + ], + ctx: Store, + parenthesized: false, + runtime_elts: None, + }, + ), + iter: Name( + ExprName { + node_index: NodeIndex(None), + range: 18..19, + id: Name("z"), + ctx: Load, + }, + ), + body: [], + orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 21..24, + value: Set( + ExprSet { + node_index: NodeIndex(None), + range: 21..24, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 22..23, + id: Name("x"), + ctx: Load, + }, + ), + ], + runtime_elts: None, + }, + ), + }, + ), + For( + StmtFor { + node_index: NodeIndex(None), + range: 25..35, + is_async: false, + target: Name( + ExprName { + node_index: NodeIndex(None), + range: 29..30, + id: Name("x"), + ctx: Store, + }, + ), + iter: Name( + ExprName { + node_index: NodeIndex(None), + range: 34..35, + id: Name("z"), + ctx: Load, + }, + ), + body: [], + orelse: [], + runtime_type_comment: None, + runtime_type_comment_bytes: None, + runtime_body: None, + runtime_orelse: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | [x, y for x, y in z] + | ^^^^ Syntax Error: did you forget parentheses around the comprehension target? +2 | {x, for x in z} + | + + + | +1 | [x, y for x, y in z] + | ^^^ Syntax Error: invalid syntax +2 | {x, for x in z} + | + + + | +1 | [x, y for x, y in z] + | ^ Syntax Error: unmatched ']' +2 | {x, for x in z} + | + + + | +1 | [x, y for x, y in z] + | ^ Syntax Error: invalid syntax +2 | {x, for x in z} + | + + + | +1 | [x, y for x, y in z] +2 | {x, for x in z} + | ^^ Syntax Error: did you forget parentheses around the comprehension target? + + + | +1 | [x, y for x, y in z] +2 | {x, for x in z} + | ^^^ Syntax Error: invalid syntax + + + | +1 | [x, y for x, y in z] +2 | {x, for x in z} + | ^ Syntax Error: unmatched '}' + + + | +1 | [x, y for x, y in z] +2 | {x, for x in z} + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expression_between_strings.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expression_between_strings.py.snap new file mode 100644 index 00000000000000..8dd55bd9432deb --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expression_between_strings.py.snap @@ -0,0 +1,317 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/expression_between_strings.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..42, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..3, + value: StringLiteral( + ExprStringLiteral { + node_index: NodeIndex(None), + range: 0..3, + value: StringLiteralValue { + inner: Single( + StringLiteral { + range: 0..3, + node_index: NodeIndex(None), + value: "a", + flags: StringLiteralFlags { + quote_style: Double, + prefix: Empty, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 4..5, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 4..5, + id: Name("b"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 6..9, + value: StringLiteral( + ExprStringLiteral { + node_index: NodeIndex(None), + range: 6..9, + value: StringLiteralValue { + inner: Single( + StringLiteral { + range: 6..9, + node_index: NodeIndex(None), + value: "c", + flags: StringLiteralFlags { + quote_style: Double, + prefix: Empty, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + }, + ), + }, + ), + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 10..17, + targets: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 10..11, + id: Name("x"), + ctx: Store, + }, + ), + ], + value: StringLiteral( + ExprStringLiteral { + node_index: NodeIndex(None), + range: 14..17, + value: StringLiteralValue { + inner: Single( + StringLiteral { + range: 14..17, + node_index: NodeIndex(None), + value: "a", + flags: StringLiteralFlags { + quote_style: Double, + prefix: Empty, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 18..23, + value: BinOp( + ExprBinOp { + node_index: NodeIndex(None), + range: 18..23, + left: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 18..19, + value: Int( + 1, + ), + }, + ), + op: Add, + right: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 22..23, + value: Int( + 2, + ), + }, + ), + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 24..25, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 24..25, + id: Name("c"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 26..29, + value: StringLiteral( + ExprStringLiteral { + node_index: NodeIndex(None), + range: 26..29, + value: StringLiteralValue { + inner: Single( + StringLiteral { + range: 26..29, + node_index: NodeIndex(None), + value: "d", + flags: StringLiteralFlags { + quote_style: Double, + prefix: Empty, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 30..41, + value: List( + ExprList { + node_index: NodeIndex(None), + range: 30..41, + elts: [ + StringLiteral( + ExprStringLiteral { + node_index: NodeIndex(None), + range: 31..34, + value: StringLiteralValue { + inner: Single( + StringLiteral { + range: 31..34, + node_index: NodeIndex(None), + value: "a", + flags: StringLiteralFlags { + quote_style: Double, + prefix: Empty, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 35..36, + id: Name("b"), + ctx: Load, + }, + ), + StringLiteral( + ExprStringLiteral { + node_index: NodeIndex(None), + range: 37..40, + value: StringLiteralValue { + inner: Single( + StringLiteral { + range: 37..40, + node_index: NodeIndex(None), + value: "c", + flags: StringLiteralFlags { + quote_style: Double, + prefix: Empty, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + }, + ), + ], + ctx: Load, + runtime_elts: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | "a" b "c" + | ^ Syntax Error: invalid syntax. Is this intended to be part of the string? +2 | x = "a" 1 + 2 c "d" +3 | ["a" b "c"] + | + + + | +1 | "a" b "c" + | ^^^ Syntax Error: invalid syntax +2 | x = "a" 1 + 2 c "d" +3 | ["a" b "c"] + | + + + | +1 | "a" b "c" +2 | x = "a" 1 + 2 c "d" + | ^^^^^^^ Syntax Error: invalid syntax. Is this intended to be part of the string? +3 | ["a" b "c"] + | + + + | +1 | "a" b "c" +2 | x = "a" 1 + 2 c "d" + | ^ Syntax Error: invalid syntax +3 | ["a" b "c"] + | + + + | +1 | "a" b "c" +2 | x = "a" 1 + 2 c "d" + | ^^^ Syntax Error: invalid syntax +3 | ["a" b "c"] + | + + + | +1 | "a" b "c" +2 | x = "a" 1 + 2 c "d" +3 | ["a" b "c"] + | ^ Syntax Error: invalid syntax. Is this intended to be part of the string? + + + | +1 | "a" b "c" +2 | x = "a" 1 + 2 c "d" +3 | ["a" b "c"] + | ^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap index a9267d530552bd..2d9c00332414dc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bin_op__named_expression.py.snap @@ -125,6 +125,13 @@ Module( ``` ## Errors + | +1 | x - y := (1, 2) + | ^^^^^ Syntax Error: cannot use assignment expressions with expression +2 | x / y := 2 + | + + | 1 | x - y := (1, 2) | ^^ Syntax Error: invalid syntax @@ -132,6 +139,12 @@ Module( | + | +1 | x - y := (1, 2) +2 | x / y := 2 + | ^^^^^ Syntax Error: cannot use assignment expressions with expression + + | 1 | x - y := (1, 2) 2 | x / y := 2 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap index 70142d071d599f..14b0d9d4273068 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__bool_op__named_expression.py.snap @@ -109,6 +109,13 @@ Module( ``` ## Errors + | +1 | x and a := b + | ^^^^^^^ Syntax Error: cannot use assignment expressions with expression +2 | x or a := b + | + + | 1 | x and a := b | ^^ Syntax Error: invalid syntax @@ -116,6 +123,12 @@ Module( | + | +1 | x and a := b +2 | x or a := b + | ^^^^^^ Syntax Error: cannot use assignment expressions with expression + + | 1 | x and a := b 2 | x or a := b diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap index 4152869dc8446c..d9489e36625e2d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__compare__named_expression.py.snap @@ -135,6 +135,13 @@ Module( ``` ## Errors + | +1 | x not in y := (1, 2) + | ^^^^^^^^^^ Syntax Error: cannot use assignment expressions with comparison +2 | x > y := 2 + | + + | 1 | x not in y := (1, 2) | ^^ Syntax Error: invalid syntax @@ -142,6 +149,12 @@ Module( | + | +1 | x not in y := (1, 2) +2 | x > y := 2 + | ^^^^^ Syntax Error: cannot use assignment expressions with comparison + + | 1 | x not in y := (1, 2) 2 | x > y := 2 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap index 3e2d753e67f93b..26f7b9016ce786 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_0.py.snap @@ -93,7 +93,7 @@ Module( | 1 | # Missing orelse expression, followed by a statement 2 | x if expr else - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: expected expression after 'else', but statement is given 3 | 4 | def foo(): 5 | pass diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap index 367c97b5b28385..ed61643581245d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__missing_orelse_expr_1.py.snap @@ -87,7 +87,7 @@ Module( | 1 | # Missing orelse expression, followed by an expression 2 | x if expr else - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: expected expression after 'else', but statement is given 3 | 4 | 1 + 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap index 3e919888a8bb13..9121efdb7195de 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__if__recover.py.snap @@ -388,7 +388,7 @@ Module( | 7 | # Invalid orelse expression 8 | x if expr else *orelse - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: expected expression after 'else', but statement is given 9 | x if expr else yield y 10 | x if expr else yield from y | @@ -398,7 +398,7 @@ Module( 7 | # Invalid orelse expression 8 | x if expr else *orelse 9 | x if expr else yield y - | ^^^^^^^ Syntax Error: yield expression cannot be used here + | ^^^^^ Syntax Error: expected expression after 'else', but statement is given 10 | x if expr else yield from y | @@ -407,4 +407,4 @@ Module( 8 | x if expr else *orelse 9 | x if expr else yield y 10 | x if expr else yield from y - | ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used here + | ^^^^^ Syntax Error: expected expression after 'else', but statement is given diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap index 6c440db3638dad..91fe18e3f438a5 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__list__comprehension.py.snap @@ -1230,6 +1230,15 @@ Module( | + | +11 | [x for x in lambda y: y] +12 | [**x for x in [{1: 2}]] +13 | [*x, for x in y] + | ^^^ Syntax Error: did you forget parentheses around the comprehension target? +14 | [*x, *y for x in y] + | + + | 11 | [x for x in lambda y: y] 12 | [**x for x in [{1: 2}]] @@ -1259,6 +1268,16 @@ Module( | + | +12 | [**x for x in [{1: 2}]] +13 | [*x, for x in y] +14 | [*x, *y for x in y] + | ^^^^^^ Syntax Error: did you forget parentheses around the comprehension target? +15 | +16 | # Invalid if + | + + | 12 | [**x for x in [{1: 2}]] 13 | [*x, for x in y] @@ -1342,7 +1361,7 @@ Module( 20 | [x for x in data if lambda y: y] 21 | [*x if x else y for x in z] 22 | [x if x else *y for x in z] - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: expected expression after 'else', but statement is given ## Unsupported Syntax Errors diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap index 9405ea58b39bbb..92c7849422ddf9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary.py.snap @@ -53,6 +53,11 @@ Module( ``` ## Errors + | +1 | not x := 1 + | ^^^^^ Syntax Error: cannot use assignment expressions with expression + + | 1 | not x := 1 | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap index 4b35b2a8302471..906b34635d82c7 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__unary__named_expression.py.snap @@ -89,6 +89,13 @@ Module( ``` ## Errors + | +1 | -x := 1 + | ^^ Syntax Error: cannot use assignment expressions with expression +2 | not x := 1 + | + + | 1 | -x := 1 | ^^ Syntax Error: invalid syntax @@ -96,6 +103,12 @@ Module( | + | +1 | -x := 1 +2 | not x := 1 + | ^^^^^ Syntax Error: cannot use assignment expressions with expression + + | 1 | -x := 1 2 | not x := 1 diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_expr_statement_after_else.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_expr_statement_after_else.py.snap new file mode 100644 index 00000000000000..6b421d8fdb51b8 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_expr_statement_after_else.py.snap @@ -0,0 +1,202 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/if_expr_statement_after_else.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..61, + body: [ + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 0..20, + targets: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("x"), + ctx: Store, + }, + ), + ], + value: If( + ExprIf { + node_index: NodeIndex(None), + range: 4..20, + test: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 9..10, + value: Int( + 1, + ), + }, + ), + body: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 4..5, + value: Int( + 1, + ), + }, + ), + orelse: Name( + ExprName { + node_index: NodeIndex(None), + range: 16..20, + id: Name("pass"), + ctx: Load, + }, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 21..36, + targets: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 21..22, + id: Name("x"), + ctx: Store, + }, + ), + ], + value: If( + ExprIf { + node_index: NodeIndex(None), + range: 25..36, + test: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 30..31, + value: Int( + 1, + ), + }, + ), + body: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 25..26, + value: Int( + 1, + ), + }, + ), + orelse: Name( + ExprName { + node_index: NodeIndex(None), + range: 36..36, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 37..60, + targets: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 37..38, + id: Name("x"), + ctx: Store, + }, + ), + ], + value: If( + ExprIf { + node_index: NodeIndex(None), + range: 41..60, + test: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 46..47, + value: Int( + 1, + ), + }, + ), + body: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 41..42, + value: Int( + 1, + ), + }, + ), + orelse: Yield( + ExprYield { + node_index: NodeIndex(None), + range: 53..60, + value: Some( + NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 59..60, + value: Int( + 2, + ), + }, + ), + ), + }, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | x = 1 if 1 else pass + | ^^^^ Syntax Error: expected expression after 'else', but statement is given +2 | x = 1 if 1 else +3 | x = 1 if 1 else yield 2 + | + + + | +1 | x = 1 if 1 else pass +2 | x = 1 if 1 else + | ^ Syntax Error: expected expression after 'else', but statement is given +3 | x = 1 if 1 else yield 2 + | + + + | +1 | x = 1 if 1 else pass +2 | x = 1 if 1 else +3 | x = 1 if 1 else yield 2 + | ^^^^^ Syntax Error: expected expression after 'else', but statement is given diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap index b2b17a32922c35..c397bd523201af 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_slice.py.snap @@ -244,6 +244,24 @@ Module( | + | +1 | # even after 3.9, an unparenthesized named expression is not allowed in a slice +2 | lst[x:=1:-1] +3 | lst[1:x:=1] + | ^^^^^^^ Syntax Error: cannot use assignment expressions with subscript +4 | lst[1:3:x:=1] + | + + + | +1 | # even after 3.9, an unparenthesized named expression is not allowed in a slice +2 | lst[x:=1:-1] +3 | lst[1:x:=1] + | ^^ Syntax Error: invalid syntax +4 | lst[1:3:x:=1] + | + + | 1 | # even after 3.9, an unparenthesized named expression is not allowed in a slice 2 | lst[x:=1:-1] @@ -269,6 +287,20 @@ Module( | ^^ Syntax Error: invalid syntax + | +2 | lst[x:=1:-1] +3 | lst[1:x:=1] +4 | lst[1:3:x:=1] + | ^^^^^^^^^ Syntax Error: cannot use assignment expressions with subscript + + + | +2 | lst[x:=1:-1] +3 | lst[1:x:=1] +4 | lst[1:3:x:=1] + | ^^ Syntax Error: invalid syntax + + | 2 | lst[x:=1:-1] 3 | lst[1:x:=1] diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_statement_invalid_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_statement_invalid_target.py.snap new file mode 100644 index 00000000000000..b316e80d920343 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@named_expr_statement_invalid_target.py.snap @@ -0,0 +1,128 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/named_expr_statement_invalid_target.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..20, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: BinOp( + ExprBinOp { + node_index: NodeIndex(None), + range: 0..5, + left: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("x"), + ctx: Load, + }, + ), + op: Add, + right: Name( + ExprName { + node_index: NodeIndex(None), + range: 4..5, + id: Name("y"), + ctx: Load, + }, + ), + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 9..10, + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 9..10, + value: Int( + 1, + ), + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 11..14, + value: Attribute( + ExprAttribute { + node_index: NodeIndex(None), + range: 11..14, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 11..12, + id: Name("a"), + ctx: Load, + }, + ), + attr: Identifier { + id: Name("b"), + range: 13..14, + node_index: NodeIndex(None), + }, + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 18..19, + value: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 18..19, + value: Int( + 1, + ), + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | x + y := 1 + | ^^^^^ Syntax Error: cannot use assignment expressions with expression +2 | a.b := 1 + | + + + | +1 | x + y := 1 + | ^^ Syntax Error: invalid syntax +2 | a.b := 1 + | + + + | +1 | x + y := 1 +2 | a.b := 1 + | ^^^ Syntax Error: cannot use assignment expressions with attribute + + + | +1 | x + y := 1 +2 | a.b := 1 + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statement_before_if_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statement_before_if_expression.py.snap new file mode 100644 index 00000000000000..9acdba1ef7d626 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@statement_before_if_expression.py.snap @@ -0,0 +1,139 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/statement_before_if_expression.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..41, + body: [ + Assign( + StmtAssign { + node_index: NodeIndex(None), + range: 0..20, + targets: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 0..1, + id: Name("x"), + ctx: Store, + }, + ), + ], + value: If( + ExprIf { + node_index: NodeIndex(None), + range: 4..20, + test: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 12..13, + value: Int( + 1, + ), + }, + ), + body: Name( + ExprName { + node_index: NodeIndex(None), + range: 4..8, + id: Name("pass"), + ctx: Load, + }, + ), + orelse: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 19..20, + value: Int( + 1, + ), + }, + ), + }, + ), + runtime_targets: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + ), + Pass( + StmtPass { + node_index: NodeIndex(None), + range: 21..25, + }, + ), + If( + StmtIf { + node_index: NodeIndex(None), + range: 26..40, + test: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 29..30, + value: Int( + 1, + ), + }, + ), + body: [], + elif_else_clauses: [ + ElifElseClause { + range: 31..40, + node_index: NodeIndex(None), + test: None, + body: [ + Pass( + StmtPass { + node_index: NodeIndex(None), + range: 36..40, + }, + ), + ], + runtime_body: None, + runtime_orelse: None, + }, + ], + runtime_body: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | x = pass if 1 else 1 + | ^^^^ Syntax Error: expected expression before 'if', but statement is given +2 | pass if 1 else pass + | + + + | +1 | x = pass if 1 else 1 +2 | pass if 1 else pass + | ^^^^ Syntax Error: expected expression before 'if', but statement is given + + + | +1 | x = pass if 1 else 1 +2 | pass if 1 else pass + | ^^ Syntax Error: invalid syntax + + + | +1 | x = pass if 1 else 1 +2 | pass if 1 else pass + | ^^^^ Syntax Error: invalid syntax + + + | +1 | x = pass if 1 else 1 +2 | pass if 1 else pass + | ^^^^ Syntax Error: invalid syntax From c7f6594ed69b925d73681d0a2c310865057c8008 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 5 Oct 2026 21:22:00 +0900 Subject: [PATCH 15/20] Report remaining statement errors with CPython messages - `elif` after `else`: "'elif' block follows an 'else' block". - `import a from b`: "Did you mean to use 'from ... import ...' instead?". - Mixed `except` and `except*` is reported at the `except` keyword and its star. - `**_` in a mapping pattern is "invalid syntax". Assisted-by: Claude Code:claude-opus-5-5 --- .../inline/err/if_stmt_elif_after_else.py | 6 + .../err/import_stmt_from_after_names.py | 2 + .../ruff_python_parser/src/parser/pattern.rs | 9 +- .../src/parser/statement.rs | 57 ++++++- ...syntax@except_stmt_invalid_as_name.py.snap | 2 +- ...lid_syntax@if_stmt_elif_after_else.py.snap | 113 +++++++++++++ ...yntax@import_stmt_from_after_names.py.snap | 149 ++++++++++++++++++ ...yntax@invalid_match_pattern_target.py.snap | 2 +- ..._syntax@try_stmt_mixed_except_kind.py.snap | 50 +++--- 9 files changed, 360 insertions(+), 30 deletions(-) create mode 100644 crates/ruff_python_parser/resources/inline/err/if_stmt_elif_after_else.py create mode 100644 crates/ruff_python_parser/resources/inline/err/import_stmt_from_after_names.py create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_after_else.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_from_after_names.py.snap diff --git a/crates/ruff_python_parser/resources/inline/err/if_stmt_elif_after_else.py b/crates/ruff_python_parser/resources/inline/err/if_stmt_elif_after_else.py new file mode 100644 index 00000000000000..9fb313d0e97f07 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/if_stmt_elif_after_else.py @@ -0,0 +1,6 @@ +if x: + pass +else: + pass +elif y: + pass diff --git a/crates/ruff_python_parser/resources/inline/err/import_stmt_from_after_names.py b/crates/ruff_python_parser/resources/inline/err/import_stmt_from_after_names.py new file mode 100644 index 00000000000000..a5a948d4bc5581 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/import_stmt_from_after_names.py @@ -0,0 +1,2 @@ +import a from b +import a.b, c from d.e as f diff --git a/crates/ruff_python_parser/src/parser/pattern.rs b/crates/ruff_python_parser/src/parser/pattern.rs index 7c7ccaef69ab33..b27b1e5b13693e 100644 --- a/crates/ruff_python_parser/src/parser/pattern.rs +++ b/crates/ruff_python_parser/src/parser/pattern.rs @@ -214,7 +214,14 @@ impl Parser<'_> { let mapping_item_start = parser.node_start(); if parser.eat(TokenKind::DoubleStar) { - let identifier = parser.parse_match_pattern_target(); + // A `_` rest target is not a capture target. + let identifier = parser.parse_identifier(); + if identifier.is_valid() && identifier.id == "_" { + parser.add_error( + ParseErrorType::OtherError("invalid syntax".to_string()), + &identifier, + ); + } if rest.is_some() { parser.add_error( ParseErrorType::OtherError( diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index b78dba62251cfb..08971b90d67467 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -656,6 +656,22 @@ impl<'src> Parser<'src> { }); let names: Vec<_> = self.alias_scratch.take(names_snapshot); + if self.at(TokenKind::From) + && !names.is_empty() + && names.iter().all(|alias| alias.asname.is_none()) + && let Some(end) = self.misplaced_from_error_end() + { + // test_err import_stmt_from_after_names + // import a from b + // import a.b, c from d.e as f + self.add_error( + ParseErrorType::OtherError( + "Did you mean to use 'from ... import ...' instead?".to_string(), + ), + TextRange::new(start, end), + ); + } + if names.is_empty() { // test_err import_stmt_empty // import @@ -670,6 +686,26 @@ impl<'src> Parser<'src> { } } + /// Returns where the error for `from` after the names of an `import` statement ends, if the + /// `from` is followed by a dotted name. The error ends one character before the end of the + /// token after the dotted name. + fn misplaced_from_error_end(&mut self) -> Option { + let checkpoint = self.checkpoint(); + self.bump(TokenKind::From); + let mut found_name = false; + while self.at_identifier_or_soft_keyword() { + found_name = true; + self.bump_any(); + if !self.eat(TokenKind::Dot) { + break; + } + } + let next = self.current_token_range(); + let end = found_name.then(|| next.start().max(next.end() - TextSize::from(1))); + self.rewind(checkpoint); + end + } + /// Parses a `from` import statement. /// /// # Panics @@ -1570,6 +1606,20 @@ impl<'src> Parser<'src> { if self.at(TokenKind::Else) { let clause = self.parse_elif_or_else_clause(ElifOrElse::Else); self.elif_else_scratch.push(clause); + + if self.at(TokenKind::Elif) { + // test_err if_stmt_elif_after_else + // if x: + // pass + // else: + // pass + // elif y: + // pass + self.add_error( + ParseErrorType::OtherError("'elif' block follows an 'else' block".to_string()), + self.current_token_range(), + ); + } } ast::StmtIf { @@ -1679,7 +1729,12 @@ impl<'src> Parser<'src> { if is_star.is_none() { is_star = Some(kind.is_star()); } else if is_star != Some(kind.is_star()) { - mixed_except_ranges.push(handler.range()); + // The error covers the `except` keyword and the star. + let except_end = match kind { + ExceptClauseKind::Star(star_range) => star_range.end(), + ExceptClauseKind::Normal => handler.start() + TextSize::of("except"), + }; + mixed_except_ranges.push(TextRange::new(handler.start(), except_end)); } if handlers.is_empty() { handlers.reserve_exact(1); diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_as_name.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_as_name.py.snap index b93b588d89c7a1..bf89cb33d2b56e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_as_name.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@except_stmt_invalid_as_name.py.snap @@ -141,4 +141,4 @@ Module( 1 | try: ... 2 | except Exception as x.y: ... 3 | except* Exception as f(): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' + | ^^^^^^^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_after_else.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_after_else.py.snap new file mode 100644 index 00000000000000..ed7c27e4cf91cb --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@if_stmt_elif_after_else.py.snap @@ -0,0 +1,113 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/if_stmt_elif_after_else.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..47, + body: [ + If( + StmtIf { + node_index: NodeIndex(None), + range: 0..29, + test: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("x"), + ctx: Load, + }, + ), + body: [ + Pass( + StmtPass { + node_index: NodeIndex(None), + range: 10..14, + }, + ), + ], + elif_else_clauses: [ + ElifElseClause { + range: 15..29, + node_index: NodeIndex(None), + test: None, + body: [ + Pass( + StmtPass { + node_index: NodeIndex(None), + range: 25..29, + }, + ), + ], + runtime_body: None, + runtime_orelse: None, + }, + ], + runtime_body: None, + }, + ), + AnnAssign( + StmtAnnAssign { + node_index: NodeIndex(None), + range: 35..37, + target: Name( + ExprName { + node_index: NodeIndex(None), + range: 35..36, + id: Name("y"), + ctx: Store, + }, + ), + annotation: Name( + ExprName { + node_index: NodeIndex(None), + range: 37..37, + id: Name(""), + ctx: Invalid, + }, + ), + value: None, + simple: true, + runtime_simple: None, + }, + ), + Pass( + StmtPass { + node_index: NodeIndex(None), + range: 42..46, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +3 | else: +4 | pass +5 | elif y: + | ^^^^ Syntax Error: 'elif' block follows an 'else' block +6 | pass + | + + + | +3 | else: +4 | pass +5 | elif y: + | ^ Syntax Error: invalid syntax +6 | pass + | + + + | +4 | pass +5 | elif y: +6 | pass + | ^ Syntax Error: unexpected indent diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_from_after_names.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_from_after_names.py.snap new file mode 100644 index 00000000000000..0b80a2ae291dc0 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@import_stmt_from_after_names.py.snap @@ -0,0 +1,149 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/import_stmt_from_after_names.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..44, + body: [ + Import( + StmtImport { + node_index: NodeIndex(None), + range: 0..8, + names: [ + Alias { + range: 7..8, + node_index: NodeIndex(None), + name: Identifier { + id: Name("a"), + range: 7..8, + node_index: NodeIndex(None), + }, + asname: None, + }, + ], + is_lazy: false, + }, + ), + ImportFrom( + StmtImportFrom { + node_index: NodeIndex(None), + range: 9..15, + module: Some( + Identifier { + id: Name("b"), + range: 14..15, + node_index: NodeIndex(None), + }, + ), + names: [], + level: 0, + is_lazy: false, + runtime_level: None, + }, + ), + Import( + StmtImport { + node_index: NodeIndex(None), + range: 16..29, + names: [ + Alias { + range: 23..26, + node_index: NodeIndex(None), + name: Identifier { + id: Name("a.b"), + range: 23..26, + node_index: NodeIndex(None), + }, + asname: None, + }, + Alias { + range: 28..29, + node_index: NodeIndex(None), + name: Identifier { + id: Name("c"), + range: 28..29, + node_index: NodeIndex(None), + }, + asname: None, + }, + ], + is_lazy: false, + }, + ), + ImportFrom( + StmtImportFrom { + node_index: NodeIndex(None), + range: 30..43, + module: Some( + Identifier { + id: Name("d.e"), + range: 35..38, + node_index: NodeIndex(None), + }, + ), + names: [ + Alias { + range: 42..43, + node_index: NodeIndex(None), + name: Identifier { + id: Name("f"), + range: 42..43, + node_index: NodeIndex(None), + }, + asname: None, + }, + ], + level: 0, + is_lazy: false, + runtime_level: None, + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | import a from b + | ^^^^^^^^^^^^^^^ Syntax Error: Did you mean to use 'from ... import ...' instead? +2 | import a.b, c from d.e as f + | + + + | +1 | import a from b + | ^^^^ Syntax Error: invalid syntax +2 | import a.b, c from d.e as f + | + + + | +1 | import a from b + | ^ Syntax Error: invalid syntax +2 | import a.b, c from d.e as f + | + + + | +1 | import a from b +2 | import a.b, c from d.e as f + | ^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: Did you mean to use 'from ... import ...' instead? + + + | +1 | import a from b +2 | import a.b, c from d.e as f + | ^^^^ Syntax Error: invalid syntax + + + | +1 | import a from b +2 | import a.b, c from d.e as f + | ^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_match_pattern_target.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_match_pattern_target.py.snap index a23c2cda3e836f..cf3a8113c9192a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_match_pattern_target.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_match_pattern_target.py.snap @@ -161,6 +161,6 @@ Module( 1 | match value: 2 | case 1 as _: ... 3 | case {**_}: ... - | ^ Syntax Error: cannot use '_' as a target + | ^ Syntax Error: invalid syntax 4 | after = 1 | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap index ea4fb660b76b45..160a727dce4b5a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@try_stmt_mixed_except_kind.py.snap @@ -259,41 +259,39 @@ Module( ## Errors | -3 | except: -4 | pass -5 | / except* ExceptionGroup: -6 | | pass - | |________^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' -7 | try: -8 | pass +3 | except: +4 | pass +5 | except* ExceptionGroup: + | ^^^^^^^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' +6 | pass +7 | try: | | - 9 | except* ExceptionGroup: -10 | pass -11 | / except: -12 | | pass - | |________^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' -13 | try: -14 | pass + 9 | except* ExceptionGroup: +10 | pass +11 | except: + | ^^^^^^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' +12 | pass +13 | try: | | -17 | except: -18 | pass -19 | / except* ExceptionGroup: -20 | | pass - | |________^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' -21 | except* ExceptionGroup: -22 | pass +17 | except: +18 | pass +19 | except* ExceptionGroup: + | ^^^^^^^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' +20 | pass +21 | except* ExceptionGroup: | | -19 | except* ExceptionGroup: -20 | pass -21 | / except* ExceptionGroup: -22 | | pass - | |________^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' +19 | except* ExceptionGroup: +20 | pass +21 | except* ExceptionGroup: + | ^^^^^^^ Syntax Error: cannot have both 'except' and 'except*' on the same 'try' +22 | pass + | From 060b62dad90dd9584e1696763974fc9608e6c6f7 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 5 Oct 2026 22:49:51 +0900 Subject: [PATCH 16/20] Report string, f-string and legacy statement errors with CPython messages Report escape sequence errors in string literals as unicode escape decoder errors with their decoder positions, at the closing quote for f-strings and t-strings. Report the f-string and t-string replacement field rules, a quote of the enclosing f-string in a replacement field as a missing `}`, a bracket closing a replacement field brace as unmatched, lambdas whose `:` starts a format spec, and `print`/`exec` statements missing parentheses. Assisted-by: Claude Code:claude-opus-5-5 --- ...ing_expected_separator_after_conversion.py | 2 + ...f_string_expected_separator_after_debug.py | 1 + ...ing_expected_separator_after_expression.py | 5 + ...ng_expression_required_before_separator.py | 3 + .../err/f_string_invalid_expression_start.py | 4 + .../err/f_string_missing_conversion_flag.py | 2 + .../err/f_string_unclosed_format_spec.py | 1 + .../err/interpolated_string_escape_error.py | 2 + .../inline/err/lambda_in_replacement_field.py | 3 + .../inline/err/legacy_print_statement.py | 3 + .../legacy_print_statement_invalid_operand.py | 2 + .../err/missing_comma_between_expressions.py | 1 + crates/ruff_python_parser/src/error.rs | 112 ++- crates/ruff_python_parser/src/lexer.rs | 52 +- .../src/lexer/interpolated_string.rs | 6 + crates/ruff_python_parser/src/lib.rs | 3 +- .../src/parser/expression.rs | 341 +++++++-- crates/ruff_python_parser/src/parser/mod.rs | 40 +- ...parser__tests__tstring_fstring_middle.snap | 6 +- ...tring__tests__invalid_unicode_literal.snap | 8 +- ...ng__tests__invalid_unicode_name_error.snap | 8 +- ...__tests__missing_unicode_lbrace_error.snap | 8 +- ...__tests__missing_unicode_rbrace_error.snap | 8 +- crates/ruff_python_parser/src/string.rs | 157 +++-- crates/ruff_python_parser/src/token_source.rs | 7 + ...ing_conversion_follows_exclamation.py.snap | 2 +- ...d_syntax@f_string_empty_expression.py.snap | 4 +- ...xpected_separator_after_conversion.py.snap | 163 +++++ ...ing_expected_separator_after_debug.py.snap | 117 ++++ ...xpected_separator_after_expression.py.snap | 650 ++++++++++++++++++ ...pression_required_before_separator.py.snap | 272 ++++++++ ...g_invalid_conversion_flag_name_tok.py.snap | 2 +- ...@f_string_invalid_expression_start.py.snap | 377 ++++++++++ ...ntax@f_string_invalid_starred_expr.py.snap | 9 + ..._string_lambda_without_parentheses.py.snap | 7 +- ...x@f_string_missing_conversion_flag.py.snap | 142 ++++ ...ntax@f_string_unclosed_format_spec.py.snap | 78 +++ ...id_syntax@f_string_unclosed_lbrace.py.snap | 32 + ...ing_unclosed_lbrace_in_format_spec.py.snap | 4 +- ...x@interpolated_string_escape_error.py.snap | 139 ++++ ...ax@invalid_fstring_literal_element.py.snap | 4 +- ...alid_syntax@invalid_string_literal.py.snap | 4 +- ...syntax@lambda_in_replacement_field.py.snap | 342 +++++++++ ...alid_syntax@legacy_print_statement.py.snap | 192 ++++++ ...cy_print_statement_invalid_operand.py.snap | 159 +++++ ...@missing_comma_between_expressions.py.snap | 281 +++++++- ...@nested_quote_in_format_spec_py312.py.snap | 2 +- ...nvalid_syntax@re_lex_logical_token.py.snap | 2 +- ...x@re_lexing__fstring_format_spec_1.py.snap | 8 +- ...re_lexing__triple_quoted_fstring_2.py.snap | 2 +- ...re_lexing__triple_quoted_fstring_3.py.snap | 2 +- .../invalid_syntax@re_lexing__ty_1828.py.snap | 2 +- ...d_syntax@t_string_empty_expression.py.snap | 4 +- ...g_invalid_conversion_flag_name_tok.py.snap | 2 +- ...ntax@t_string_invalid_starred_expr.py.snap | 10 + ..._string_lambda_without_parentheses.py.snap | 8 +- ...id_syntax@t_string_unclosed_lbrace.py.snap | 34 + ...ing_unclosed_lbrace_in_format_spec.py.snap | 4 +- ...erminated_fstring_newline_recovery.py.snap | 2 +- 59 files changed, 3671 insertions(+), 176 deletions(-) create mode 100644 crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_conversion.py create mode 100644 crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_debug.py create mode 100644 crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_expression.py create mode 100644 crates/ruff_python_parser/resources/inline/err/f_string_expression_required_before_separator.py create mode 100644 crates/ruff_python_parser/resources/inline/err/f_string_invalid_expression_start.py create mode 100644 crates/ruff_python_parser/resources/inline/err/f_string_missing_conversion_flag.py create mode 100644 crates/ruff_python_parser/resources/inline/err/f_string_unclosed_format_spec.py create mode 100644 crates/ruff_python_parser/resources/inline/err/interpolated_string_escape_error.py create mode 100644 crates/ruff_python_parser/resources/inline/err/lambda_in_replacement_field.py create mode 100644 crates/ruff_python_parser/resources/inline/err/legacy_print_statement.py create mode 100644 crates/ruff_python_parser/resources/inline/err/legacy_print_statement_invalid_operand.py create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_conversion.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_debug.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_expression.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expression_required_before_separator.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_expression_start.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_missing_conversion_flag.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_format_spec.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@interpolated_string_escape_error.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_in_replacement_field.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@legacy_print_statement.py.snap create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@legacy_print_statement_invalid_operand.py.snap diff --git a/crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_conversion.py b/crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_conversion.py new file mode 100644 index 00000000000000..bbba261b0c231c --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_conversion.py @@ -0,0 +1,2 @@ +f"{x!s!}" +f"{x!r{y}}" diff --git a/crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_debug.py b/crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_debug.py new file mode 100644 index 00000000000000..126643369ad59e --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_debug.py @@ -0,0 +1 @@ +f"{x=y}" diff --git a/crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_expression.py b/crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_expression.py new file mode 100644 index 00000000000000..278921332de965 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_expression.py @@ -0,0 +1,5 @@ +f"{x;y}" +f"{1 +}" +f"{a, b and}" +f"{x.}" +A tokenizer error up to where the expression fails comes first. diff --git a/crates/ruff_python_parser/resources/inline/err/f_string_expression_required_before_separator.py b/crates/ruff_python_parser/resources/inline/err/f_string_expression_required_before_separator.py new file mode 100644 index 00000000000000..d334a070bdd959 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/f_string_expression_required_before_separator.py @@ -0,0 +1,3 @@ +f"{=x}" +f"{!r}" +t"{:x}" diff --git a/crates/ruff_python_parser/resources/inline/err/f_string_invalid_expression_start.py b/crates/ruff_python_parser/resources/inline/err/f_string_invalid_expression_start.py new file mode 100644 index 00000000000000..328f48b1d8614a --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/f_string_invalid_expression_start.py @@ -0,0 +1,4 @@ +f"{.}" +f"{**x}" +f"{+;}" +t"{x:{/5}}" diff --git a/crates/ruff_python_parser/resources/inline/err/f_string_missing_conversion_flag.py b/crates/ruff_python_parser/resources/inline/err/f_string_missing_conversion_flag.py new file mode 100644 index 00000000000000..ca284ae0d237bf --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/f_string_missing_conversion_flag.py @@ -0,0 +1,2 @@ +f"{x!}" +f"{x=!:}" diff --git a/crates/ruff_python_parser/resources/inline/err/f_string_unclosed_format_spec.py b/crates/ruff_python_parser/resources/inline/err/f_string_unclosed_format_spec.py new file mode 100644 index 00000000000000..f15ff352114dfa --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/f_string_unclosed_format_spec.py @@ -0,0 +1 @@ +f"{x!s:" diff --git a/crates/ruff_python_parser/resources/inline/err/interpolated_string_escape_error.py b/crates/ruff_python_parser/resources/inline/err/interpolated_string_escape_error.py new file mode 100644 index 00000000000000..be4abd9cb54052 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/interpolated_string_escape_error.py @@ -0,0 +1,2 @@ +f'a\N b{x}' +t'{x}\x1' 'c' diff --git a/crates/ruff_python_parser/resources/inline/err/lambda_in_replacement_field.py b/crates/ruff_python_parser/resources/inline/err/lambda_in_replacement_field.py new file mode 100644 index 00000000000000..7f1314585e769c --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/lambda_in_replacement_field.py @@ -0,0 +1,3 @@ +f"{lambda x:x}" +f"{1, lambda:x}" +t"{lambda x:}" diff --git a/crates/ruff_python_parser/resources/inline/err/legacy_print_statement.py b/crates/ruff_python_parser/resources/inline/err/legacy_print_statement.py new file mode 100644 index 00000000000000..fbc5eca504b5eb --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/legacy_print_statement.py @@ -0,0 +1,3 @@ +print 'hello' +[print x, y] +exec code in ns diff --git a/crates/ruff_python_parser/resources/inline/err/legacy_print_statement_invalid_operand.py b/crates/ruff_python_parser/resources/inline/err/legacy_print_statement_invalid_operand.py new file mode 100644 index 00000000000000..5415b36056a972 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/legacy_print_statement_invalid_operand.py @@ -0,0 +1,2 @@ +print {1:(foo.)} +[print 1 +] diff --git a/crates/ruff_python_parser/resources/inline/err/missing_comma_between_expressions.py b/crates/ruff_python_parser/resources/inline/err/missing_comma_between_expressions.py index 633843284c832b..c89c77b18822f4 100644 --- a/crates/ruff_python_parser/resources/inline/err/missing_comma_between_expressions.py +++ b/crates/ruff_python_parser/resources/inline/err/missing_comma_between_expressions.py @@ -2,3 +2,4 @@ f(x, a.b c) x[1 + 2 3] f"{a b}" +A tokenizer error in or right after the first expression comes first. diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index 0e11515d0f82fd..3c72adea27e776 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -55,6 +55,36 @@ impl ParseError { } } +/// The reason an escape sequence in a string literal cannot be decoded. +#[derive(Debug, Clone, Copy, PartialEq, Eq, get_size2::GetSize)] +pub enum UnicodeEscapeErrorKind { + /// `\x` is not followed by two hexadecimal digits. + TruncatedHexByte, + /// `\u` is not followed by four hexadecimal digits. + TruncatedShortUnicode, + /// `\U` is not followed by eight hexadecimal digits. + TruncatedLongUnicode, + /// `\U` names a code point above `U+10FFFF`. + IllegalCharacter, + /// `\N` is not followed by a non-empty name in braces. + MalformedName, + /// `\N{...}` names no Unicode character. + UnknownName, +} + +impl Display for UnicodeEscapeErrorKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(match self { + Self::TruncatedHexByte => "truncated \\xXX escape", + Self::TruncatedShortUnicode => "truncated \\uXXXX escape", + Self::TruncatedLongUnicode => "truncated \\UXXXXXXXX escape", + Self::IllegalCharacter => "illegal Unicode character", + Self::MalformedName => "malformed \\N character escape", + Self::UnknownName => "unknown Unicode character name", + }) + } +} + /// Represents the different types of errors that can occur during parsing of an f-string or t-string. #[derive(Debug, Clone, PartialEq, Eq, get_size2::GetSize)] pub enum InterpolatedStringErrorType { @@ -74,6 +104,22 @@ pub enum InterpolatedStringErrorType { ConversionFlagNotImmediatelyAfterExclamation, /// Newline inside of a format spec for a single quoted f- or t-string. NewlineInFormatSpec, + /// A replacement field has no expression before the given separator. + ExpressionRequiredBefore(char), + /// A replacement field does not start with an expression. + ExpectedExpressionAfterLbrace, + /// The expression of a replacement field is not followed by `=`, `!`, `:` or `}`. + ExpectedSeparatorAfterExpression, + /// The `=` of a replacement field is not followed by `!`, `:` or `}`. + ExpectedSeparatorAfterDebug, + /// The conversion of a replacement field is not followed by `:` or `}`. + ExpectedSeparatorAfterConversion, + /// The format spec of a replacement field is not followed by `}`. + UnclosedFormatSpec, + /// A `!` is directly followed by `:` or `}`. + MissingConversionFlag, + /// A closing bracket closes the brace that opens a replacement field. + UnmatchedBracket(char), } impl std::fmt::Display for InterpolatedStringErrorType { @@ -99,6 +145,20 @@ impl std::fmt::Display for InterpolatedStringErrorType { "newlines are not allowed in format specifiers when using single quotes" ) } + Self::ExpressionRequiredBefore(separator) => { + write!(f, "valid expression required before '{separator}'") + } + Self::ExpectedExpressionAfterLbrace => { + f.write_str("expecting a valid expression after '{'") + } + Self::ExpectedSeparatorAfterExpression => { + f.write_str("expecting '=', or '!', or ':', or '}'") + } + Self::ExpectedSeparatorAfterDebug => f.write_str("expecting '!', or ':', or '}'"), + Self::ExpectedSeparatorAfterConversion => f.write_str("expecting ':' or '}'"), + Self::UnclosedFormatSpec => f.write_str("expecting '}', or format specs"), + Self::MissingConversionFlag => f.write_str("missing conversion character"), + Self::UnmatchedBracket(closing) => write!(f, "unmatched '{closing}'"), } } } @@ -121,6 +181,10 @@ fn write_interpolated_string_error( "unterminated triple-quoted {kind} literal (detected at line {detected_line})" ) } + InterpolatedStringErrorType::NewlineInFormatSpec => write!( + f, + "{kind}: newlines are not allowed in format specifiers for single quoted {kind}s" + ), _ => write!(f, "{kind}: {error}"), } } @@ -642,12 +706,17 @@ pub enum LexicalErrorType { escaped_end_quote: bool, detected_line: u32, }, - /// Decoding of a unicode escape sequence in a string literal failed. - UnicodeError, - /// Missing the `{` for unicode escape sequence. - MissingUnicodeLbrace, - /// Missing the `}` for unicode escape sequence. - MissingUnicodeRbrace, + /// An escape sequence in a string literal cannot be decoded. `start` and `end` are the + /// inclusive positions of the escape sequence in the string content, where a non-ASCII + /// character counts as its ten-character `\U` escape. + UnicodeEscapeError { + kind: UnicodeEscapeErrorKind, + start: u32, + end: u32, + }, + /// A `\x` escape in a bytes literal at the given position of its content is not followed by + /// two hexadecimal digits. + BytesEscapeError { position: u32 }, /// A dedent does not match any outer indentation level. IndentationError, /// Tabs and spaces are mixed in a way that makes the indentation depend on the tab size. @@ -742,14 +811,23 @@ fn is_printable(c: char) -> bool { } impl LexicalErrorType { + /// Returns `true` if the error reports a string literal without its closing quotes. + pub(crate) fn is_unclosed_string_error(&self) -> bool { + matches!( + self, + Self::UnclosedStringError { .. } + | Self::FStringError(InterpolatedStringErrorType::UnclosedLbrace) + | Self::TStringError(InterpolatedStringErrorType::UnclosedLbrace) + ) + } + /// Returns `true` if the error stops tokenization, as opposed to an error found while /// decoding the content of a token. pub fn is_tokenizer_error(&self) -> bool { match self { Self::StringError - | Self::UnicodeError - | Self::MissingUnicodeLbrace - | Self::MissingUnicodeRbrace + | Self::UnicodeEscapeError { .. } + | Self::BytesEscapeError { .. } | Self::InvalidByteLiteral | Self::OtherError(_) => false, // An ASCII punctuation character is a token that the parser rejects. @@ -760,6 +838,8 @@ impl LexicalErrorType { | InterpolatedStringErrorType::UnterminatedTripleQuotedString { .. } | InterpolatedStringErrorType::SingleRbrace | InterpolatedStringErrorType::NewlineInFormatSpec + | InterpolatedStringErrorType::UnclosedLbrace + | InterpolatedStringErrorType::UnmatchedBracket(_) ), Self::UnclosedStringError { .. } | Self::IndentationError @@ -802,7 +882,13 @@ impl std::fmt::Display for LexicalErrorType { Self::InvalidByteLiteral => { write!(f, "bytes can only contain ASCII literal characters") } - Self::UnicodeError => write!(f, "got unexpected unicode"), + Self::UnicodeEscapeError { kind, start, end } => write!( + f, + "(unicode error) 'unicodeescape' codec can't decode bytes in position {start}-{end}: {kind}" + ), + Self::BytesEscapeError { position } => { + write!(f, "(value error) invalid \\x escape at position {position}") + } Self::IndentationError => { write!(f, "unindent does not match any outer indentation level") } @@ -873,12 +959,6 @@ impl std::fmt::Display for LexicalErrorType { } Ok(()) } - Self::MissingUnicodeLbrace => { - write!(f, "missing `{{` in Unicode escape sequence") - } - Self::MissingUnicodeRbrace => { - write!(f, "missing `}}` in Unicode escape sequence") - } } } } diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index e5adbbd17fcb64..8ac81b7de3cc46 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -1115,10 +1115,24 @@ impl<'src> Lexer<'src> { break; } } - let error = LexicalErrorType::UnclosedStringError { - triple_quoted: self.current_flags.is_triple_quoted(), - escaped_end_quote, - detected_line: self.detected_line(), + let error = match self.interpolated_strings.current() { + // A string in a replacement field that opens with the quotes of the enclosing + // f-string or t-string is its end without the closing brace. + Some(interpolated_string) + if interpolated_string.quote_char() == quote + && interpolated_string.is_triple_quoted() + == self.current_flags.is_triple_quoted() => + { + LexicalErrorType::from_interpolated_string_error( + InterpolatedStringErrorType::UnclosedLbrace, + interpolated_string.kind(), + ) + } + _ => LexicalErrorType::UnclosedStringError { + triple_quoted: self.current_flags.is_triple_quoted(), + escaped_end_quote, + detected_line: self.detected_line(), + }, }; self.push_error(LexicalError::new(error, TextRange::empty(range.start()))); } @@ -1178,8 +1192,18 @@ impl<'src> Lexer<'src> { /// that has no opening bracket or does not match it. fn close_bracket(&mut self, closing: char) { let start = self.token_range().start(); + let at_interpolation_brace = self + .interpolated_strings + .current() + .filter(|interpolated_string| interpolated_string.is_at_interpolation_brace(self.nesting)); let error = match self.brackets.pop() { Some(open) if open.kind == opening_bracket(closing) => None, + Some(open) if open.kind == '{' && at_interpolation_brace.is_some() => { + Some(LexicalErrorType::from_interpolated_string_error( + InterpolatedStringErrorType::UnmatchedBracket(closing), + at_interpolation_brace.unwrap().kind(), + )) + } Some(open) => { let opening_line = self.line_number(open.start); Some(LexicalErrorType::MismatchedBracket { @@ -1642,7 +1666,7 @@ impl<'src> Lexer<'src> { if self.errors.last().is_some_and(|error| { error.location().start() == self.current_range.start() - && matches!(error.error(), LexicalErrorType::UnclosedStringError { .. }) + && error.error().is_unclosed_string_error() }) { self.errors.pop(); } @@ -1682,7 +1706,7 @@ impl<'src> Lexer<'src> { { if self.errors.last().is_some_and(|error| { error.location().start() == self.current_range.start() - && matches!(error.error(), LexicalErrorType::UnclosedStringError { .. }) + && error.error().is_unclosed_string_error() }) { self.errors.pop(); } @@ -3011,11 +3035,9 @@ t"{(lambda x:{x})}" ``` [ LexicalError { - error: UnclosedStringError { - triple_quoted: false, - escaped_end_quote: false, - detected_line: 1, - }, + error: FStringError( + UnclosedLbrace, + ), location: 3..3, }, LexicalError { @@ -3050,11 +3072,9 @@ t"{(lambda x:{x})}" ``` [ LexicalError { - error: UnclosedStringError { - triple_quoted: false, - escaped_end_quote: false, - detected_line: 1, - }, + error: FStringError( + UnclosedLbrace, + ), location: 7..7, }, LexicalError { diff --git a/crates/ruff_python_parser/src/lexer/interpolated_string.rs b/crates/ruff_python_parser/src/lexer/interpolated_string.rs index d165be8692c291..1312f91765921a 100644 --- a/crates/ruff_python_parser/src/lexer/interpolated_string.rs +++ b/crates/ruff_python_parser/src/lexer/interpolated_string.rs @@ -98,6 +98,12 @@ impl InterpolatedStringContext { self.open_parentheses_count(current_nesting) > self.format_spec_depth } + /// Returns `true` if the innermost open bracket is the brace that opens the current + /// expression or interpolation. + pub(crate) const fn is_at_interpolation_brace(&self, current_nesting: u32) -> bool { + self.open_parentheses_count(current_nesting) == self.format_spec_depth + 1 + } + /// Returns `true` if the lexer is in a f-string format spec i.e., after a colon. pub(crate) const fn is_in_format_spec(&self, current_nesting: u32) -> bool { self.format_spec_depth > 0 && !self.is_in_interpolation(current_nesting) diff --git a/crates/ruff_python_parser/src/lib.rs b/crates/ruff_python_parser/src/lib.rs index 19b81e5d9ed690..9577be1f7eca30 100644 --- a/crates/ruff_python_parser/src/lib.rs +++ b/crates/ruff_python_parser/src/lib.rs @@ -65,7 +65,8 @@ pub use crate::error::{ BlockClause, ExpressionKind, InterpolatedStringErrorType, LexicalErrorType, NumberLiteralKind, - ParseError, ParseErrorType, UnsupportedSyntaxError, UnsupportedSyntaxErrorKind, + ParseError, ParseErrorType, UnicodeEscapeErrorKind, UnsupportedSyntaxError, + UnsupportedSyntaxErrorKind, }; pub use crate::parser::ParseOptions; diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 60e8081166b434..14d7b65a3bd073 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -371,7 +371,7 @@ impl<'src> Parser<'src> { context: ExpressionContext, ) -> ParsedExpr { if self.at(TokenKind::Lambda) { - Expr::Lambda(self.parse_lambda_expr()).into() + Expr::Lambda(self.parse_lambda_expr(false)).into() } else { let start = self.node_start(); let parsed_expr = self.parse_simple_expression(context); @@ -388,16 +388,22 @@ impl<'src> Parser<'src> { /// another expression. /// /// The error is not reported when the first expression is a name followed by a string (an - /// invalid string prefix), starts with a soft keyword (including `_`), or is the name `print` - /// or `exec`. + /// invalid string prefix) or starts with a soft keyword (including `_`). The name `print` or + /// `exec` followed by an expression is reported as a call missing its parentheses instead. fn check_missing_comma(&mut self, first: &ParsedExpr) { // test_err missing_comma_between_expressions // [a b] // f(x, a.b c) // x[1 + 2 3] // f"{a b}" + // A tokenizer error in or right after the first expression comes first. if !self.at_expr() || self.at(TokenKind::Yield) + || self.at_tokenizer_error() + || self.tokens.has_tokenizer_error_in(TextRange::new( + first.start(), + self.current_token_range().end(), + )) || matches!( first.expr, Expr::Starred(_) @@ -410,14 +416,17 @@ impl<'src> Parser<'src> { { return; } - if let Expr::Name(name) = &first.expr { - if !first.is_parenthesized - && (matches!(name.id.as_str(), "print" | "exec") - || matches!( - self.current_token_kind(), - TokenKind::String | TokenKind::FStringStart | TokenKind::TStringStart - )) - { + if let Expr::Name(name) = &first.expr + && !first.is_parenthesized + { + if matches!(name.id.as_str(), "print" | "exec") { + self.report_legacy_statement(first.start(), name.id.as_str()); + return; + } + if matches!( + self.current_token_kind(), + TokenKind::String | TokenKind::FStringStart | TokenKind::TStringStart + ) { return; } } @@ -440,6 +449,34 @@ impl<'src> Parser<'src> { ); } + /// Reports the Python 2 `print` or `exec` statement named `keyword` that starts at `start` + /// and whose operands start at the current token, unless no prefix of the operands is a + /// complete expression. + fn report_legacy_statement(&mut self, start: TextSize, keyword: &str) { + // test_err legacy_print_statement + // print 'hello' + // [print x, y] + // exec code in ns + + // test_err legacy_print_statement_invalid_operand + // print {1:(foo.)} + // [print 1 +] + let checkpoint = self.checkpoint(); + let errors_before = self.errors.len(); + let operands = self.parse_expression_list(ExpressionContext::starred_bitwise_or()); + let end = self.complete_prefix_end(&operands.expr, errors_before); + self.rewind(checkpoint); + let Some(end) = end else { + return; + }; + self.add_error( + ParseErrorType::OtherError(format!( + "Missing parentheses in call to '{keyword}'. Did you mean {keyword}(...)?" + )), + TextRange::new(start, end), + ); + } + /// Parses every Python expression except unparenthesized tuples, named expressions, /// and `if` expression. /// @@ -616,7 +653,7 @@ impl<'src> Parser<'src> { TokenKind::Lambda => { // Lambda expression isn't allowed in this context but we'll still parse it and // report an error for better recovery. - let lambda_expr = self.parse_lambda_expr(); + let lambda_expr = self.parse_lambda_expr(true); self.add_error(ParseErrorType::InvalidLambdaExpressionUsage, &lambda_expr); return Expr::Lambda(lambda_expr).into(); } @@ -1920,15 +1957,25 @@ impl<'src> Parser<'src> { let mut flags = self.tokens.current_flags().as_any_string_flags(); self.bump(kind.start_token()); + let outer_escape_error = self.interpolated_string_escape_error.take(); let elements = self.parse_interpolated_string_elements( flags, InterpolatedStringElementsKind::Regular(kind), kind, ); + let end_range = self.current_token_range(); if !self.expect(kind.end_token()) { flags = flags.with_unclosed(true); } + // test_err interpolated_string_escape_error + // f'a\N b{x}' + // t'{x}\x1' 'c' + if let Some(error) = + std::mem::replace(&mut self.interpolated_string_escape_error, outer_escape_error) + { + self.add_error(ParseErrorType::Lexical(error), end_range); + } InterpolatedStringData { elements, @@ -1992,11 +2039,9 @@ impl<'src> Parser<'src> { // test_err invalid_fstring_literal_element // f'hello \N{INVALID} world' // f"""hello \N{INVALID} world""" - let location = lex_error.location(); - parser.add_error( - ParseErrorType::Lexical(lex_error.into_error()), - location, - ); + parser + .interpolated_string_escape_error + .get_or_insert(lex_error.into_error()); ast::InterpolatedStringLiteralElement { value: "".into(), range, @@ -2034,6 +2079,124 @@ impl<'src> Parser<'src> { /// # Panics /// /// If the parser isn't positioned at a `{` token. + /// Returns `true` if the tokenizer stops at the current token. + fn at_tokenizer_error(&self) -> bool { + self.tokens + .has_tokenizer_error_in(self.current_token_range()) + } + + /// Reports a replacement field expression that does not start with a valid expression, or + /// whose longest valid prefix is not followed by `=`, `!`, `:` or `}`. The expression starts + /// at `expression_start`, and its errors follow the first `errors_before` errors. + fn check_replacement_field_expression( + &mut self, + expr: &Expr, + expression_start: TextRange, + errors_before: usize, + string_kind: InterpolatedStringKind, + ) { + // test_err f_string_invalid_expression_start + // f"{.}" + // f"{**x}" + // f"{+;}" + // t"{x:{/5}}" + + // test_err f_string_expected_separator_after_expression + // f"{x;y}" + // f"{1 +}" + // f"{a, b and}" + // f"{x.}" + // A tokenizer error up to where the expression fails comes first. + let failure_end = self + .errors + .get(errors_before) + .map_or(self.current_token_range(), |error| error.location) + .end(); + if self + .tokens + .has_tokenizer_error_in(TextRange::new(expression_start.start(), failure_end)) + { + return; + } + let (error, range) = match self.errors.get(errors_before) { + Some(first) if matches!(first.error, ParseErrorType::ExpectedExpression) => { + match self.complete_prefix_end(expr, errors_before) { + None => ( + InterpolatedStringErrorType::ExpectedExpressionAfterLbrace, + expression_start, + ), + Some(end) => ( + InterpolatedStringErrorType::ExpectedSeparatorAfterExpression, + self.token_after(end).1, + ), + } + } + Some(_) => return, + None if replacement_field_separator(self.current_token_kind()).is_some() => return, + None => ( + InterpolatedStringErrorType::ExpectedSeparatorAfterExpression, + self.current_token_range(), + ), + }; + self.errors.insert( + errors_before, + ParseError { + error: ParseErrorType::from_interpolated_string_error(error, string_kind), + location: range, + }, + ); + } + + /// Returns the end of the longest prefix of `expr` that is a complete expression, where an + /// expression is incomplete if one of the errors after the first `errors_before` errors is + /// inside it, or `None` if no prefix is complete. + fn complete_prefix_end(&self, expr: &Expr, errors_before: usize) -> Option { + let is_complete = |expr: &Expr| { + !self.errors[errors_before..] + .iter() + .any(|error| expr.range().contains_inclusive(error.location.start())) + }; + if is_complete(expr) { + return Some(expr.end()); + } + let operands: Vec<&Expr> = match expr { + Expr::BinOp(ast::ExprBinOp { left, right, .. }) => vec![left, right], + Expr::BoolOp(ast::ExprBoolOp { values, .. }) => values.iter().collect(), + Expr::Compare(ast::ExprCompare { operands, .. }) => operands.iter().collect(), + Expr::Tuple(ast::ExprTuple { + elts, + parenthesized: false, + .. + }) => elts.iter().collect(), + Expr::Attribute(ast::ExprAttribute { value, .. }) + | Expr::Subscript(ast::ExprSubscript { value, .. }) => vec![value], + Expr::Call(ast::ExprCall { func, .. }) => vec![func], + Expr::If(ast::ExprIf { body, .. }) => vec![body], + _ => return None, + }; + let mut end = None; + for operand in operands { + if is_complete(operand) { + end = Some(operand.end()); + continue; + } + if let Some(operand_end) = self.complete_prefix_end(operand, errors_before) { + return Some(operand_end); + } + break; + } + // A trailing comma ends a valid tuple. + if expr.is_tuple_expr() + && let Some(end) = end + { + let (kind, range) = self.token_after(end); + if kind == TokenKind::Comma { + return Some(range.end()); + } + } + end + } + fn parse_interpolated_element( &mut self, flags: ast::AnyStringFlags, @@ -2067,28 +2230,57 @@ impl<'src> Parser<'src> { // t"{*x and y}" // t"{*yield x}" - let value = self.parse_expression_list(ExpressionContext::yield_or_starred_bitwise_or()); - - if !value.is_parenthesized && value.expr.is_lambda_expr() { - // TODO(dhruvmanila): This requires making some changes in lambda expression - // parsing logic to handle the emitted `FStringMiddle` token in case the - // lambda expression is not parenthesized. - - // test_err f_string_lambda_without_parentheses - // f"{lambda x: x}" - - // test_err t_string_lambda_without_parentheses - // # parse_options: {"target-version": "3.14"} - // t"{lambda x: x}" + // test_err f_string_expression_required_before_separator + // f"{=x}" + // f"{!r}" + // t"{:x}" + let expression_start = self.current_token_range(); + let errors_before = self.errors.len(); + if let Some(separator) = replacement_field_separator(self.current_token_kind()) { self.add_error( ParseErrorType::from_interpolated_string_error( - InterpolatedStringErrorType::LambdaWithoutParentheses, + InterpolatedStringErrorType::ExpressionRequiredBefore(separator), string_kind, ), - value.range(), + expression_start, ); } + + // test_err f_string_lambda_without_parentheses + // f"{lambda x: x}" + + // test_err t_string_lambda_without_parentheses + // # parse_options: {"target-version": "3.14"} + // t"{lambda x: x}" + let outer_field = self + .replacement_field + .replace((string_kind, self.bracket_level())); + let value = self.parse_expression_list(ExpressionContext::yield_or_starred_bitwise_or()); + self.replacement_field = outer_field; + self.check_replacement_field_expression( + &value.expr, + expression_start, + errors_before, + string_kind, + ); + let debug_text = if self.eat(TokenKind::Equal) { + // test_err f_string_expected_separator_after_debug + // f"{x=y}" + if !self.at_ts(TokenSet::new([ + TokenKind::Exclamation, + TokenKind::Colon, + TokenKind::Rbrace, + ])) && !self.at_tokenizer_error() + { + self.add_error( + ParseErrorType::from_interpolated_string_error( + InterpolatedStringErrorType::ExpectedSeparatorAfterDebug, + string_kind, + ), + self.current_token_range(), + ); + } let leading_range = TextRange::new(start + "{".text_len(), value.start()); let trailing_range = TextRange::new(value.end(), self.current_token_range().start()); Some(ast::DebugText::new( @@ -2106,7 +2298,19 @@ impl<'src> Parser<'src> { self.tokens.re_lex_raw_string_in_format_spec(); let conversion_flag_range = self.current_token_range(); - if self.at(TokenKind::Identifier) { + if self.at(TokenKind::Colon) || self.at(TokenKind::Rbrace) { + // test_err f_string_missing_conversion_flag + // f"{x!}" + // f"{x=!:}" + self.add_error( + ParseErrorType::from_interpolated_string_error( + InterpolatedStringErrorType::MissingConversionFlag, + string_kind, + ), + conversion_flag_range, + ); + ConversionFlag::None + } else if self.at(TokenKind::Identifier) { // test_err f_string_conversion_follows_exclamation // f"{x! s}" // t"{x! s}" @@ -2121,7 +2325,7 @@ impl<'src> Parser<'src> { ); } let name = self.bump_identifier(); - match &*name { + let flag = match &*name { "s" => ConversionFlag::Str, "r" => ConversionFlag::Repr, "a" => ConversionFlag::Ascii, @@ -2133,15 +2337,30 @@ impl<'src> Parser<'src> { // # parse_options: {"target-version": "3.14"} // t"{x!z}" self.add_error( - ParseErrorType::from_interpolated_string_error( - InterpolatedStringErrorType::InvalidConversionFlag, - string_kind, - ), + ParseErrorType::OtherError(format!( + "{string_kind}: invalid conversion character '{name}': expected 's', 'r', or 'a'" + )), conversion_flag_range, ); ConversionFlag::None } + }; + // test_err f_string_expected_separator_after_conversion + // f"{x!s!}" + // f"{x!r{y}}" + if !self.at(TokenKind::Colon) + && !self.at(TokenKind::Rbrace) + && !self.at_tokenizer_error() + { + self.add_error( + ParseErrorType::from_interpolated_string_error( + InterpolatedStringErrorType::ExpectedSeparatorAfterConversion, + string_kind, + ), + self.current_token_range(), + ); } + flag } else { // test_err f_string_invalid_conversion_flag_other_tok // f"{x!123}" @@ -2166,6 +2385,7 @@ impl<'src> Parser<'src> { ConversionFlag::None }; + let has_format_spec = self.at(TokenKind::Colon); let format_spec = if self.eat(TokenKind::Colon) { let spec_start = self.node_start(); let elements = self.with_recursion(|parser| { @@ -2218,11 +2438,16 @@ impl<'src> Parser<'src> { // # parse_options: {"target-version": "3.14"} // t"hello {x:" // t"hello {x:.3f" + + // test_err f_string_unclosed_format_spec + // f"{x!s:" + let error = if has_format_spec { + InterpolatedStringErrorType::UnclosedFormatSpec + } else { + InterpolatedStringErrorType::UnclosedLbrace + }; self.add_error( - ParseErrorType::from_interpolated_string_error( - InterpolatedStringErrorType::UnclosedLbrace, - string_kind, - ), + ParseErrorType::from_interpolated_string_error(error, string_kind), self.current_token_range(), ); } @@ -3395,7 +3620,8 @@ impl<'src> Parser<'src> { /// If the parser isn't positioned at a `lambda` token. /// /// See: - fn parse_lambda_expr(&mut self) -> ast::ExprLambda { + /// Parses a lambda expression, which is an operand of another expression if `is_operand`. + fn parse_lambda_expr(&mut self, is_operand: bool) -> ast::ExprLambda { let start = self.node_start(); self.bump(TokenKind::Lambda); @@ -3407,6 +3633,24 @@ impl<'src> Parser<'src> { Some(Box::new(self.parse_parameters(FunctionKind::Lambda))) }; + // A `:` at the level of a replacement field starts its format spec. + if !is_operand + && self.at(TokenKind::Colon) + && let Some((kind, level)) = self.replacement_field + && level == self.bracket_level() + { + // test_err lambda_in_replacement_field + // f"{lambda x:x}" + // f"{1, lambda:x}" + // t"{lambda x:}" + self.add_error( + ParseErrorType::from_interpolated_string_error( + InterpolatedStringErrorType::LambdaWithoutParentheses, + kind, + ), + TextRange::new(start, self.current_token_range().end()), + ); + } self.expect(TokenKind::Colon); // test_ok lambda_with_valid_body @@ -3698,6 +3942,17 @@ bitflags! { } } +/// Returns the character of `kind` if it separates the parts of a replacement field. +fn replacement_field_separator(kind: TokenKind) -> Option { + match kind { + TokenKind::Equal => Some('='), + TokenKind::Exclamation => Some('!'), + TokenKind::Colon => Some(':'), + TokenKind::Rbrace => Some('}'), + _ => None, + } +} + impl ExpressionContext { /// Create a new context allowing starred expression at conditional precedence. pub(super) fn starred_conditional() -> Self { diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index dba7e60aaedf0e..6fdb1e7c6f717f 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -16,7 +16,9 @@ use rustc_hash::FxBuildHasher; use thin_vec::ThinVec; use unicode_normalization::UnicodeNormalization; -use crate::error::{LexicalError, LexicalErrorType, UnsupportedSyntaxError}; +use crate::error::{ + InterpolatedStringErrorType, LexicalError, LexicalErrorType, UnsupportedSyntaxError, +}; use crate::lexer::Lexer; use crate::parser::expression::ExpressionContext; use crate::parser::progress::{ParserProgress, TokenId}; @@ -104,6 +106,14 @@ pub(crate) struct Parser<'src> { /// bracket's logical line. first_unclosed_bracket_recovery: Option, + /// The first escape sequence error in a literal part of the f-string or t-string being + /// parsed. It is reported at the closing quote once the string ends. + interpolated_string_escape_error: Option, + + /// The kind of the innermost f-string or t-string whose replacement field expression is + /// being parsed, and the bracket level inside its brace, where a `:` starts the format spec. + replacement_field: Option<(InterpolatedStringKind, usize)>, + /// Number of active recursive statement, expression, and pattern parsing operations. recursion_depth: usize, @@ -161,6 +171,8 @@ impl<'src> Parser<'src> { prev_token_end: TextSize::new(0), start_offset, first_unclosed_bracket_recovery: None, + interpolated_string_escape_error: None, + replacement_field: None, recursion_depth: 0, current_token_id: TokenId::default(), expr_scratch: ScratchBuffer::with_capacity(16), @@ -304,6 +316,17 @@ impl<'src> Parser<'src> { .cmp(&lex_error.location().start()) { Ordering::Less => merged.push(parse_errors.next().unwrap()), + // A replacement field error at a token the tokenizer accepts replaces the lex + // error of that token. + Ordering::Equal + if matches!( + parse_error.error, + ParseErrorType::FStringError(_) | ParseErrorType::TStringError(_) + ) && !lex_error.error().is_tokenizer_error() => + { + lex_errors.next().unwrap(); + merged.push(parse_errors.next().unwrap()); + } Ordering::Equal => { // Skip the parse error if we already have a lex error at the same location.. parse_errors.next().unwrap(); @@ -1983,7 +2006,20 @@ fn prioritize_tokenizer_error( .iter() .find(|error| error.error().is_tokenizer_error()) { - break (error.clone(), in_interpolated_string, lexer.offset()); + // A missing closing brace or a bracket that closes a replacement field is found at + // the token that shows it. + let detected = match error.error() { + LexicalErrorType::FStringError( + InterpolatedStringErrorType::UnclosedLbrace + | InterpolatedStringErrorType::UnmatchedBracket(_), + ) + | LexicalErrorType::TStringError( + InterpolatedStringErrorType::UnclosedLbrace + | InterpolatedStringErrorType::UnmatchedBracket(_), + ) => error.location().start(), + _ => lexer.offset(), + }; + break (error.clone(), in_interpolated_string, detected); } if matches!( kind, diff --git a/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__tstring_fstring_middle.snap b/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__tstring_fstring_middle.snap index 12c9787631e776..45027e176617d4 100644 --- a/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__tstring_fstring_middle.snap +++ b/crates/ruff_python_parser/src/parser/snapshots/ruff_python_parser__parser__tests__tstring_fstring_middle.snap @@ -3,6 +3,10 @@ source: crates/ruff_python_parser/src/parser/tests.rs expression: error --- ParseError { - error: ExpectedExpression, + error: TStringError( + ExpressionRequiredBefore( + ':', + ), + ), location: 3..4, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_unicode_literal.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_unicode_literal.snap index 05ba4616d513a7..24deb403ce9f4f 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_unicode_literal.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_unicode_literal.snap @@ -4,7 +4,11 @@ expression: error --- ParseError { error: Lexical( - UnicodeError, + UnicodeEscapeError { + kind: TruncatedHexByte, + start: 0, + end: 2, + }, ), - location: 4..6, + location: 0..9, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_unicode_name_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_unicode_name_error.snap index d657f5063d6845..92cfae586e9f53 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_unicode_name_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__invalid_unicode_name_error.snap @@ -4,7 +4,11 @@ expression: error --- ParseError { error: Lexical( - UnicodeError, + UnicodeEscapeError { + kind: UnknownName, + start: 0, + end: 10, + }, ), - location: 4..11, + location: 0..13, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__missing_unicode_lbrace_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__missing_unicode_lbrace_error.snap index fec204c0dffd1a..1dd2c53b0e0c7d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__missing_unicode_lbrace_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__missing_unicode_lbrace_error.snap @@ -4,7 +4,11 @@ expression: error --- ParseError { error: Lexical( - MissingUnicodeLbrace, + UnicodeEscapeError { + kind: MalformedName, + start: 0, + end: 1, + }, ), - location: 3..3, + location: 0..5, } diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__missing_unicode_rbrace_error.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__missing_unicode_rbrace_error.snap index c052b292f56704..4987a7c98b5b87 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__missing_unicode_rbrace_error.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__missing_unicode_rbrace_error.snap @@ -4,7 +4,11 @@ expression: error --- ParseError { error: Lexical( - MissingUnicodeRbrace, + UnicodeEscapeError { + kind: MalformedName, + start: 0, + end: 7, + }, ), - location: 9..9, + location: 0..10, } diff --git a/crates/ruff_python_parser/src/string.rs b/crates/ruff_python_parser/src/string.rs index f8a82a6ad6496f..a9083b2b8f3eeb 100644 --- a/crates/ruff_python_parser/src/string.rs +++ b/crates/ruff_python_parser/src/string.rs @@ -7,7 +7,7 @@ use ruff_python_ast::token::TokenKind; use ruff_python_ast::{self as ast, AnyStringFlags, AtomicNodeIndex, Expr, StringFlags}; use ruff_text_size::{Ranged, TextRange, TextSize}; -use crate::error::{LexicalError, LexicalErrorType}; +use crate::error::{LexicalError, LexicalErrorType, UnicodeEscapeErrorKind}; #[derive(Debug)] pub(crate) enum StringType { @@ -153,34 +153,87 @@ impl<'src> StringParser<'src> { self.source.as_bytes()[self.cursor..].first().copied() } - fn parse_unicode_literal(&mut self, literal_number: usize) -> Result { + #[inline] + fn peek_char(&self) -> Option { + self.source[self.cursor..].chars().next() + } + + /// Returns the position of the byte at `index` as the unicode escape decoder sees the + /// content: every non-ASCII character is replaced by its `\UXXXXXXXX` escape, and a + /// backslash that starts a pair before a non-ASCII character or at the end gains `u005c`. + fn escape_position(&self, index: usize) -> u32 { + let width = |c: char| if c.is_ascii() { 1 } else { 10 }; + let mut position = 0; + let mut chars = self.source.char_indices().peekable(); + while let Some((offset, c)) = chars.next() { + if offset >= index { + break; + } + if c != '\\' { + position += width(c); + continue; + } + position += 1; + let Some(&(next_offset, next)) = chars.peek() else { + position += 5; + break; + }; + if !next.is_ascii() { + position += 5; + } + if next_offset >= index { + break; + } + chars.next(); + position += width(next); + } + position + } + + /// Returns the error for the escape sequence starting at the backslash at `start`, where the + /// decoder stopped before the byte at `end`. + fn escape_error(&self, kind: UnicodeEscapeErrorKind, start: usize, end: usize) -> LexicalError { + let error = if self.flags.is_byte_string() { + LexicalErrorType::BytesEscapeError { + position: u32::try_from(start).unwrap(), + } + } else { + LexicalErrorType::UnicodeEscapeError { + kind, + start: self.escape_position(start), + end: self.escape_position(end) - 1, + } + }; + LexicalError::new(error, self.range) + } + + fn parse_unicode_literal( + &mut self, + literal_number: usize, + escape_start: usize, + ) -> Result { + let kind = match literal_number { + 2 => UnicodeEscapeErrorKind::TruncatedHexByte, + 4 => UnicodeEscapeErrorKind::TruncatedShortUnicode, + _ => UnicodeEscapeErrorKind::TruncatedLongUnicode, + }; let mut p: u32 = 0u32; for i in 1..=literal_number { - let start = self.position(); - match self.next_char() { - Some(c) => match c.to_digit(16) { - Some(d) => p += d << ((literal_number - i) * 4), - None => { - return Err(LexicalError::new( - LexicalErrorType::UnicodeError, - TextRange::at(start, TextSize::try_from(c.len_utf8()).unwrap()), - )); - } - }, - None => { - return Err(LexicalError::new( - LexicalErrorType::UnicodeError, - TextRange::empty(self.position()), - )); - } - } + let Some(d) = self.peek_char().and_then(|c| c.to_digit(16)) else { + return Err(self.escape_error(kind, escape_start, self.cursor)); + }; + self.cursor += 1; + p += d << ((literal_number - i) * 4); } match p { 0xD800..=0xDFFF => Ok(std::char::REPLACEMENT_CHARACTER), - _ => std::char::from_u32(p).ok_or(LexicalError::new( - LexicalErrorType::UnicodeError, - TextRange::empty(self.position()), - )), + _ => std::char::from_u32(p).ok_or_else(|| { + self.escape_error( + UnicodeEscapeErrorKind::IllegalCharacter, + escape_start, + self.cursor, + ) + }), } } @@ -203,41 +256,45 @@ impl<'src> StringParser<'src> { char::from_u32(value).unwrap() } - fn parse_unicode_name(&mut self) -> Result { - let start_pos = self.position(); - let Some('{') = self.next_char() else { - return Err(LexicalError::new( - LexicalErrorType::MissingUnicodeLbrace, - TextRange::empty(start_pos), + fn parse_unicode_name(&mut self, escape_start: usize) -> Result { + if self.peek_char() != Some('{') { + return Err(self.escape_error( + UnicodeEscapeErrorKind::MalformedName, + escape_start, + self.cursor, )); - }; - - let start_pos = self.position(); + } + self.cursor += 1; let Some(close_idx) = self.source[self.cursor..].find('}') else { - return Err(LexicalError::new( - LexicalErrorType::MissingUnicodeRbrace, - TextRange::empty(self.compute_position(self.source.len())), + return Err(self.escape_error( + UnicodeEscapeErrorKind::MalformedName, + escape_start, + self.source.len(), )); }; + if close_idx == 0 { + return Err(self.escape_error( + UnicodeEscapeErrorKind::MalformedName, + escape_start, + self.cursor, + )); + } let name_and_ending = self.skip_bytes(close_idx + 1); let name = &name_and_ending[..name_and_ending.len() - 1]; unicode_names2::character(name).ok_or_else(|| { - LexicalError::new( - LexicalErrorType::UnicodeError, - // The cursor is right after the `}` character, so we subtract 1 to get the correct - // range of the unicode name. - TextRange::new( - start_pos, - self.compute_position(self.cursor - '}'.len_utf8()), - ), + self.escape_error( + UnicodeEscapeErrorKind::UnknownName, + escape_start, + self.cursor, ) }) } /// Parse an escaped character, returning the new character. fn parse_escaped_char(&mut self) -> Result, LexicalError> { + let escape_start = self.cursor - 1; let Some(first_char) = self.next_char() else { // TODO: check when this error case happens return Err(LexicalError::new( @@ -258,10 +315,10 @@ impl<'src> StringParser<'src> { 't' => '\t', 'v' => '\x0b', o @ '0'..='7' => self.parse_octet(o as u8), - 'x' => self.parse_unicode_literal(2)?, - 'u' if !self.flags.is_byte_string() => self.parse_unicode_literal(4)?, - 'U' if !self.flags.is_byte_string() => self.parse_unicode_literal(8)?, - 'N' if !self.flags.is_byte_string() => self.parse_unicode_name()?, + 'x' => self.parse_unicode_literal(2, escape_start)?, + 'u' if !self.flags.is_byte_string() => self.parse_unicode_literal(4, escape_start)?, + 'U' if !self.flags.is_byte_string() => self.parse_unicode_literal(8, escape_start)?, + 'N' if !self.flags.is_byte_string() => self.parse_unicode_name(escape_start)?, // Special cases where the escape sequence is not a single character '\n' => return Ok(None), '\r' => { @@ -641,7 +698,7 @@ mod tests { fn test_parse_invalid_fstring() { use InterpolatedStringErrorType::{InvalidConversionFlag, LambdaWithoutParentheses}; - assert_eq!(parse_fstring_error(r#"f"{5!x}""#), InvalidConversionFlag); + assert_eq!(parse_fstring_error(r#"f"{5!1}""#), InvalidConversionFlag); assert_eq!( parse_fstring_error("f'{lambda x:{x}}'"), LambdaWithoutParentheses @@ -762,7 +819,7 @@ mod tests { fn test_parse_invalid_tstring() { use InterpolatedStringErrorType::{InvalidConversionFlag, LambdaWithoutParentheses}; - assert_eq!(parse_tstring_error(r#"t"{5!x}""#), InvalidConversionFlag); + assert_eq!(parse_tstring_error(r#"t"{5!1}""#), InvalidConversionFlag); assert_eq!( parse_tstring_error("t'{lambda x:{x}}'"), LambdaWithoutParentheses diff --git a/crates/ruff_python_parser/src/token_source.rs b/crates/ruff_python_parser/src/token_source.rs index 7df04f60a517bb..c4dabb52414081 100644 --- a/crates/ruff_python_parser/src/token_source.rs +++ b/crates/ruff_python_parser/src/token_source.rs @@ -52,6 +52,13 @@ impl<'src> TokenSource<'src> { self.lexer.current_flags() } + /// Returns `true` if the lexer found an error that stops tokenization in `range`. + pub(crate) fn has_tokenizer_error_in(&self, range: TextRange) -> bool { + self.lexer.errors().iter().any(|error| { + range.contains_inclusive(error.location().start()) && error.error().is_tokenizer_error() + }) + } + /// Calls the underlying [`re_lex_logical_token`] method on the lexer with the new lexer /// position and updates the token vector accordingly. /// diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_conversion_follows_exclamation.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_conversion_follows_exclamation.py.snap index 8be51c4f0d1836..fc0e1b0382e98e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_conversion_follows_exclamation.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_conversion_follows_exclamation.py.snap @@ -194,4 +194,4 @@ Module( 1 | f"{x! s}" 2 | t"{x! s}" 3 | f"{x! z}" - | ^ Syntax Error: f-string: invalid conversion character + | ^ Syntax Error: f-string: invalid conversion character 'z': expected 's', 'r', or 'a' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap index ba840d556a744a..c2b80ea23edb7e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_empty_expression.py.snap @@ -119,7 +119,7 @@ Module( | 1 | f"{}" - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: f-string: valid expression required before '}' 2 | f"{ }" | @@ -127,4 +127,4 @@ Module( | 1 | f"{}" 2 | f"{ }" - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: f-string: valid expression required before '}' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_conversion.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_conversion.py.snap new file mode 100644 index 00000000000000..d905e0265abbac --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_conversion.py.snap @@ -0,0 +1,163 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_conversion.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..22, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..9, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 0..9, + value: FStringValue { + inner: Single( + FString { + range: 0..9, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 2..6, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("x"), + ctx: Load, + }, + ), + debug_text: None, + conversion: Str, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 10..21, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 10..21, + value: FStringValue { + inner: Single( + FString { + range: 10..21, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 12..16, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 13..14, + id: Name("x"), + ctx: Load, + }, + ), + debug_text: None, + conversion: Repr, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + Interpolation( + InterpolatedElement { + range: 16..19, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 17..18, + id: Name("y"), + ctx: Load, + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f"{x!s!}" + | ^ Syntax Error: f-string: expecting ':' or '}' +2 | f"{x!r{y}}" + | + + + | +1 | f"{x!s!}" + | ^ Syntax Error: expected an element of or the end of the f-string +2 | f"{x!r{y}}" + | + + + | +1 | f"{x!s!}" +2 | f"{x!r{y}}" + | ^ Syntax Error: f-string: expecting ':' or '}' + + + | +1 | f"{x!s!}" +2 | f"{x!r{y}}" + | ^ Syntax Error: expected an element of or the end of the f-string diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_debug.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_debug.py.snap new file mode 100644 index 00000000000000..8d315d0956b39b --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_debug.py.snap @@ -0,0 +1,117 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_debug.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..9, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 0..5, + value: FStringValue { + inner: Single( + FString { + range: 0..5, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 2..5, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("x"), + ctx: Load, + }, + ), + debug_text: Some( + DebugText { + leading: "", + expression: "x", + trailing: "=", + }, + ), + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: true, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 5..6, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 5..6, + id: Name("y"), + ctx: Load, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f"{x=y}" + | ^ Syntax Error: f-string: expecting '!', or ':', or '}' + + + | +1 | f"{x=y}" + | ^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + + | +1 | f"{x=y}" + | ^ Syntax Error: invalid syntax + + + | +1 | f"{x=y}" + | ^ Syntax Error: f-string: single '}' is not allowed + + + | +1 | f"{x=y}" + | ^ Syntax Error: invalid syntax + + + | +1 | f"{x=y}" + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_expression.py.snap new file mode 100644 index 00000000000000..29185a3fb91ab7 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_expression.py.snap @@ -0,0 +1,650 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/f_string_expected_separator_after_expression.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..104, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..4, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 0..4, + value: FStringValue { + inner: Single( + FString { + range: 0..4, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 2..4, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("x"), + ctx: Load, + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: true, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 5..6, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 5..6, + id: Name("y"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 9..17, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 9..17, + value: FStringValue { + inner: Single( + FString { + range: 9..17, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 11..16, + node_index: NodeIndex(None), + expression: BinOp( + ExprBinOp { + node_index: NodeIndex(None), + range: 12..15, + left: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 12..13, + value: Int( + 1, + ), + }, + ), + op: Add, + right: Name( + ExprName { + node_index: NodeIndex(None), + range: 15..15, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 18..31, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 18..31, + value: FStringValue { + inner: Single( + FString { + range: 18..31, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 20..30, + node_index: NodeIndex(None), + expression: Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 21..29, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 21..22, + id: Name("a"), + ctx: Load, + }, + ), + BoolOp( + ExprBoolOp { + node_index: NodeIndex(None), + range: 24..29, + op: And, + values: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 24..25, + id: Name("b"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 29..29, + id: Name(""), + ctx: Invalid, + }, + ), + ], + runtime_values: None, + }, + ), + ], + ctx: Load, + parenthesized: false, + runtime_elts: None, + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 32..39, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 32..39, + value: FStringValue { + inner: Single( + FString { + range: 32..39, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 34..38, + node_index: NodeIndex(None), + expression: Attribute( + ExprAttribute { + node_index: NodeIndex(None), + range: 35..37, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 35..36, + id: Name("x"), + ctx: Load, + }, + ), + attr: Identifier { + id: Name(""), + range: 37..37, + node_index: NodeIndex(None), + }, + ctx: Load, + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 40..41, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 40..41, + id: Name("A"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 42..51, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 42..51, + id: Name("tokenizer"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 52..57, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 52..57, + id: Name("error"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 58..60, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 58..60, + id: Name("up"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 61..63, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 61..63, + id: Name("to"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 64..69, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 64..69, + id: Name("where"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 70..73, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 70..73, + id: Name("the"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 74..84, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 74..84, + id: Name("expression"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 85..90, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 85..90, + id: Name("fails"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 91..96, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 91..96, + id: Name("comes"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 97..103, + value: Attribute( + ExprAttribute { + node_index: NodeIndex(None), + range: 97..103, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 97..102, + id: Name("first"), + ctx: Load, + }, + ), + attr: Identifier { + id: Name(""), + range: 103..103, + node_index: NodeIndex(None), + }, + ctx: Load, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f"{x;y}" + | ^ Syntax Error: f-string: expecting '=', or '!', or ':', or '}' +2 | f"{1 +}" +3 | f"{a, b and}" + | + + + | +1 | f"{x;y}" + | ^ Syntax Error: invalid syntax +2 | f"{1 +}" +3 | f"{a, b and}" + | + + + | +1 | f"{x;y}" + | ^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +2 | f"{1 +}" +3 | f"{a, b and}" + | + + + | +1 | f"{x;y}" + | ^ Syntax Error: invalid syntax +2 | f"{1 +}" +3 | f"{a, b and}" + | + + + | +1 | f"{x;y}" + | ^ Syntax Error: f-string: single '}' is not allowed +2 | f"{1 +}" +3 | f"{a, b and}" + | + + + | +1 | f"{x;y}" + | ^ Syntax Error: invalid syntax +2 | f"{1 +}" +3 | f"{a, b and}" + | + + + | +1 | f"{x;y}" + | ^ Syntax Error: invalid syntax +2 | f"{1 +}" +3 | f"{a, b and}" +4 | f"{x.}" + | + + + | +1 | f"{x;y}" +2 | f"{1 +}" + | ^ Syntax Error: f-string: expecting '=', or '!', or ':', or '}' +3 | f"{a, b and}" +4 | f"{x.}" + | + + + | +1 | f"{x;y}" +2 | f"{1 +}" + | ^ Syntax Error: invalid syntax +3 | f"{a, b and}" +4 | f"{x.}" + | + + + | +1 | f"{x;y}" +2 | f"{1 +}" +3 | f"{a, b and}" + | ^^^ Syntax Error: f-string: expecting '=', or '!', or ':', or '}' +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | + + + | +1 | f"{x;y}" +2 | f"{1 +}" +3 | f"{a, b and}" + | ^ Syntax Error: invalid syntax +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | + + + | +2 | f"{1 +}" +3 | f"{a, b and}" +4 | f"{x.}" + | ^ Syntax Error: invalid syntax +5 | A tokenizer error up to where the expression fails comes first. + | + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^^^^^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^^^^^^^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^^^^^^^^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | f"{a, b and}" +4 | f"{x.}" +5 | A tokenizer error up to where the expression fails comes first. + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expression_required_before_separator.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expression_required_before_separator.py.snap new file mode 100644 index 00000000000000..d1c9f3b8c8786d --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expression_required_before_separator.py.snap @@ -0,0 +1,272 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/f_string_expression_required_before_separator.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..24, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..4, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 0..4, + value: FStringValue { + inner: Single( + FString { + range: 0..4, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 2..4, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..3, + id: Name(""), + ctx: Invalid, + }, + ), + debug_text: Some( + DebugText { + leading: "", + expression: "", + trailing: "=", + }, + ), + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: true, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 4..5, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 4..5, + id: Name("x"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 8..15, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 8..15, + value: FStringValue { + inner: Single( + FString { + range: 8..15, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 10..14, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 11..11, + id: Name(""), + ctx: Invalid, + }, + ), + debug_text: None, + conversion: Repr, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 16..23, + value: TString( + ExprTString { + node_index: NodeIndex(None), + range: 16..23, + value: TStringValue { + inner: Single( + TString { + range: 16..23, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 18..22, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 19..19, + id: Name(""), + ctx: Invalid, + }, + ), + debug_text: None, + conversion: None, + format_spec: Some( + InterpolatedStringFormatSpec { + range: 20..21, + node_index: NodeIndex(None), + elements: [ + Literal( + InterpolatedStringLiteralElement { + range: 20..21, + node_index: NodeIndex(None), + value: "x", + }, + ), + ], + }, + ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: TStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_template_str: None, + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f"{=x}" + | ^ Syntax Error: f-string: valid expression required before '=' +2 | f"{!r}" +3 | t"{:x}" + | + + + | +1 | f"{=x}" + | ^ Syntax Error: f-string: expecting '!', or ':', or '}' +2 | f"{!r}" +3 | t"{:x}" + | + + + | +1 | f"{=x}" + | ^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +2 | f"{!r}" +3 | t"{:x}" + | + + + | +1 | f"{=x}" + | ^ Syntax Error: invalid syntax +2 | f"{!r}" +3 | t"{:x}" + | + + + | +1 | f"{=x}" + | ^ Syntax Error: f-string: single '}' is not allowed +2 | f"{!r}" +3 | t"{:x}" + | + + + | +1 | f"{=x}" + | ^ Syntax Error: invalid syntax +2 | f"{!r}" +3 | t"{:x}" + | + + + | +1 | f"{=x}" + | ^ Syntax Error: invalid syntax +2 | f"{!r}" +3 | t"{:x}" + | + + + | +1 | f"{=x}" +2 | f"{!r}" + | ^ Syntax Error: f-string: valid expression required before '!' +3 | t"{:x}" + | + + + | +1 | f"{=x}" +2 | f"{!r}" +3 | t"{:x}" + | ^ Syntax Error: t-string: valid expression required before ':' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_name_tok.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_name_tok.py.snap index 57da1ff90707e3..d0db965040062d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_name_tok.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_conversion_flag_name_tok.py.snap @@ -69,4 +69,4 @@ Module( | 1 | f"{x!z}" - | ^ Syntax Error: f-string: invalid conversion character + | ^ Syntax Error: f-string: invalid conversion character 'z': expected 's', 'r', or 'a' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_expression_start.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_expression_start.py.snap new file mode 100644 index 00000000000000..fa1660988b4bf5 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_expression_start.py.snap @@ -0,0 +1,377 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/f_string_invalid_expression_start.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..36, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..6, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 0..6, + value: FStringValue { + inner: Single( + FString { + range: 0..6, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 2..5, + node_index: NodeIndex(None), + expression: Attribute( + ExprAttribute { + node_index: NodeIndex(None), + range: 3..4, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..3, + id: Name(""), + ctx: Invalid, + }, + ), + attr: Identifier { + id: Name(""), + range: 4..4, + node_index: NodeIndex(None), + }, + ctx: Load, + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 7..15, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 7..15, + value: FStringValue { + inner: Single( + FString { + range: 7..15, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 9..14, + node_index: NodeIndex(None), + expression: BinOp( + ExprBinOp { + node_index: NodeIndex(None), + range: 10..13, + left: Name( + ExprName { + node_index: NodeIndex(None), + range: 10..10, + id: Name(""), + ctx: Invalid, + }, + ), + op: Pow, + right: Name( + ExprName { + node_index: NodeIndex(None), + range: 12..13, + id: Name("x"), + ctx: Load, + }, + ), + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 16..23, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 16..23, + value: FStringValue { + inner: Single( + FString { + range: 16..23, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 18..20, + node_index: NodeIndex(None), + expression: UnaryOp( + ExprUnaryOp { + node_index: NodeIndex(None), + range: 19..20, + op: UAdd, + operand: Name( + ExprName { + node_index: NodeIndex(None), + range: 20..20, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 24..35, + value: TString( + ExprTString { + node_index: NodeIndex(None), + range: 24..35, + value: TStringValue { + inner: Single( + TString { + range: 24..35, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 26..34, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 27..28, + id: Name("x"), + ctx: Load, + }, + ), + debug_text: None, + conversion: None, + format_spec: Some( + InterpolatedStringFormatSpec { + range: 29..33, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 29..33, + node_index: NodeIndex(None), + expression: BinOp( + ExprBinOp { + node_index: NodeIndex(None), + range: 30..32, + left: Name( + ExprName { + node_index: NodeIndex(None), + range: 30..30, + id: Name(""), + ctx: Invalid, + }, + ), + op: Div, + right: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 31..32, + value: Int( + 5, + ), + }, + ), + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + }, + ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: TStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_template_str: None, + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f"{.}" + | ^ Syntax Error: f-string: expecting a valid expression after '{' +2 | f"{**x}" +3 | f"{+;}" + | + + + | +1 | f"{.}" + | ^ Syntax Error: invalid syntax +2 | f"{**x}" +3 | f"{+;}" + | + + + | +1 | f"{.}" + | ^ Syntax Error: invalid syntax +2 | f"{**x}" +3 | f"{+;}" + | + + + | +1 | f"{.}" +2 | f"{**x}" + | ^^ Syntax Error: f-string: expecting a valid expression after '{' +3 | f"{+;}" +4 | t"{x:{/5}}" + | + + + | +1 | f"{.}" +2 | f"{**x}" + | ^^ Syntax Error: invalid syntax +3 | f"{+;}" +4 | t"{x:{/5}}" + | + + + | +1 | f"{.}" +2 | f"{**x}" +3 | f"{+;}" + | ^ Syntax Error: f-string: expecting a valid expression after '{' +4 | t"{x:{/5}}" + | + + + | +1 | f"{.}" +2 | f"{**x}" +3 | f"{+;}" + | ^ Syntax Error: invalid syntax +4 | t"{x:{/5}}" + | + + + | +1 | f"{.}" +2 | f"{**x}" +3 | f"{+;}" + | ^ Syntax Error: expected an element of or the end of the f-string +4 | t"{x:{/5}}" + | + + + | +2 | f"{**x}" +3 | f"{+;}" +4 | t"{x:{/5}}" + | ^ Syntax Error: t-string: expecting a valid expression after '{' + + + | +2 | f"{**x}" +3 | f"{+;}" +4 | t"{x:{/5}}" + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap index 8028e8ae062c70..2ec2f491d30890 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_invalid_starred_expr.py.snap @@ -214,6 +214,15 @@ Module( ``` ## Errors + | +1 | # Starred expression inside f-string has a minimum precedence of bitwise or. +2 | f"{*}" + | ^ Syntax Error: f-string: expecting a valid expression after '{' +3 | f"{*x and y}" +4 | f"{*yield x}" + | + + | 1 | # Starred expression inside f-string has a minimum precedence of bitwise or. 2 | f"{*}" diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap index 02691110c17170..300759e9fe8d7b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_lambda_without_parentheses.py.snap @@ -110,11 +110,6 @@ Module( ``` ## Errors - | -1 | f"{lambda x: x}" - | ^^ Syntax Error: invalid syntax - - | 1 | f"{lambda x: x}" | ^^^^^^^^^ Syntax Error: f-string: lambda expressions are not allowed without parentheses @@ -122,7 +117,7 @@ Module( | 1 | f"{lambda x: x}" - | ^^ Syntax Error: f-string: expecting '}' + | ^^ Syntax Error: invalid syntax | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_missing_conversion_flag.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_missing_conversion_flag.py.snap new file mode 100644 index 00000000000000..3a2a293136ccc0 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_missing_conversion_flag.py.snap @@ -0,0 +1,142 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/f_string_missing_conversion_flag.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..18, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..7, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 0..7, + value: FStringValue { + inner: Single( + FString { + range: 0..7, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 2..6, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("x"), + ctx: Load, + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 8..17, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 8..17, + value: FStringValue { + inner: Single( + FString { + range: 8..17, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 10..16, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 11..12, + id: Name("x"), + ctx: Load, + }, + ), + debug_text: Some( + DebugText { + leading: "", + expression: "x", + trailing: "=", + }, + ), + conversion: None, + format_spec: Some( + InterpolatedStringFormatSpec { + range: 15..15, + node_index: NodeIndex(None), + elements: [], + }, + ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f"{x!}" + | ^ Syntax Error: f-string: missing conversion character +2 | f"{x=!:}" + | + + + | +1 | f"{x!}" +2 | f"{x=!:}" + | ^ Syntax Error: f-string: missing conversion character diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_format_spec.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_format_spec.py.snap new file mode 100644 index 00000000000000..081ddc9e722701 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_format_spec.py.snap @@ -0,0 +1,78 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/f_string_unclosed_format_spec.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..9, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..8, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 0..8, + value: FStringValue { + inner: Single( + FString { + range: 0..8, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 2..7, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 3..4, + id: Name("x"), + ctx: Load, + }, + ), + debug_text: None, + conversion: Str, + format_spec: Some( + InterpolatedStringFormatSpec { + range: 7..7, + node_index: NodeIndex(None), + elements: [], + }, + ), + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f"{x!s:" + | ^ Syntax Error: f-string: expecting '}', or format specs diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap index 7a305c3bd35a63..5e0d9637590495 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace.py.snap @@ -273,6 +273,22 @@ Module( ``` ## Errors + | +1 | f"{" + | ^ Syntax Error: f-string: expecting '}' +2 | f"{foo!r" +3 | f"{foo=" + | + + + | +1 | f"{" + | ^ Syntax Error: f-string: expecting a valid expression after '{' +2 | f"{foo!r" +3 | f"{foo=" + | + + | 1 | f"{" | ^ Syntax Error: invalid syntax @@ -300,6 +316,15 @@ Module( | + | +2 | f"{foo!r" +3 | f"{foo=" +4 | f"{" + | ^ Syntax Error: f-string: expecting a valid expression after '{' +5 | f"""{""" + | + + | 2 | f"{foo!r" 3 | f"{foo=" @@ -309,6 +334,13 @@ Module( | + | +3 | f"{foo=" +4 | f"{" +5 | f"""{""" + | ^^^ Syntax Error: f-string: expecting a valid expression after '{' + + | 3 | f"{foo=" 4 | f"{" diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap index 1ed9b9adcae0e4..675bc53ad8946a 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_unclosed_lbrace_in_format_spec.py.snap @@ -153,7 +153,7 @@ Module( | 1 | f"hello {x:" - | ^ Syntax Error: f-string: expecting '}' + | ^ Syntax Error: f-string: expecting '}', or format specs 2 | f"hello {x:.3f" | @@ -161,4 +161,4 @@ Module( | 1 | f"hello {x:" 2 | f"hello {x:.3f" - | ^ Syntax Error: f-string: expecting '}' + | ^ Syntax Error: f-string: expecting '}', or format specs diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@interpolated_string_escape_error.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@interpolated_string_escape_error.py.snap new file mode 100644 index 00000000000000..cfe22ef9761fda --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@interpolated_string_escape_error.py.snap @@ -0,0 +1,139 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/interpolated_string_escape_error.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..26, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..11, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 0..11, + value: FStringValue { + inner: Single( + FString { + range: 0..11, + node_index: NodeIndex(None), + elements: [ + Literal( + InterpolatedStringLiteralElement { + range: 2..7, + node_index: NodeIndex(None), + value: "", + }, + ), + Interpolation( + InterpolatedElement { + range: 7..10, + node_index: NodeIndex(None), + expression: Name( + ExprName { + node_index: NodeIndex(None), + range: 8..9, + id: Name("x"), + ctx: Load, + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: FStringFlags { + quote_style: Single, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 12..25, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 12..25, + value: FStringValue { + inner: Concatenated( + [ + Literal( + StringLiteral { + range: 12..21, + node_index: NodeIndex(None), + value: "", + flags: StringLiteralFlags { + quote_style: Single, + prefix: Empty, + triple_quoted: false, + unclosed: false, + }, + }, + ), + Literal( + StringLiteral { + range: 22..25, + node_index: NodeIndex(None), + value: "c", + flags: StringLiteralFlags { + quote_style: Single, + prefix: Empty, + triple_quoted: false, + unclosed: false, + }, + }, + ), + ], + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f'a\N b{x}' + | ^ Syntax Error: (unicode error) 'unicodeescape' codec can't decode bytes in position 1-2: malformed \N character escape +2 | t'{x}\x1' 'c' + | + + + | +1 | f'a\N b{x}' +2 | t'{x}\x1' 'c' + | ^ Syntax Error: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-2: truncated \xXX escape + + + | +1 | f'a\N b{x}' +2 | t'{x}\x1' 'c' + | ^^^^^^^^^^^^^ Syntax Error: cannot mix t-string literals with string or bytes literals diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap index 1f84f46254248e..cb70c6df62dd08 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_fstring_literal_element.py.snap @@ -93,7 +93,7 @@ Module( | 1 | f'hello \N{INVALID} world' - | ^^^^^^^ Syntax Error: got unexpected unicode + | ^ Syntax Error: (unicode error) 'unicodeescape' codec can't decode bytes in position 6-16: unknown Unicode character name 2 | f"""hello \N{INVALID} world""" | @@ -101,4 +101,4 @@ Module( | 1 | f'hello \N{INVALID} world' 2 | f"""hello \N{INVALID} world""" - | ^^^^^^^ Syntax Error: got unexpected unicode + | ^^^ Syntax Error: (unicode error) 'unicodeescape' codec can't decode bytes in position 6-16: unknown Unicode character name diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap index dc18f67d032396..5944db737e534b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@invalid_string_literal.py.snap @@ -73,7 +73,7 @@ Module( | 1 | 'hello \N{INVALID} world' - | ^^^^^^^ Syntax Error: got unexpected unicode + | ^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: (unicode error) 'unicodeescape' codec can't decode bytes in position 6-16: unknown Unicode character name 2 | """hello \N{INVALID} world""" | @@ -81,4 +81,4 @@ Module( | 1 | 'hello \N{INVALID} world' 2 | """hello \N{INVALID} world""" - | ^^^^^^^ Syntax Error: got unexpected unicode + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax Error: (unicode error) 'unicodeescape' codec can't decode bytes in position 6-16: unknown Unicode character name diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_in_replacement_field.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_in_replacement_field.py.snap new file mode 100644 index 00000000000000..598c1587534ed8 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@lambda_in_replacement_field.py.snap @@ -0,0 +1,342 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/lambda_in_replacement_field.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..48, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..15, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 0..15, + value: FStringValue { + inner: Single( + FString { + range: 0..15, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 2..12, + node_index: NodeIndex(None), + expression: Lambda( + ExprLambda { + node_index: NodeIndex(None), + range: 3..12, + parameters: Some( + Parameters { + range: 10..11, + node_index: NodeIndex(None), + posonlyargs: [], + args: [ + ParameterWithDefault { + range: 10..11, + node_index: NodeIndex(None), + parameter: Parameter { + range: 10..11, + node_index: NodeIndex(None), + name: Identifier { + id: Name("x"), + range: 10..11, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ], + vararg: None, + kwonlyargs: [], + kwarg: None, + runtime_defaults: None, + }, + ), + body: Name( + ExprName { + node_index: NodeIndex(None), + range: 12..12, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + Literal( + InterpolatedStringLiteralElement { + range: 12..13, + node_index: NodeIndex(None), + value: "x", + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 16..32, + value: FString( + ExprFString { + node_index: NodeIndex(None), + range: 16..32, + value: FStringValue { + inner: Single( + FString { + range: 16..32, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 18..29, + node_index: NodeIndex(None), + expression: Tuple( + ExprTuple { + node_index: NodeIndex(None), + range: 19..29, + elts: [ + NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 19..20, + value: Int( + 1, + ), + }, + ), + Lambda( + ExprLambda { + node_index: NodeIndex(None), + range: 22..29, + parameters: None, + body: Name( + ExprName { + node_index: NodeIndex(None), + range: 29..29, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + ], + ctx: Load, + parenthesized: false, + runtime_elts: None, + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + Literal( + InterpolatedStringLiteralElement { + range: 29..30, + node_index: NodeIndex(None), + value: "x", + }, + ), + ], + flags: FStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_joined_str: None, + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 33..47, + value: TString( + ExprTString { + node_index: NodeIndex(None), + range: 33..47, + value: TStringValue { + inner: Single( + TString { + range: 33..47, + node_index: NodeIndex(None), + elements: [ + Interpolation( + InterpolatedElement { + range: 35..46, + node_index: NodeIndex(None), + expression: Lambda( + ExprLambda { + node_index: NodeIndex(None), + range: 36..45, + parameters: Some( + Parameters { + range: 43..44, + node_index: NodeIndex(None), + posonlyargs: [], + args: [ + ParameterWithDefault { + range: 43..44, + node_index: NodeIndex(None), + parameter: Parameter { + range: 43..44, + node_index: NodeIndex(None), + name: Identifier { + id: Name("x"), + range: 43..44, + node_index: NodeIndex(None), + }, + annotation: None, + runtime_type_comment: None, + runtime_type_comment_bytes: None, + }, + default: None, + }, + ], + vararg: None, + kwonlyargs: [], + kwarg: None, + runtime_defaults: None, + }, + ), + body: Name( + ExprName { + node_index: NodeIndex(None), + range: 45..45, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + debug_text: None, + conversion: None, + format_spec: None, + runtime_str: None, + runtime_interpolation_format_spec: None, + runtime_formatted_value_format_spec: None, + }, + ), + ], + flags: TStringFlags { + quote_style: Double, + prefix: Regular, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + runtime_template_str: None, + runtime_values: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | f"{lambda x:x}" + | ^^^^^^^^^ Syntax Error: f-string: lambda expressions are not allowed without parentheses +2 | f"{1, lambda:x}" +3 | t"{lambda x:}" + | + + + | +1 | f"{lambda x:x}" + | ^ Syntax Error: invalid syntax +2 | f"{1, lambda:x}" +3 | t"{lambda x:}" + | + + + | +1 | f"{lambda x:x}" + | ^ Syntax Error: expected an element of or the end of the f-string +2 | f"{1, lambda:x}" +3 | t"{lambda x:}" + | + + + | +1 | f"{lambda x:x}" +2 | f"{1, lambda:x}" + | ^^^^^^^ Syntax Error: f-string: lambda expressions are not allowed without parentheses +3 | t"{lambda x:}" + | + + + | +1 | f"{lambda x:x}" +2 | f"{1, lambda:x}" + | ^ Syntax Error: invalid syntax +3 | t"{lambda x:}" + | + + + | +1 | f"{lambda x:x}" +2 | f"{1, lambda:x}" + | ^ Syntax Error: f-string: single '}' is not allowed +3 | t"{lambda x:}" + | + + + | +1 | f"{lambda x:x}" +2 | f"{1, lambda:x}" +3 | t"{lambda x:}" + | ^^^^^^^^^ Syntax Error: t-string: lambda expressions are not allowed without parentheses + + + | +1 | f"{lambda x:x}" +2 | f"{1, lambda:x}" +3 | t"{lambda x:}" + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@legacy_print_statement.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@legacy_print_statement.py.snap new file mode 100644 index 00000000000000..11534998371b27 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@legacy_print_statement.py.snap @@ -0,0 +1,192 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/legacy_print_statement.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..43, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..5, + id: Name("print"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 6..13, + value: StringLiteral( + ExprStringLiteral { + node_index: NodeIndex(None), + range: 6..13, + value: StringLiteralValue { + inner: Single( + StringLiteral { + range: 6..13, + node_index: NodeIndex(None), + value: "hello", + flags: StringLiteralFlags { + quote_style: Single, + prefix: Empty, + triple_quoted: false, + unclosed: false, + }, + }, + ), + }, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 14..26, + value: List( + ExprList { + node_index: NodeIndex(None), + range: 14..26, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 15..20, + id: Name("print"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 21..22, + id: Name("x"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 24..25, + id: Name("y"), + ctx: Load, + }, + ), + ], + ctx: Load, + runtime_elts: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 27..31, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 27..31, + id: Name("exec"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 32..42, + value: Compare( + ExprCompare { + node_index: NodeIndex(None), + range: 32..42, + ops: [ + In, + ], + operands: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 32..36, + id: Name("code"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 40..42, + id: Name("ns"), + ctx: Load, + }, + ), + ], + runtime_comparators: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | print 'hello' + | ^^^^^^^^^^^^^ Syntax Error: Missing parentheses in call to 'print'. Did you mean print(...)? +2 | [print x, y] +3 | exec code in ns + | + + + | +1 | print 'hello' + | ^^^^^^^ Syntax Error: invalid syntax +2 | [print x, y] +3 | exec code in ns + | + + + | +1 | print 'hello' +2 | [print x, y] + | ^^^^^^^^^^ Syntax Error: Missing parentheses in call to 'print'. Did you mean print(...)? +3 | exec code in ns + | + + + | +1 | print 'hello' +2 | [print x, y] + | ^ Syntax Error: invalid syntax +3 | exec code in ns + | + + + | +1 | print 'hello' +2 | [print x, y] +3 | exec code in ns + | ^^^^^^^^^^^^^^^ Syntax Error: Missing parentheses in call to 'exec'. Did you mean exec(...)? + + + | +1 | print 'hello' +2 | [print x, y] +3 | exec code in ns + | ^^^^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@legacy_print_statement_invalid_operand.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@legacy_print_statement_invalid_operand.py.snap new file mode 100644 index 00000000000000..bbfc46ece129f7 --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@legacy_print_statement_invalid_operand.py.snap @@ -0,0 +1,159 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/legacy_print_statement_invalid_operand.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..29, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 0..5, + id: Name("print"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 6..16, + value: Dict( + ExprDict { + node_index: NodeIndex(None), + range: 6..16, + items: [ + DictItem { + key: Some( + NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 7..8, + value: Int( + 1, + ), + }, + ), + ), + value: Attribute( + ExprAttribute { + node_index: NodeIndex(None), + range: 10..14, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 10..13, + id: Name("foo"), + ctx: Load, + }, + ), + attr: Identifier { + id: Name(""), + range: 14..14, + node_index: NodeIndex(None), + }, + ctx: Load, + }, + ), + }, + ], + runtime_values: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 17..28, + value: List( + ExprList { + node_index: NodeIndex(None), + range: 17..28, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 18..23, + id: Name("print"), + ctx: Load, + }, + ), + BinOp( + ExprBinOp { + node_index: NodeIndex(None), + range: 24..27, + left: NumberLiteral( + ExprNumberLiteral { + node_index: NodeIndex(None), + range: 24..25, + value: Int( + 1, + ), + }, + ), + op: Add, + right: Name( + ExprName { + node_index: NodeIndex(None), + range: 27..27, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + ], + ctx: Load, + runtime_elts: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | print {1:(foo.)} + | ^ Syntax Error: invalid syntax +2 | [print 1 +] + | + + + | +1 | print {1:(foo.)} + | ^ Syntax Error: invalid syntax +2 | [print 1 +] + | + + + | +1 | print {1:(foo.)} +2 | [print 1 +] + | ^^^^^^^ Syntax Error: Missing parentheses in call to 'print'. Did you mean print(...)? + + + | +1 | print {1:(foo.)} +2 | [print 1 +] + | ^ Syntax Error: invalid syntax + + + | +1 | print {1:(foo.)} +2 | [print 1 +] + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_between_expressions.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_between_expressions.py.snap index 00d5e77c45de10..09f559e2cf1d38 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_between_expressions.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_between_expressions.py.snap @@ -8,7 +8,7 @@ input_file: crates/ruff_python_parser/resources/inline/err/missing_comma_between Module( ModModule { node_index: NodeIndex(None), - range: 0..38, + range: 0..108, body: [ Expr( StmtExpr { @@ -237,6 +237,178 @@ Module( ), }, ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 38..39, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 38..39, + id: Name("A"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 40..49, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 40..49, + id: Name("tokenizer"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 50..61, + value: Compare( + ExprCompare { + node_index: NodeIndex(None), + range: 50..61, + ops: [ + In, + ], + operands: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 50..55, + id: Name("error"), + ctx: Load, + }, + ), + Name( + ExprName { + node_index: NodeIndex(None), + range: 59..61, + id: Name("or"), + ctx: Load, + }, + ), + ], + runtime_comparators: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 62..67, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 62..67, + id: Name("right"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 68..73, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 68..73, + id: Name("after"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 74..77, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 74..77, + id: Name("the"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 78..83, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 78..83, + id: Name("first"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 84..94, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 84..94, + id: Name("expression"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 95..100, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 95..100, + id: Name("comes"), + ctx: Load, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 101..107, + value: Attribute( + ExprAttribute { + node_index: NodeIndex(None), + range: 101..107, + value: Name( + ExprName { + node_index: NodeIndex(None), + range: 101..106, + id: Name("first"), + ctx: Load, + }, + ), + attr: Identifier { + id: Name(""), + range: 107..107, + node_index: NodeIndex(None), + }, + ctx: Load, + }, + ), + }, + ), ], runtime_body: None, }, @@ -284,6 +456,7 @@ Module( 3 | x[1 + 2 3] | ^^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? 4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. | @@ -293,6 +466,7 @@ Module( 3 | x[1 + 2 3] | ^ Syntax Error: invalid syntax 4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. | @@ -301,6 +475,8 @@ Module( 3 | x[1 + 2 3] 4 | f"{a b}" | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +5 | A tokenizer error in or right after the first expression comes first. + | | @@ -308,6 +484,8 @@ Module( 3 | x[1 + 2 3] 4 | f"{a b}" | ^ Syntax Error: f-string: expecting '}' +5 | A tokenizer error in or right after the first expression comes first. + | | @@ -315,6 +493,8 @@ Module( 3 | x[1 + 2 3] 4 | f"{a b}" | ^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? +5 | A tokenizer error in or right after the first expression comes first. + | | @@ -322,6 +502,8 @@ Module( 3 | x[1 + 2 3] 4 | f"{a b}" | ^ Syntax Error: invalid syntax +5 | A tokenizer error in or right after the first expression comes first. + | | @@ -329,6 +511,8 @@ Module( 3 | x[1 + 2 3] 4 | f"{a b}" | ^ Syntax Error: f-string: single '}' is not allowed +5 | A tokenizer error in or right after the first expression comes first. + | | @@ -336,6 +520,8 @@ Module( 3 | x[1 + 2 3] 4 | f"{a b}" | ^ Syntax Error: invalid syntax +5 | A tokenizer error in or right after the first expression comes first. + | | @@ -343,3 +529,96 @@ Module( 3 | x[1 + 2 3] 4 | f"{a b}" | ^ Syntax Error: invalid syntax +5 | A tokenizer error in or right after the first expression comes first. + | + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^^^^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^^^^^^^^^^^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^^^^^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^^^^^ Syntax Error: invalid syntax + + + | +3 | x[1 + 2 3] +4 | f"{a b}" +5 | A tokenizer error in or right after the first expression comes first. + | ^ Syntax Error: invalid syntax diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap index ae067fe019c94b..6e70e54055489e 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@nested_quote_in_format_spec_py312.py.snap @@ -94,4 +94,4 @@ Module( | 1 | # parse_options: {"target-version": "3.12"} 2 | f"{1:""}" # this is a ParseError on all versions - | ^ Syntax Error: f-string: expecting '}' + | ^ Syntax Error: f-string: expecting '}', or format specs diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap index 8ee64532dd68d6..30baa692b7bc05 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lex_logical_token.py.snap @@ -977,7 +977,7 @@ Module( 49 | # F-strings uses normal list parsing, so test those as well 50 | if call(f"hello {x 51 | def bar(): - | ^^^ Syntax Error: f-string: expecting '}' + | ^^^ Syntax Error: f-string: expecting '=', or '!', or ':', or '}' 52 | pass | 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 514341167e9738..020bb581142b8d 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 @@ -418,7 +418,7 @@ Module( | 5 | f'middle {'string':\ 6 | 'format spec'} - | ^ Syntax Error: f-string: expecting '}' + | ^ Syntax Error: f-string: expecting '}', or format specs 7 | 8 | f'middle {'string':\\ | @@ -457,7 +457,7 @@ Module( 6 | 'format spec'} 7 | 8 | f'middle {'string':\\ - | ^^ Syntax Error: f-string: newlines are not allowed in format specifiers when using single quotes + | ^^ Syntax Error: f-string: newlines are not allowed in format specifiers for single quoted f-strings 9 | 'format spec'} | @@ -466,7 +466,7 @@ Module( 6 | 'format spec'} 7 | 8 | f'middle {'string':\\ - | ^ Syntax Error: f-string: expecting '}' + | ^ Syntax Error: f-string: expecting '}', or format specs 9 | 'format spec'} 10 | 11 | f'middle {'string':\\\ @@ -504,7 +504,7 @@ Module( | 11 | f'middle {'string':\\\ 12 | 'format spec'} - | ^ Syntax Error: f-string: expecting '}' + | ^ Syntax Error: f-string: expecting '}', or format specs | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap index 83eaf07feed0ac..a624ec4e06209b 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_2.py.snap @@ -84,4 +84,4 @@ Module( | 5 | f'''{foo:.3f 6 | ''' - | ^^^ Syntax Error: f-string: expecting '}' + | ^^^ Syntax Error: f-string: expecting '}', or format specs diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap index 984a676f989937..8385fcedbdacdc 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__triple_quoted_fstring_3.py.snap @@ -127,7 +127,7 @@ Module( | 5 | if call(f'''{x:.3f 6 | ''' - | ^^^ Syntax Error: f-string: expecting '}' + | ^^^ Syntax Error: f-string: expecting '}', or format specs 7 | pass | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap index 3701134b56052a..dbe4c57a7aab04 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@re_lexing__ty_1828.py.snap @@ -190,7 +190,7 @@ Module( | 1 | # Regression test for https://github.com/astral-sh/ty/issues/1828 2 | (c: int = 1,f"""{d=[ - | ^ Syntax Error: f-string: expecting '}' + | ^ Syntax Error: f-string: expecting '!', or ':', or '}' 3 | def a( 4 | class A: | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap index e85b2a2b431738..74b16c6d21adf2 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_empty_expression.py.snap @@ -120,7 +120,7 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{}" - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: t-string: valid expression required before '}' 3 | t"{ }" | @@ -129,4 +129,4 @@ Module( 1 | # parse_options: {"target-version": "3.14"} 2 | t"{}" 3 | t"{ }" - | ^ Syntax Error: invalid syntax + | ^ Syntax Error: t-string: valid expression required before '}' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_name_tok.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_name_tok.py.snap index 4f21af3fdf1761..88a7d9254a7f30 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_name_tok.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_conversion_flag_name_tok.py.snap @@ -70,4 +70,4 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{x!z}" - | ^ Syntax Error: t-string: invalid conversion character + | ^ Syntax Error: t-string: invalid conversion character 'z': expected 's', 'r', or 'a' diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap index 41986a4f100d6e..b2eacfb6f97166 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_invalid_starred_expr.py.snap @@ -214,6 +214,16 @@ Module( ``` ## Errors + | +1 | # parse_options: {"target-version": "3.14"} +2 | # Starred expression inside t-string has a minimum precedence of bitwise or. +3 | t"{*}" + | ^ Syntax Error: t-string: expecting a valid expression after '{' +4 | t"{*x and y}" +5 | t"{*yield x}" + | + + | 1 | # parse_options: {"target-version": "3.14"} 2 | # Starred expression inside t-string has a minimum precedence of bitwise or. diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap index 39f9843333b4bb..640ca2f9c9f62f 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_lambda_without_parentheses.py.snap @@ -110,12 +110,6 @@ Module( ``` ## Errors - | -1 | # parse_options: {"target-version": "3.14"} -2 | t"{lambda x: x}" - | ^^ Syntax Error: invalid syntax - - | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{lambda x: x}" @@ -125,7 +119,7 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{lambda x: x}" - | ^^ Syntax Error: t-string: expecting '}' + | ^^ Syntax Error: invalid syntax | diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap index 93b4726089e99f..eee59c4cf1796c 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace.py.snap @@ -273,6 +273,24 @@ Module( ``` ## Errors + | +1 | # parse_options: {"target-version": "3.14"} +2 | t"{" + | ^ Syntax Error: t-string: expecting '}' +3 | t"{foo!r" +4 | t"{foo=" + | + + + | +1 | # parse_options: {"target-version": "3.14"} +2 | t"{" + | ^ Syntax Error: t-string: expecting a valid expression after '{' +3 | t"{foo!r" +4 | t"{foo=" + | + + | 1 | # parse_options: {"target-version": "3.14"} 2 | t"{" @@ -302,6 +320,15 @@ Module( | + | +3 | t"{foo!r" +4 | t"{foo=" +5 | t"{" + | ^ Syntax Error: t-string: expecting a valid expression after '{' +6 | t"""{""" + | + + | 3 | t"{foo!r" 4 | t"{foo=" @@ -311,6 +338,13 @@ Module( | + | +4 | t"{foo=" +5 | t"{" +6 | t"""{""" + | ^^^ Syntax Error: t-string: expecting a valid expression after '{' + + | 4 | t"{foo=" 5 | t"{" diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap index 108c8a1b2626d8..168f5d28ff4f73 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@t_string_unclosed_lbrace_in_format_spec.py.snap @@ -154,7 +154,7 @@ Module( | 1 | # parse_options: {"target-version": "3.14"} 2 | t"hello {x:" - | ^ Syntax Error: t-string: expecting '}' + | ^ Syntax Error: t-string: expecting '}', or format specs 3 | t"hello {x:.3f" | @@ -163,4 +163,4 @@ Module( 1 | # parse_options: {"target-version": "3.14"} 2 | t"hello {x:" 3 | t"hello {x:.3f" - | ^ Syntax Error: t-string: expecting '}' + | ^ Syntax Error: t-string: expecting '}', or format specs diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap index 8c2919982a7c85..7eeed6378b2d1d 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@unterminated_fstring_newline_recovery.py.snap @@ -419,7 +419,7 @@ Module( 3 | f"hello {x 4 | 2 + 2 5 | f"hello {x: - | ^ Syntax Error: f-string: newlines are not allowed in format specifiers when using single quotes + | ^ Syntax Error: f-string: newlines are not allowed in format specifiers for single quoted f-strings 6 | 3 + 3 7 | f"hello {x} | From 6b46d0dfc80389323f325e2df9f3ac4c69bb8428 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 5 Oct 2026 23:30:44 +0900 Subject: [PATCH 17/20] Refine replacement field, comma and string decode error reporting Add `ParseErrorType::ExpectedIdentifier` for a missing identifier. Treat only missing expressions and identifiers as making an expression incomplete, require a complete prefix of the second expression for the missing comma error, keep string decode errors read before an unknown token, and report them ahead of an unclosed bracket. Assisted-by: Claude Code:claude-opus-5-5 --- ...missing_comma_before_invalid_expression.py | 2 + crates/ruff_python_parser/src/error.rs | 6 +- .../src/parser/expression.rs | 37 +++-- crates/ruff_python_parser/src/parser/mod.rs | 14 +- ...xpected_separator_after_expression.py.snap | 9 ++ ...ng_comma_before_invalid_expression.py.snap | 135 ++++++++++++++++++ 6 files changed, 188 insertions(+), 15 deletions(-) create mode 100644 crates/ruff_python_parser/resources/inline/err/missing_comma_before_invalid_expression.py create mode 100644 crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_before_invalid_expression.py.snap diff --git a/crates/ruff_python_parser/resources/inline/err/missing_comma_before_invalid_expression.py b/crates/ruff_python_parser/resources/inline/err/missing_comma_before_invalid_expression.py new file mode 100644 index 00000000000000..3ffbda303ab828 --- /dev/null +++ b/crates/ruff_python_parser/resources/inline/err/missing_comma_before_invalid_expression.py @@ -0,0 +1,2 @@ +[a ~] +[a b +] diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index 3c72adea27e776..e5aa1250d9c82a 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -288,6 +288,8 @@ pub enum ParseErrorType { ExpectedImaginaryNumber, /// Expected an expression at the current parser location. ExpectedExpression, + /// Expected an identifier at the current parser location. + ExpectedIdentifier, /// The parser expected a specific token that was not found. ExpectedToken { expected: TokenKind, @@ -579,7 +581,9 @@ impl std::fmt::Display for ParseErrorType { ParseErrorType::ExpectedImaginaryNumber => { f.write_str("expected an imaginary number in complex literal pattern") } - ParseErrorType::ExpectedExpression => f.write_str("invalid syntax"), + ParseErrorType::ExpectedExpression | ParseErrorType::ExpectedIdentifier => { + f.write_str("invalid syntax") + } ParseErrorType::UnexpectedIndentation => f.write_str("unexpected indent"), ParseErrorType::InvalidAssignmentTarget { kind, diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 14d7b65a3bd073..9f711ebe9e1697 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -439,10 +439,18 @@ impl<'src> Parser<'src> { return; } + // test_err missing_comma_before_invalid_expression + // [a ~] + // [a b +] let checkpoint = self.checkpoint(); + let errors_before = self.errors.len(); let second = self.parse_conditional_expression_or_higher(); - let range = TextRange::new(first.start(), second.end()); + let second_end = self.complete_prefix_end(&second.expr, errors_before); self.rewind(checkpoint); + let Some(second_end) = second_end else { + return; + }; + let range = TextRange::new(first.start(), second_end); self.add_error( ParseErrorType::OtherError("invalid syntax. Perhaps you forgot a comma?".to_string()), range, @@ -798,7 +806,7 @@ impl<'src> Parser<'src> { if self.current_token_kind().is_keyword() { // Non-soft keyword - self.add_error(ParseErrorType::OtherError("invalid syntax".into()), range); + self.add_error(ParseErrorType::ExpectedIdentifier, range); let text = self.src_text(range); let id = self.intern_name(text); @@ -814,10 +822,7 @@ impl<'src> Parser<'src> { } fn parse_missing_identifier(&mut self) -> ast::Identifier { - self.add_error( - ParseErrorType::OtherError("invalid syntax".into()), - self.current_token_range(), - ); + self.add_error(ParseErrorType::ExpectedIdentifier, self.current_token_range()); ast::Identifier { id: Name::empty(), @@ -2119,7 +2124,12 @@ impl<'src> Parser<'src> { return; } let (error, range) = match self.errors.get(errors_before) { - Some(first) if matches!(first.error, ParseErrorType::ExpectedExpression) => { + Some(first) + if matches!( + first.error, + ParseErrorType::ExpectedExpression | ParseErrorType::ExpectedIdentifier + ) => + { match self.complete_prefix_end(expr, errors_before) { None => ( InterpolatedStringErrorType::ExpectedExpressionAfterLbrace, @@ -2148,13 +2158,16 @@ impl<'src> Parser<'src> { } /// Returns the end of the longest prefix of `expr` that is a complete expression, where an - /// expression is incomplete if one of the errors after the first `errors_before` errors is - /// inside it, or `None` if no prefix is complete. + /// expression is incomplete if a missing expression or identifier after the first + /// `errors_before` errors is inside it, or `None` if no prefix is complete. fn complete_prefix_end(&self, expr: &Expr, errors_before: usize) -> Option { let is_complete = |expr: &Expr| { - !self.errors[errors_before..] - .iter() - .any(|error| expr.range().contains_inclusive(error.location.start())) + !self.errors[errors_before..].iter().any(|error| { + matches!( + error.error, + ParseErrorType::ExpectedExpression | ParseErrorType::ExpectedIdentifier + ) && expr.range().contains_inclusive(error.location.start()) + }) }; if is_complete(expr) { return Some(expr.end()); diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index 6fdb1e7c6f717f..581243f329b6d4 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -885,8 +885,9 @@ impl<'src> Parser<'src> { } } - // The lexer already reported an error for the current token, which comes first. - if self.at(TokenKind::Unknown) { + // The lexer already reported an error for the current token, which comes first. A + // string literal that fails to decode was read before it. + if self.at(TokenKind::Unknown) && !matches!(error, ParseErrorType::Lexical(_)) { return; } @@ -2043,8 +2044,17 @@ fn prioritize_tokenizer_error( } _ => first_start, }; + // An escape sequence error is found when its string is parsed, before the end of the + // source shows an unclosed bracket. + let escape_error = matches!( + first.error, + ParseErrorType::Lexical( + LexicalErrorType::UnicodeEscapeError { .. } | LexicalErrorType::BytesEscapeError { .. } + ) + ); let wins = detected <= first_start || (!in_interpolated_string + && !escape_error && match tokenizer_error.error() { LexicalErrorType::UnclosedBracket { .. } => { let bracket_start = tokenizer_error.location().start(); diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_expression.py.snap index 29185a3fb91ab7..0d494b2d0fb2e9 100644 --- a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_expression.py.snap +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@f_string_expected_separator_after_expression.py.snap @@ -557,6 +557,15 @@ Module( | + | +2 | f"{1 +}" +3 | f"{a, b and}" +4 | f"{x.}" + | ^ Syntax Error: f-string: expecting '=', or '!', or ':', or '}' +5 | A tokenizer error up to where the expression fails comes first. + | + + | 2 | f"{1 +}" 3 | f"{a, b and}" diff --git a/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_before_invalid_expression.py.snap b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_before_invalid_expression.py.snap new file mode 100644 index 00000000000000..585f5137ad676a --- /dev/null +++ b/crates/ruff_python_parser/tests/snapshots/invalid_syntax@missing_comma_before_invalid_expression.py.snap @@ -0,0 +1,135 @@ +--- +source: crates/ruff_python_parser/tests/fixtures.rs +input_file: crates/ruff_python_parser/resources/inline/err/missing_comma_before_invalid_expression.py +--- +## AST + +``` +Module( + ModModule { + node_index: NodeIndex(None), + range: 0..14, + body: [ + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 0..5, + value: List( + ExprList { + node_index: NodeIndex(None), + range: 0..5, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 1..2, + id: Name("a"), + ctx: Load, + }, + ), + UnaryOp( + ExprUnaryOp { + node_index: NodeIndex(None), + range: 3..4, + op: Invert, + operand: Name( + ExprName { + node_index: NodeIndex(None), + range: 4..4, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + ], + ctx: Load, + runtime_elts: None, + }, + ), + }, + ), + Expr( + StmtExpr { + node_index: NodeIndex(None), + range: 6..13, + value: List( + ExprList { + node_index: NodeIndex(None), + range: 6..13, + elts: [ + Name( + ExprName { + node_index: NodeIndex(None), + range: 7..8, + id: Name("a"), + ctx: Load, + }, + ), + BinOp( + ExprBinOp { + node_index: NodeIndex(None), + range: 9..12, + left: Name( + ExprName { + node_index: NodeIndex(None), + range: 9..10, + id: Name("b"), + ctx: Load, + }, + ), + op: Add, + right: Name( + ExprName { + node_index: NodeIndex(None), + range: 12..12, + id: Name(""), + ctx: Invalid, + }, + ), + }, + ), + ], + ctx: Load, + runtime_elts: None, + }, + ), + }, + ), + ], + runtime_body: None, + }, +) +``` +## Errors + + | +1 | [a ~] + | ^ Syntax Error: invalid syntax +2 | [a b +] + | + + + | +1 | [a ~] + | ^ Syntax Error: invalid syntax +2 | [a b +] + | + + + | +1 | [a ~] +2 | [a b +] + | ^^^ Syntax Error: invalid syntax. Perhaps you forgot a comma? + + + | +1 | [a ~] +2 | [a b +] + | ^ Syntax Error: invalid syntax + + + | +1 | [a ~] +2 | [a b +] + | ^ Syntax Error: invalid syntax From c3c644c3f23852b74e2448ed9697e6d7166bcbb5 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Tue, 6 Oct 2026 11:58:14 +0900 Subject: [PATCH 18/20] Format parser sources Assisted-by: Claude Code:claude-opus-5-5 --- crates/ruff_python_parser/src/lexer.rs | 10 ++++++---- crates/ruff_python_parser/src/parser/expression.rs | 12 ++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 8ac81b7de3cc46..3fb6743fbd63fc 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -1192,10 +1192,12 @@ impl<'src> Lexer<'src> { /// that has no opening bracket or does not match it. fn close_bracket(&mut self, closing: char) { let start = self.token_range().start(); - let at_interpolation_brace = self - .interpolated_strings - .current() - .filter(|interpolated_string| interpolated_string.is_at_interpolation_brace(self.nesting)); + let at_interpolation_brace = + self.interpolated_strings + .current() + .filter(|interpolated_string| { + interpolated_string.is_at_interpolation_brace(self.nesting) + }); let error = match self.brackets.pop() { Some(open) if open.kind == opening_bracket(closing) => None, Some(open) if open.kind == '{' && at_interpolation_brace.is_some() => { diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 9f711ebe9e1697..68b41bba048682 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -822,7 +822,10 @@ impl<'src> Parser<'src> { } fn parse_missing_identifier(&mut self) -> ast::Identifier { - self.add_error(ParseErrorType::ExpectedIdentifier, self.current_token_range()); + self.add_error( + ParseErrorType::ExpectedIdentifier, + self.current_token_range(), + ); ast::Identifier { id: Name::empty(), @@ -1976,9 +1979,10 @@ impl<'src> Parser<'src> { // test_err interpolated_string_escape_error // f'a\N b{x}' // t'{x}\x1' 'c' - if let Some(error) = - std::mem::replace(&mut self.interpolated_string_escape_error, outer_escape_error) - { + if let Some(error) = std::mem::replace( + &mut self.interpolated_string_escape_error, + outer_escape_error, + ) { self.add_error(ParseErrorType::Lexical(error), end_range); } From 14e5415fb2b41bb96e4d8fb7ce80441e3b45f453 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Tue, 6 Oct 2026 22:42:53 +0900 Subject: [PATCH 19/20] Skip work on the error-free parse path Return early from `prioritize_tokenizer_error` when there are no errors instead of re-lexing the source, and track seen string prefixes in a bitmask instead of allocating a `Vec` for every identifier. Assisted-by: Claude Code:claude-opus-5-5 --- crates/ruff_python_parser/src/lexer.rs | 12 +++++++----- crates/ruff_python_parser/src/parser/mod.rs | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 3fb6743fbd63fc..3dea914fcea9d8 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -780,7 +780,8 @@ impl<'src> Lexer<'src> { ('f', 't'), ]; - let mut seen = Vec::with_capacity(PREFIXES.len()); + let bit = |prefix: char| PREFIXES.iter().position(|&c| c == prefix).map(|i| 1u8 << i); + let mut seen = 0u8; let mut len = TextSize::new(0); let mut chars = std::iter::once(first).chain(self.cursor.rest().chars()); loop { @@ -788,16 +789,17 @@ impl<'src> Lexer<'src> { if is_quote(c) { break; } - let prefix = c.to_ascii_lowercase(); - if !PREFIXES.contains(&prefix) || seen.contains(&prefix) { + let prefix = bit(c.to_ascii_lowercase())?; + if seen & prefix != 0 { return None; } - seen.push(prefix); + seen |= prefix; len += c.text_len(); } + let has = |prefix: char| bit(prefix).is_some_and(|prefix| seen & prefix != 0); let (first, second) = INCOMPATIBLE .into_iter() - .find(|(first, second)| seen.contains(first) && seen.contains(second))?; + .find(|(first, second)| has(*first) && has(*second))?; Some(LexicalError::new( LexicalErrorType::IncompatibleStringPrefixes { first, second }, TextRange::at(self.token_range().start(), len), diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index 581243f329b6d4..4641cf5ca0ec08 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -1990,6 +1990,10 @@ fn prioritize_tokenizer_error( start_offset: TextSize, unclosed_bracket_recovery: Option, ) { + // The lexer reports every tokenizer error, so a source without errors has none to find. + if errors.is_empty() { + return; + } let is_tokenizer_error = |error: &ParseError| matches!(&error.error, ParseErrorType::Lexical(lexical) if lexical.is_tokenizer_error()); let first = errors .iter() From 8b59b8534415d79b28376a9808fc1b425d04b3ec Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Tue, 6 Oct 2026 23:03:58 +0900 Subject: [PATCH 20/20] Keep a starred var-positional annotation out of the default value error `def f(*args: *b = (1,))` is invalid syntax, not a var-positional parameter with a default value. Assisted-by: Claude Code:claude-opus-5-5 --- crates/ruff_python_parser/src/parser/statement.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index 08971b90d67467..b0b43c4f3b024b 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -3631,7 +3631,13 @@ impl<'src> Parser<'src> { AllowStarAnnotation::Yes, ); - if parser.at(TokenKind::Equal) { + // A starred annotation is not an annotation the rule accepts. + if parser.at(TokenKind::Equal) + && !param + .annotation + .as_deref() + .is_some_and(ast::Expr::is_starred_expr) + { // test_err params_var_positional_with_default // def foo(a, *args=(1, 2)): ... parser.add_error(