From a6a286e4c285e69ce430ad17ce2aaf88aa82bfb4 Mon Sep 17 00:00:00 2001
From: Steve C <diceroll123@gmail.com>
Date: Thu, 30 Nov 2023 18:32:44 -0500
Subject: [PATCH] tweaks

---
 .../rules/unnecessary_dict_index_lookup.rs    | 48 +++++++++----------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs b/crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs
index fdc690c8e9808..ff49560bd303c 100644
--- a/crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs
+++ b/crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs
@@ -1,4 +1,4 @@
-use ast::{Arguments, Stmt};
+use ast::Stmt;
 use ruff_python_ast::{self as ast, Expr, StmtFor};
 
 use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
@@ -66,13 +66,15 @@ fn check_target_for_assignment(expr: &Expr, dict_name: &str, index_name: &str) -
     // if we see the sequence subscript being modified, we'll stop emitting diagnostics
     match expr {
         Expr::Subscript(ast::ExprSubscript { value, slice, .. }) => {
-            if let Expr::Name(ast::ExprName { id, .. }) = value.as_ref() {
-                if id == dict_name {
-                    if let Expr::Name(ast::ExprName { id, .. }) = slice.as_ref() {
-                        if id == index_name {
-                            return true;
-                        }
-                    }
+            let Expr::Name(ast::ExprName { id, .. }) = value.as_ref() else {
+                return false;
+            };
+            if id == dict_name {
+                let Expr::Name(ast::ExprName { id, .. }) = slice.as_ref() else {
+                    return false;
+                };
+                if id == index_name {
+                    return true;
                 }
             }
             false
@@ -93,13 +95,15 @@ impl<'a> Visitor<'_> for SubscriptVisitor<'a> {
                 range,
                 ..
             }) => {
-                if let Expr::Name(ast::ExprName { id, .. }) = value.as_ref() {
-                    if id == self.dict_name {
-                        if let Expr::Name(ast::ExprName { id, .. }) = slice.as_ref() {
-                            if id == self.index_name {
-                                self.diagnostic_ranges.push(*range);
-                            }
-                        }
+                let Expr::Name(ast::ExprName { id, .. }) = value.as_ref() else {
+                    return;
+                };
+                if id == self.dict_name {
+                    let Expr::Name(ast::ExprName { id, .. }) = slice.as_ref() else {
+                        return;
+                    };
+                    if id == self.index_name {
+                        self.diagnostic_ranges.push(*range);
                     }
                 }
             }
@@ -207,15 +211,11 @@ pub(crate) fn unnecessary_dict_index_lookup_comprehension(checker: &mut Checker,
 }
 
 fn dict_items(call_expr: &Expr, tuple_expr: &Expr) -> Option<(String, String, String)> {
-    let Expr::Call(ast::ExprCall {
-        func,
-        arguments: Arguments { args, .. },
-        ..
-    }) = call_expr
-    else {
-        return None;
-    };
-    if !args.is_empty() {
+    let ast::ExprCall {
+        func, arguments, ..
+    } = call_expr.as_call_expr()?;
+
+    if !arguments.is_empty() {
         return None;
     }
     let Expr::Attribute(ast::ExprAttribute { value, attr, .. }) = func.as_ref() else {