]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
refactor: clean up unused variables in engine module
authorShamil <ashm.tech@proton.me>
Thu, 17 Apr 2025 19:48:19 +0000 (15:48 -0400)
committerMichael Bayer <mike_mp@zzzcomputing.com>
Mon, 21 Apr 2025 15:08:27 +0000 (15:08 +0000)
Removed unused variables to improve code clarity and maintainability. This change simplifies logic in `base.py`, `default.py`, and `result.py`. No functionality was altered.

Closes: #12535
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12535
Pull-request-sha: a9d849f3a4f3abe9aff49279c4cc81aa26aeaa9b

Change-Id: If78b18dbd33733c631f8b5aad7d55261fbc4817b

lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/engine/result.py

index 464d2d2ab328be307b8f7b93f6d141a1149a1716..5b5339036bb9353a77edc7589fca413465cf57b7 100644 (file)
@@ -2437,9 +2437,7 @@ class Connection(ConnectionEventsTarget, inspection.Inspectable["Inspector"]):
                     break
 
             if sqlalchemy_exception and is_disconnect != ctx.is_disconnect:
-                sqlalchemy_exception.connection_invalidated = is_disconnect = (
-                    ctx.is_disconnect
-                )
+                sqlalchemy_exception.connection_invalidated = ctx.is_disconnect
 
         if newraise:
             raise newraise.with_traceback(exc_info[2]) from e
index 7d5afa83ef5210290e552ee67622a47765930519..8b704d2a1b749856b961a57b8637a1e958893f14 100644 (file)
@@ -744,8 +744,6 @@ class DefaultDialect(Dialect):
                 raise
 
     def do_ping(self, dbapi_connection: DBAPIConnection) -> bool:
-        cursor = None
-
         cursor = dbapi_connection.cursor()
         try:
             cursor.execute(self._dialect_specific_select_one)
@@ -1849,7 +1847,7 @@ class DefaultExecutionContext(ExecutionContext):
 
         if self.is_crud or self.is_text:
             result = self._setup_dml_or_text_result()
-            yp = sr = False
+            yp = False
         else:
             yp = exec_opt.get("yield_per", None)
             sr = self._is_server_side or exec_opt.get("stream_results", False)
index 38db2e10309aafb1409eebc43b4a9265ca61a276..2aa0aec9cd3e00837e4a06462cf00a45bd72b2a2 100644 (file)
@@ -811,7 +811,6 @@ class ResultInternal(InPlaceGenerative, Generic[_R]):
                     "was required"
                 )
         else:
-            next_row = _NO_ROW
             # if we checked for second row then that would have
             # closed us :)
             self._soft_close(hard=True)