mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-23 00:31:55 +00:00
Update Black tests (#20794)
Summary -- ```shell git clone git@github.com:psf/black.git ../other/black crates/ruff_python_formatter/resources/test/fixtures/import_black_tests.py ../other/black ``` Then ran our tests and accepted the snapshots I had to make a small fix to our tuple normalization logic for `del` statements in the second commit, otherwise the tests were panicking at a changed AST. I think the new implementation is closer to the intention described in the nearby comment anyway, though. The first commit adds the new Python, settings, and `.expect` files, the next three commits make some small fixes to help get the tests running, and then the fifth commit accepts all but one of the new snapshots. The last commit includes the new unsupported syntax error for one f-string example, tracked in #20774. Test Plan -- Newly imported tests. I went through all of the new snapshots and added review comments below. I think they're all expected, except a few cases I wasn't 100% sure about.
This commit is contained in:
parent
9090aead0f
commit
1ed9b215b9
123 changed files with 6607 additions and 343 deletions
|
@ -1,8 +1,5 @@
|
|||
use regex::Regex;
|
||||
use std::sync::LazyLock;
|
||||
use {
|
||||
itertools::Either::{Left, Right},
|
||||
regex::Regex,
|
||||
};
|
||||
|
||||
use ruff_python_ast::{
|
||||
self as ast, BytesLiteralFlags, Expr, FStringFlags, FStringPart, InterpolatedStringElement,
|
||||
|
@ -46,18 +43,9 @@ impl Transformer for Normalizer {
|
|||
fn visit_stmt(&self, stmt: &mut Stmt) {
|
||||
if let Stmt::Delete(delete) = stmt {
|
||||
// Treat `del a, b` and `del (a, b)` equivalently.
|
||||
delete.targets = delete
|
||||
.targets
|
||||
.clone()
|
||||
.into_iter()
|
||||
.flat_map(|target| {
|
||||
if let Expr::Tuple(tuple) = target {
|
||||
Left(tuple.elts.into_iter())
|
||||
} else {
|
||||
Right(std::iter::once(target))
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if let [Expr::Tuple(tuple)] = delete.targets.as_slice() {
|
||||
delete.targets = tuple.elts.clone();
|
||||
}
|
||||
}
|
||||
|
||||
transformer::walk_stmt(self, stmt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue