ruff/crates/ruff_python_formatter/resources/test/fixtures/ruff
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
..
carriage_return Normalize '\r' in string literals to '\n' 2023-06-30 10:13:23 +02:00
expression Use `BestFit` layout even for attributes with a short name (#6872) 2023-08-25 17:47:02 +02:00
fmt_on_off Indent statements in suppressed ranges (#6507) 2023-08-15 08:00:35 +02:00
fmt_skip Fix `fmt:skip` for function with return type (#6733) 2023-08-21 17:45:23 +02:00
parentheses Add general support for parenthesized comments on expressions (#6485) 2023-08-15 18:59:18 +00:00
statement Introduce AST nodes for `PatternMatchClass` arguments (#6881) 2023-08-26 14:45:44 +00:00
.editorconfig Indent statements in suppressed ranges (#6507) 2023-08-15 08:00:35 +02:00
docstring.options.json Add tab width option (#6848) 2023-08-26 12:29:58 +02:00
docstring.py Format docstrings (#6452) 2023-08-14 12:28:58 +00:00
skip_magic_trailing_comma.options.json Add tests for skip magic trailing comma 2023-06-26 14:15:55 +02:00
skip_magic_trailing_comma.py Improve `with` statement comment handling and expression breaking (#6621) 2023-08-18 03:30:38 +00:00
tab_width.options.json Add tab width option (#6848) 2023-08-26 12:29:58 +02:00
tab_width.py Add tab width option (#6848) 2023-08-26 12:29:58 +02:00
trivia.py Correctly handle newlines after/before comments (#4895) 2023-06-07 14:49:43 +02:00