]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
refactor(testing-and-utils): Remove unused code and fix style issues
authorShamil <ashm.tech@proton.me>
Mon, 21 Apr 2025 16:35:43 +0000 (12:35 -0400)
committersqla-tester <sqla-tester@sqlalchemy.org>
Mon, 21 Apr 2025 16:35:43 +0000 (12:35 -0400)
This PR includes several small refactorings and style fixes aimed at improving code cleanliness, primarily within the test suite and tooling.

Key changes:

*   Removed assignments to unused variables in various test files (`test_dialect.py`, `test_reflection.py`, `test_select.py`).
*   Removed an unused variable in the pytest plugin (`pytestplugin.py`).
*   Removed an unused variable in the topological sort utility (`topological.py`).
*   Fixed a minor style issue (removed an extra blank line) in the `cython_imports.py` script.

Closes: #12539
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12539
Pull-request-sha: 837c1e6cb17f0ff31444d5161329c318b52e48e7

Change-Id: Ifa37fb956bc3cacd31967f08bdaa4254e16911c2

lib/sqlalchemy/testing/plugin/pytestplugin.py
lib/sqlalchemy/testing/suite/test_dialect.py
lib/sqlalchemy/testing/suite/test_reflection.py
lib/sqlalchemy/testing/suite/test_select.py
lib/sqlalchemy/util/topological.py
tools/cython_imports.py

index aa531776f805204ee8e6011890f6fd77ac196a21..79d14458ca89a52ad2bde0feeac95779eecb79e9 100644 (file)
@@ -270,7 +270,6 @@ def pytest_collection_modifyitems(session, config, items):
         for test_class in test_classes:
             # transfer legacy __backend__ and __sparse_backend__ symbols
             # to be markers
-            add_markers = set()
             if getattr(test_class.cls, "__backend__", False) or getattr(
                 test_class.cls, "__only_on__", False
             ):
index ae67cc10adcb091b4fa1db84b3c57edfd9845075..ebbb9e435a07de0a83bfc41a54cf5e55a470f90f 100644 (file)
@@ -537,7 +537,7 @@ class DifficultParametersTest(fixtures.TestBase):
             t.c[name].in_(["some name", "some other_name"])
         )
 
-        row = connection.execute(stmt).first()
+        connection.execute(stmt).first()
 
     @testing.fixture
     def multirow_fixture(self, metadata, connection):
@@ -621,7 +621,7 @@ class ReturningGuardsTest(fixtures.TablesTest):
                         f"current server capabilities does not support "
                         f".*RETURNING when executemany is used",
                     ):
-                        result = connection.execute(
+                        connection.execute(
                             stmt,
                             [
                                 {id_param_name: 1, "data": "d1"},
index faafe7dc578ac54a0cdd4f2320772291410fe678..5cf860c6a07a63210335c42c976c6361c2fd877f 100644 (file)
@@ -460,7 +460,7 @@ class QuotedNameArgumentTest(fixtures.TablesTest):
             is_true(isinstance(res, dict))
         else:
             with expect_raises(NotImplementedError):
-                res = insp.get_table_options(name)
+                insp.get_table_options(name)
 
     @quote_fixtures
     @testing.requires.view_column_reflection
@@ -2048,7 +2048,7 @@ class ComponentReflectionTest(ComparesTables, OneConnectionTablesTest):
             is_true(isinstance(res, dict))
         else:
             with expect_raises(NotImplementedError):
-                res = insp.get_table_options("users", schema=schema)
+                insp.get_table_options("users", schema=schema)
 
     @testing.combinations((True, testing.requires.schemas), False)
     def test_multi_get_table_options(self, use_schema):
@@ -2064,7 +2064,7 @@ class ComponentReflectionTest(ComparesTables, OneConnectionTablesTest):
             eq_(res, exp)
         else:
             with expect_raises(NotImplementedError):
-                res = insp.get_multi_table_options()
+                insp.get_multi_table_options()
 
     @testing.fixture
     def get_multi_exp(self, connection):
index 79a371d88b29bb4a697e6446ad6758bda032db34..6b21bb67fe2dfca9c4578f1b622503cc379b7c1c 100644 (file)
@@ -1780,7 +1780,7 @@ class IdentityAutoincrementTest(fixtures.TablesTest):
         )
 
     def test_autoincrement_with_identity(self, connection):
-        res = connection.execute(self.tables.tbl.insert(), {"desc": "row"})
+        connection.execute(self.tables.tbl.insert(), {"desc": "row"})
         res = connection.execute(self.tables.tbl.select()).first()
         eq_(res, (1, "row"))
 
index 393c855abca87075e3762839fa45c60f6b3ac0b0..82f22a01957051000654b2c5f927626f3d81d55b 100644 (file)
@@ -112,7 +112,7 @@ def find_cycles(
                     todo.remove(node)
                     break
             else:
-                node = stack.pop()
+                stack.pop()
     return output
 
 
index 7e73dd0be3588a5a3f533ba66796071bac481430..c1b1a8c9c168665191f7c65b5a9f8378d2c73e02 100644 (file)
@@ -1,7 +1,6 @@
 from pathlib import Path
 import re
 
-
 from sqlalchemy.util.tool_support import code_writer_cmd
 
 sa_path = Path(__file__).parent.parent / "lib/sqlalchemy"