From: Shamil Date: Mon, 21 Apr 2025 16:35:43 +0000 (-0400) Subject: refactor(testing-and-utils): Remove unused code and fix style issues X-Git-Tag: rel_2_0_41~19^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4bfdafe337aacc7ac03058063458091502f650f1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git refactor(testing-and-utils): Remove unused code and fix style issues 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 (cherry picked from commit 64f45d0a6b4ad41cf570a8f0e09b86fba0ebb043) (cherry picked from commit e15cb0779b42829027faea3496fa0d5163d9e2f5) --- diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index f6d47c631c..e5b63adf29 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -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 ): diff --git a/lib/sqlalchemy/testing/suite/test_dialect.py b/lib/sqlalchemy/testing/suite/test_dialect.py index ae67cc10ad..ebbb9e435a 100644 --- a/lib/sqlalchemy/testing/suite/test_dialect.py +++ b/lib/sqlalchemy/testing/suite/test_dialect.py @@ -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"}, diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py index 47e012aba3..d3d8b37dfa 100644 --- a/lib/sqlalchemy/testing/suite/test_reflection.py +++ b/lib/sqlalchemy/testing/suite/test_reflection.py @@ -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 @@ -2047,7 +2047,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): @@ -2063,7 +2063,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): diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py index b9e8b11efe..d67d769876 100644 --- a/lib/sqlalchemy/testing/suite/test_select.py +++ b/lib/sqlalchemy/testing/suite/test_select.py @@ -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")) diff --git a/lib/sqlalchemy/util/topological.py b/lib/sqlalchemy/util/topological.py index 393c855abc..82f22a0195 100644 --- a/lib/sqlalchemy/util/topological.py +++ b/lib/sqlalchemy/util/topological.py @@ -112,7 +112,7 @@ def find_cycles( todo.remove(node) break else: - node = stack.pop() + stack.pop() return output