ruff/crates
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
..
flake8_to_ruff Bump version to 0.0.286 (#6876) 2023-08-25 14:59:26 -04:00
ruff Avoid PEP 604 upgrades that lead to invalid syntax (#6888) 2023-08-25 19:47:15 -04:00
ruff_benchmark Use Codspeed for continous benchmarking (#6896) 2023-08-26 16:34:35 +02:00
ruff_cache Error on zero tab width (#6429) 2023-08-08 16:51:37 -04:00
ruff_cli Bump version to 0.0.286 (#6876) 2023-08-25 14:59:26 -04:00
ruff_dev Improve formatter contributor docs (#6776) 2023-08-24 10:45:08 +00:00
ruff_diagnostics Avoid attempting to fix PT018 in multi-statement lines (#6829) 2023-08-23 19:09:34 -04:00
ruff_formatter Add tab width option (#6848) 2023-08-26 12:29:58 +02:00
ruff_index Add unreachable code rule (#5384) 2023-07-04 14:27:23 +00:00
ruff_macros Remove parser dependency from ruff-python-ast (#6096) 2023-07-26 17:47:22 +02:00
ruff_python_ast Introduce AST nodes for `PatternMatchClass` arguments (#6881) 2023-08-26 14:45:44 +00:00
ruff_python_codegen Make `Parameters` an optional field on `ExprLambda` (#6669) 2023-08-18 15:34:54 +00:00
ruff_python_formatter Introduce AST nodes for `PatternMatchClass` arguments (#6881) 2023-08-26 14:45:44 +00:00
ruff_python_index Avoid attempting to fix PT018 in multi-statement lines (#6829) 2023-08-23 19:09:34 -04:00
ruff_python_literal Avoid parsing other parts of a format specification if replacements are present (#6858) 2023-08-25 17:42:57 +00:00
ruff_python_parser Introduce AST nodes for `PatternMatchClass` arguments (#6881) 2023-08-26 14:45:44 +00:00
ruff_python_resolver Replace `.map_or(false, $closure)` with `.is_some_and(closure)` (#6244) 2023-08-01 19:29:42 +02:00
ruff_python_semantic Update `mutable-argument-default` (`B006`) to use `extend-immutable-calls` when determining if annotations are immutable (#6781) 2023-08-23 15:44:35 +00:00
ruff_python_stdlib Replace `.map_or(false, $closure)` with `.is_some_and(closure)` (#6244) 2023-08-01 19:29:42 +02:00
ruff_python_trivia Format all attribute dot comments manually (#6825) 2023-08-25 03:50:56 +00:00
ruff_shrinking Implement `Ranged` on more structs (#6639) 2023-08-17 11:22:39 -04:00
ruff_source_file Skip BOM when determining Locator's line starts (#6159) 2023-07-29 11:47:13 +00:00
ruff_text_size Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_wasm Set a default on `PythonVersion` (#6446) 2023-08-09 15:19:27 +00:00