]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Fix flake8
authorJustin Malin <justin@joincandidhealth.com>
Tue, 10 Jun 2025 17:41:46 +0000 (17:41 +0000)
committerJustin Malin <justin@joincandidhealth.com>
Tue, 10 Jun 2025 17:41:46 +0000 (17:41 +0000)
alembic/autogenerate/render.py
tests/test_autogen_render.py
tests/test_postgresql.py

index 9d955646b0c137073c65563d305a788e9512749f..8f88a7b914c8d8a3b44f02f99d30ce04088304a3 100644 (file)
@@ -32,7 +32,6 @@ if TYPE_CHECKING:
 
     from sqlalchemy import Computed
     from sqlalchemy import Identity
-    from sqlalchemy.sql.base import DialectKWArgs
     from sqlalchemy.sql.elements import ColumnElement
     from sqlalchemy.sql.elements import TextClause
     from sqlalchemy.sql.schema import CheckConstraint
@@ -420,12 +419,15 @@ def _add_fk_constraint(
             if value is not None:
                 args.append("%s=%r" % (k, value))
 
-    dialect_kwargs = _render_dialect_kwargs_items(autogen_context, constraint.dialect_kwargs)
+    dialect_kwargs = _render_dialect_kwargs_items(
+        autogen_context, constraint.dialect_kwargs
+    )
 
     return "%(prefix)screate_foreign_key(%(args)s%(dialect_kwargs)s)" % {
         "prefix": _alembic_autogenerate_prefix(autogen_context),
         "args": ", ".join(args),
-        "dialect_kwargs": ", " + ", ".join(dialect_kwargs) if dialect_kwargs else "",
+        "dialect_kwargs": ", " + ", ".join(dialect_kwargs)
+        if dialect_kwargs else "",
     }
 
 
@@ -669,7 +671,9 @@ def _uq_constraint(
         opts.append(
             ("name", _render_gen_name(autogen_context, constraint.name))
         )
-    dialect_options = _render_dialect_kwargs_items(autogen_context, constraint.dialect_kwargs)
+    dialect_options = _render_dialect_kwargs_items(
+        autogen_context, constraint.dialect_kwargs
+    )
 
     if alter:
         args = [repr(_render_gen_name(autogen_context, constraint.name))]
index 7f60def677a8937f9bca3b8e0bfba3f6ef22db6b..9bc894ba0d228f2d61d626ce251d2def8d4f5194 100644 (file)
@@ -41,7 +41,7 @@ from alembic import op  # noqa
 from alembic import testing
 from alembic.autogenerate import api
 from alembic.migration import MigrationContext
-from alembic.operations import Operations, ops
+from alembic.operations import ops
 from alembic.testing import assert_raises
 from alembic.testing import assertions
 from alembic.testing import config
@@ -317,15 +317,21 @@ class AutogenRenderTest(TestBase):
     def test_add_fk_constraint__dialect_kwargs(self):
         t1 = self.table()
         t2 = self.table()
-        item = ForeignKeyConstraint([t1.c.id], [t2.c.id], name="fk", postgresql_not_valid=True)
+        item = ForeignKeyConstraint(
+            [t1.c.id], [t2.c.id], name="fk", postgresql_not_valid=True
+        )
         fk_obj = ops.CreateForeignKeyOp.from_constraint(item)
 
         eq_ignore_whitespace(
-            re.sub( r"u'", "'", autogenerate.render_op_text(self.autogen_context, fk_obj)),
-            "op.create_foreign_key('fk', 'test', 'test', ['id'], ['id'], postgresql_not_valid=True)",
+            re.sub(
+                r"u'",
+                "'",
+                autogenerate.render_op_text(self.autogen_context, fk_obj)
+            ),
+            "op.create_foreign_key('fk', 'test', 'test', ['id'], ['id'], "
+            "postgresql_not_valid=True)",
         )
 
-
     def test_drop_index_batch(self):
         """
         autogenerate.render._drop_index
index 289090df1e276d96e048e2bd618563109ad51766..476da5f15ed804df75049445c804783bac40a807 100644 (file)
@@ -135,8 +135,13 @@ class PostgresqlOpTest(TestBase):
 
     def test_create_fk_postgresql_not_valid(self):
         context = op_fixture("postgresql")
-        op.create_foreign_key("i", "t1", "t2", ["c1"], ["c2"], postgresql_not_valid=True)
-        context.assert_("ALTER TABLE t1 ADD CONSTRAINT i FOREIGN KEY(c1) REFERENCES t2 (c2) NOT VALID")
+        op.create_foreign_key(
+            "i", "t1", "t2", ["c1"], ["c2"], postgresql_not_valid=True
+        )
+        context.assert_(
+            "ALTER TABLE t1 ADD CONSTRAINT i FOREIGN KEY(c1) "
+            "REFERENCES t2 (c2) NOT VALID"
+        )
 
     @config.combinations("include_table", "no_table", argnames="include_table")
     def test_drop_index_postgresql_concurrently(self, include_table):