ruff/crates/ruff_python_ast/tests
Charlie Marsh 1050142a58
Expand expressions to include parentheses in E712 (#6575)
## Summary

This PR exposes our `is_expression_parenthesized` logic such that we can
use it to expand expressions when autofixing to include their
parenthesized ranges.

This solution has a few drawbacks: (1) we need to compute parenthesized
ranges in more places, which also relies on backwards lexing; and (2) we
need to make use of this in any relevant fixes.

However, I still think it's worth pursuing. On (1), the implementation
is very contained, so IMO we can easily swap this out for a more
performant solution in the future if needed. On (2), this improves
correctness and fixes some bad syntax errors detected by fuzzing, which
means it has value even if it's not as robust as an _actual_
`ParenthesizedExpression` node in the AST itself.

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

## Test Plan

`cargo test` with new cases that previously failed the fuzzer.
2023-08-17 15:51:09 +00:00
..
snapshots Rename Arguments to Parameters in the AST (#6253) 2023-08-01 13:53:28 -04:00
identifier.rs Remove Parse trait (#6235) 2023-08-01 18:35:03 +02:00
parenthesize.rs Expand expressions to include parentheses in E712 (#6575) 2023-08-17 15:51:09 +00:00
preorder.rs Rename Arguments to Parameters in the AST (#6253) 2023-08-01 13:53:28 -04:00
stmt_if.rs Remove Parse trait (#6235) 2023-08-01 18:35:03 +02:00
visitor.rs Rename Arguments to Parameters in the AST (#6253) 2023-08-01 13:53:28 -04:00