Misc. stylistic changes from flipping through rules late at night (#5757)

## Summary

This is really bad PR hygiene, but a mix of: using `Locator`-based fixes
in a few places (in lieu of `Generator`-based fixes), using match syntax
to avoid `.len() == 1` checks, using common helpers in more places, etc.

## Test Plan

`cargo test`
This commit is contained in:
Charlie Marsh 2023-07-14 01:23:47 -04:00 committed by GitHub
parent 875e04e369
commit 5a4516b812
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 127 additions and 169 deletions

View file

@ -549,10 +549,7 @@ pub fn is_assignment_to_a_dunder(stmt: &Stmt) -> bool {
// annotation. This is what pycodestyle (as of 2.9.1) does.
match stmt {
Stmt::Assign(ast::StmtAssign { targets, .. }) => {
if targets.len() != 1 {
return false;
}
if let Expr::Name(ast::ExprName { id, .. }) = &targets[0] {
if let [Expr::Name(ast::ExprName { id, .. })] = targets.as_slice() {
is_dunder(id)
} else {
false