From f74527f4e9d7e25badb08665868a8fb6a5a8ee01 Mon Sep 17 00:00:00 2001 From: Jia Chen Date: Wed, 11 Jun 2025 23:20:14 -0700 Subject: [PATCH] `SourceOrderVisitor` should visit the `Identifier` part of the `PatternKeyword` node (#18635) --- crates/ruff_python_ast/src/visitor/source_order.rs | 2 +- .../tests/snapshots/source_order__match_class_pattern.snap | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ruff_python_ast/src/visitor/source_order.rs b/crates/ruff_python_ast/src/visitor/source_order.rs index af57ee48db..9e42766f0d 100644 --- a/crates/ruff_python_ast/src/visitor/source_order.rs +++ b/crates/ruff_python_ast/src/visitor/source_order.rs @@ -501,7 +501,7 @@ where { let node = AnyNodeRef::from(pattern_keyword); if visitor.enter_node(node).is_traverse() { - visitor.visit_pattern(&pattern_keyword.pattern); + pattern_keyword.visit_source_order(visitor); } visitor.leave_node(node); } diff --git a/crates/ruff_python_ast_integration_tests/tests/snapshots/source_order__match_class_pattern.snap b/crates/ruff_python_ast_integration_tests/tests/snapshots/source_order__match_class_pattern.snap index ddd8b0c3d1..6a2e1f07f5 100644 --- a/crates/ruff_python_ast_integration_tests/tests/snapshots/source_order__match_class_pattern.snap +++ b/crates/ruff_python_ast_integration_tests/tests/snapshots/source_order__match_class_pattern.snap @@ -1,7 +1,6 @@ --- source: crates/ruff_python_ast_integration_tests/tests/source_order.rs expression: trace -snapshot_kind: text --- - ModModule - StmtMatch @@ -21,12 +20,15 @@ snapshot_kind: text - ExprName - PatternArguments - PatternKeyword + - Identifier - PatternMatchValue - ExprNumberLiteral - PatternKeyword + - Identifier - PatternMatchValue - ExprNumberLiteral - PatternKeyword + - Identifier - PatternMatchValue - ExprNumberLiteral - StmtExpr