From f0fac6dbb805217218e546a632c7b661155df0ce Mon Sep 17 00:00:00 2001
From: Christoph Tyralla <c.tyralla@bjoernsen.de>
Date: Sun, 12 Jan 2025 22:27:50 +0100
Subject: [PATCH] refactor

---
 mypy/checker.py | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/mypy/checker.py b/mypy/checker.py
index 6565ba5c97171..62c84e783847a 100644
--- a/mypy/checker.py
+++ b/mypy/checker.py
@@ -595,11 +595,9 @@ def accept_loop(
 
             # Disable error types that we cannot safely identify in intermediate iteration steps:
             warn_unreachable = self.options.warn_unreachable
-            if warn_unreachable:
-                self.options.warn_unreachable = False
             warn_redundant = codes.REDUNDANT_EXPR in self.options.enabled_error_codes
-            if warn_redundant:
-                self.options.enabled_error_codes.remove(codes.REDUNDANT_EXPR)
+            self.options.warn_unreachable = False
+            self.options.enabled_error_codes.discard(codes.REDUNDANT_EXPR)
 
             while True:
                 with self.binder.frame_context(can_skip=True, break_frame=2, continue_frame=1):
@@ -610,10 +608,10 @@ def accept_loop(
                 partials_old = partials_new
 
             # If necessary, reset the modified options and make up for the postponed error checks:
+            self.options.warn_unreachable = warn_unreachable
+            if warn_redundant:
+                self.options.enabled_error_codes.add(codes.REDUNDANT_EXPR)
             if warn_unreachable or warn_redundant:
-                self.options.warn_unreachable = warn_unreachable
-                if warn_redundant:
-                    self.options.enabled_error_codes.add(codes.REDUNDANT_EXPR)
                 with self.binder.frame_context(can_skip=True, break_frame=2, continue_frame=1):
                     self.accept(body)