]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Avoid D103 linter warnings via script.py.mako
authorPeter Cock <p.j.a.cock@googlemail.com>
Wed, 6 Nov 2024 17:07:02 +0000 (12:07 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 3 Feb 2025 14:48:26 +0000 (09:48 -0500)
Added a basic docstring to the migration template files so that the
upgrade/downgrade methods pass the D103 linter check which requires a
docstring for public functions.  Pull request courtesy Peter Cock.

Fixes: #1567
Closes: #1568
Pull-request: https://github.com/sqlalchemy/alembic/pull/1568
Pull-request-sha: fa3bcd5926cc2523ac6f05c3c1e8c4eeafc55dda

Change-Id: I14b7863dfef01edca9c94d8dff4109efd274df3c

alembic/templates/async/script.py.mako
alembic/templates/generic/script.py.mako
alembic/templates/multidb/script.py.mako
docs/build/unreleased/1567.rst [new file with mode: 0644]
tests/test_script_production.py

index fbc4b07dcef98b20c6f96b642097f35e8433258e..480b130d632ca677c11f23d9fe82cf4014d15e0c 100644 (file)
@@ -19,8 +19,10 @@ depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
 
 
 def upgrade() -> None:
+    """Upgrade schema."""
     ${upgrades if upgrades else "pass"}
 
 
 def downgrade() -> None:
+    """Downgrade schema."""
     ${downgrades if downgrades else "pass"}
index fbc4b07dcef98b20c6f96b642097f35e8433258e..480b130d632ca677c11f23d9fe82cf4014d15e0c 100644 (file)
@@ -19,8 +19,10 @@ depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
 
 
 def upgrade() -> None:
+    """Upgrade schema."""
     ${upgrades if upgrades else "pass"}
 
 
 def downgrade() -> None:
+    """Downgrade schema."""
     ${downgrades if downgrades else "pass"}
index 6108b8a0dc2a1bef8f8b25fda188ab61ef9bdaf9..3caca7bfa54033036b16f1ae65f64f4ca770f402 100644 (file)
@@ -22,10 +22,12 @@ depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
 
 
 def upgrade(engine_name: str) -> None:
+    """Upgrade schema."""
     globals()["upgrade_%s" % engine_name]()
 
 
 def downgrade(engine_name: str) -> None:
+    """Downgrade schema."""
     globals()["downgrade_%s" % engine_name]()
 
 <%
@@ -38,10 +40,12 @@ def downgrade(engine_name: str) -> None:
 % for db_name in re.split(r',\s*', db_names):
 
 def upgrade_${db_name}() -> None:
+    """Upgrade ${db_name} schema."""
     ${context.get("%s_upgrades" % db_name, "pass")}
 
 
 def downgrade_${db_name}() -> None:
+    """Downgrade ${db_name} schema."""
     ${context.get("%s_downgrades" % db_name, "pass")}
 
 % endfor
diff --git a/docs/build/unreleased/1567.rst b/docs/build/unreleased/1567.rst
new file mode 100644 (file)
index 0000000..a9a89c0
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, environment
+    :tickets: 1567
+
+    Added a basic docstring to the migration template files so that the
+    upgrade/downgrade methods pass the D103 linter check which requires a
+    docstring for public functions.  Pull request courtesy Peter Cock.
index 0551acb5bf9c19a085411c6965848ca173c72b30..7857f5d424f1dbfc5252f1e48f6912ba5df5afd8 100644 (file)
@@ -657,8 +657,9 @@ def downgrade():
             result = handle.read()
         assert (
             (
-                """
+                '''
 def upgrade() -> None:
+    """Upgrade schema."""
     # ### commands auto generated by Alembic - please adjust! ###
     op.create_table('test_table',
     sa.Column('id', sa.Integer(), nullable=False),
@@ -666,7 +667,7 @@ def upgrade() -> None:
     sa.PrimaryKeyConstraint('id')
     )
     # ### end Alembic commands ###
-"""
+'''
             )
             in result
         )