ruff/crates/ruff_python_ast
Charlie Marsh d574fcd1ac
Compare formatted and unformatted ASTs during formatter tests (#8624)
## Summary

This PR implements validation in the formatter tests to ensure that we
don't modify the AST during formatting. Black has similar logic.

In implementing this, I learned that Black actually _does_ modify the
AST, and their test infrastructure normalizes the AST to wipe away those
differences. Specifically, Black changes the indentation of docstrings,
which _does_ modify the AST; and it also inserts parentheses in `del`
statements, which changes the AST too.

Ruff also does both these things, so we _also_ implement the same
normalization using a new visitor that allows for modifying the AST.

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

## Test Plan

`cargo test`
2023-11-13 17:43:27 +00:00
..
src Compare formatted and unformatted ASTs during formatter tests (#8624) 2023-11-13 17:43:27 +00:00
tests Split Constant to individual literal nodes (#8064) 2023-10-30 12:13:23 +05:30
Cargo.toml Implement our own small-integer optimization (#7584) 2023-09-25 15:13:21 +00:00