ruff/crates/ruff_python_parser/src
Charlie Marsh 15b73bdb8a
Introduce AST nodes for PatternMatchClass arguments (#6881)
## Summary

This PR introduces two new AST nodes to improve the representation of
`PatternMatchClass`. As a reminder, `PatternMatchClass` looks like this:

```python
case Point2D(0, 0, x=1, y=2):
  ...
```

Historically, this was represented as a vector of patterns (for the `0,
0` portion) and parallel vectors of keyword names (for `x` and `y`) and
values (for `1` and `2`). This introduces a bunch of challenges for the
formatter, but importantly, it's also really different from how we
represent similar nodes, like arguments (`func(0, 0, x=1, y=2)`) or
parameters (`def func(x, y)`).

So, firstly, we now use a single node (`PatternArguments`) for the
entire parenthesized region, making it much more consistent with our
other nodes. So, above, `PatternArguments` would be `(0, 0, x=1, y=2)`.

Secondly, we now have a `PatternKeyword` node for `x=1` and `y=2`. This
is much more similar to the how `Keyword` is represented within
`Arguments` for call expressions.

Closes https://github.com/astral-sh/ruff/issues/6866.

Closes https://github.com/astral-sh/ruff/issues/6880.
2023-08-26 14:45:44 +00:00
..
lexer Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
snapshots Introduce AST nodes for PatternMatchClass arguments (#6881) 2023-08-26 14:45:44 +00:00
context.rs Remove Parse trait (#6235) 2023-08-01 18:35:03 +02:00
function.rs Implement Ranged on more structs (#6639) 2023-08-17 11:22:39 -04:00
lexer.rs Update lexer tests to use snapshots (#6658) 2023-08-22 18:23:19 +00:00
lib.rs Rename Notebook related symbols (#6862) 2023-08-25 11:40:54 +05:30
parser.rs Expand NamedExpr range to include full range of parenthesized value (#6632) 2023-08-17 14:34:05 +00:00
python.lalrpop Introduce AST nodes for PatternMatchClass arguments (#6881) 2023-08-26 14:45:44 +00:00
python.rs Introduce AST nodes for PatternMatchClass arguments (#6881) 2023-08-26 14:45:44 +00:00
soft_keywords.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
string.rs Implement Ranged on more structs (#6639) 2023-08-17 11:22:39 -04:00
token.rs Rename Magic* to IpyEscape* (#6395) 2023-08-09 13:28:18 +00:00
typing.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00