]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Add single pound to generated comments
authorMaico Timmerman <maico.timmerman@gmail.com>
Tue, 15 Nov 2016 20:39:18 +0000 (15:39 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 15 Nov 2016 20:57:35 +0000 (15:57 -0500)
Adjustment to the "please adjust!" comment in the script.py.mako
template so that the generated comment starts with a single pound
sign, appeasing flake8.

Change-Id: I4b425d2fa8701cabf8352d046b3342a73f78c70d
Pull-request: https://bitbucket.org/zzzeek/alembic/pull-requests/65
Partially-fixes: #393

alembic/autogenerate/render.py
docs/build/changelog.rst
tests/test_autogen_composition.py
tests/test_autogen_render.py
tests/test_script_production.py

index cade4d7c837f21af65b049b577e3d263d3997274..476c1f9fa35c93e55d0fb343541c0eb9ad6bd751 100644 (file)
@@ -52,8 +52,7 @@ def _render_cmd_body(op_container, autogen_context):
     printer = PythonPrinter(buf)
 
     printer.writeline(
-        "### commands auto generated by Alembic - "
-        "please adjust! ###"
+        "# ### commands auto generated by Alembic - please adjust! ###"
     )
 
     if not op_container.ops:
@@ -65,7 +64,7 @@ def _render_cmd_body(op_container, autogen_context):
             for line in lines:
                 printer.writeline(line)
 
-    printer.writeline("### end Alembic commands ###")
+    printer.writeline("# ### end Alembic commands ###")
 
     return buf.getvalue()
 
index f8a89be2809ac9c0d827bac94e57e39ac6135f12..1f683c27caf916f9842f0e67f10f0958ec782bfe 100644 (file)
@@ -6,6 +6,14 @@ Changelog
 .. changelog::
     :version: 0.8.9
 
+    .. change::  393
+      :tags: bug, autogenerate
+      :tickets: 393
+
+      Adjustment to the "please adjust!" comment in the script.py.mako
+      template so that the generated comment starts with a single pound
+      sign, appeasing flake8.
+
     .. change::
       :tags: bug, autogenerate
       :tickets: 395
index ace6e194bfa22c5052d2652a3507181375ba5d98..c53631750a753fbc935b3c7f11f7bcebcb1d9944 100644 (file)
@@ -26,13 +26,13 @@ class AutogenerateDiffTest(ModelOne, AutogenTest, TestBase):
         autogenerate._render_migration_diffs(context, template_args)
 
         eq_(re.sub(r"u'", "'", template_args['upgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     pass
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
         eq_(re.sub(r"u'", "'", template_args['downgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     pass
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
 
     def test_render_nothing_batch(self):
         context = MigrationContext.configure(
@@ -53,13 +53,13 @@ class AutogenerateDiffTest(ModelOne, AutogenTest, TestBase):
         autogenerate._render_migration_diffs(context, template_args)
 
         eq_(re.sub(r"u'", "'", template_args['upgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     pass
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
         eq_(re.sub(r"u'", "'", template_args['downgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     pass
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
 
     def test_render_diffs_standard(self):
         """test a full render including indentation"""
@@ -67,7 +67,7 @@ class AutogenerateDiffTest(ModelOne, AutogenTest, TestBase):
         template_args = {}
         autogenerate._render_migration_diffs(self.context, template_args)
         eq_(re.sub(r"u'", "'", template_args['upgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     op.create_table('item',
     sa.Column('id', sa.Integer(), nullable=False),
     sa.Column('description', sa.String(length=100), nullable=True),
@@ -96,10 +96,10 @@ nullable=True))
                nullable=False)
     op.drop_index('pw_idx', table_name='user')
     op.drop_column('user', 'pw')
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
 
         eq_(re.sub(r"u'", "'", template_args['downgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     op.add_column('user', sa.Column('pw', sa.VARCHAR(length=50), \
 nullable=True))
     op.create_index('pw_idx', 'user', ['pw'], unique=False)
@@ -125,7 +125,7 @@ nullable=True))
     sa.ForeignKeyConstraint(['uid'], ['user.id'], )
     )
     op.drop_table('item')
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
 
     def test_render_diffs_batch(self):
         """test a full render in batch mode including indentation"""
@@ -135,7 +135,7 @@ nullable=True))
         autogenerate._render_migration_diffs(self.context, template_args)
 
         eq_(re.sub(r"u'", "'", template_args['upgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     op.create_table('item',
     sa.Column('id', sa.Integer(), nullable=False),
     sa.Column('description', sa.String(length=100), nullable=True),
@@ -169,10 +169,10 @@ nullable=True))
         batch_op.drop_index('pw_idx')
         batch_op.drop_column('pw')
 
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
 
         eq_(re.sub(r"u'", "'", template_args['downgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     with op.batch_alter_table('user', schema=None) as batch_op:
         batch_op.add_column(sa.Column('pw', sa.VARCHAR(length=50), nullable=True))
         batch_op.create_index('pw_idx', ['pw'], unique=False)
@@ -203,7 +203,7 @@ nullable=True))
     sa.ForeignKeyConstraint(['uid'], ['user.id'], )
     )
     op.drop_table('item')
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
 
     def test_imports_maintined(self):
         template_args = {}
@@ -252,13 +252,13 @@ class AutogenerateDiffTestWSchema(ModelOne, AutogenTest, TestBase):
         autogenerate._render_migration_diffs(context, template_args)
 
         eq_(re.sub(r"u'", "'", template_args['upgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     pass
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
         eq_(re.sub(r"u'", "'", template_args['downgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     pass
-    ### end Alembic commands ###""")
+    # ### end Alembic commands ###""")
 
     def test_render_diffs_extras(self):
         """test a full render including indentation (include and schema)"""
@@ -271,7 +271,7 @@ class AutogenerateDiffTestWSchema(ModelOne, AutogenTest, TestBase):
         autogenerate._render_migration_diffs(self.context, template_args)
 
         eq_(re.sub(r"u'", "'", template_args['upgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     op.create_table('item',
     sa.Column('id', sa.Integer(), nullable=False),
     sa.Column('description', sa.String(length=100), nullable=True),
@@ -307,10 +307,10 @@ source_schema='%(schema)s', referent_schema='%(schema)s')
                schema='%(schema)s')
     op.drop_index('pw_idx', table_name='user', schema='test_schema')
     op.drop_column('user', 'pw', schema='%(schema)s')
-    ### end Alembic commands ###""" % {"schema": self.schema})
+    # ### end Alembic commands ###""" % {"schema": self.schema})
 
         eq_(re.sub(r"u'", "'", template_args['downgrades']),
-            """### commands auto generated by Alembic - please adjust! ###
+            """# ### commands auto generated by Alembic - please adjust! ###
     op.add_column('user', sa.Column('pw', sa.VARCHAR(length=50), \
 autoincrement=False, nullable=True), schema='%(schema)s')
     op.create_index('pw_idx', 'user', ['pw'], unique=False, schema='%(schema)s')
@@ -341,5 +341,5 @@ name='extra_uid_fkey'),
     schema='%(schema)s'
     )
     op.drop_table('item', schema='%(schema)s')
-    ### end Alembic commands ###""" % {"schema": self.schema})
+    # ### end Alembic commands ###""" % {"schema": self.schema})
 
index 64425a97588f0531c731696999c2b5e8f688a7d0..4beabb07a3b5f42aba47de3ecd7bd78b74032729 100644 (file)
@@ -1674,7 +1674,7 @@ class RenderNamingConventionTest(TestBase):
 
         eq_(
             autogenerate.render_python_code(uo, render_as_batch=True),
-            "### commands auto generated by Alembic - please adjust! ###\n"
+            "# ### commands auto generated by Alembic - please adjust! ###\n"
             "    op.create_table('sometable',\n"
             "    sa.Column('x', sa.Integer(), nullable=True),\n"
             "    sa.Column('y', sa.Integer(), nullable=True)\n"
@@ -1683,5 +1683,5 @@ class RenderNamingConventionTest(TestBase):
             "as batch_op:\n"
             "        batch_op.create_index("
             "'ix1', ['x', 'y'], unique=False)\n\n"
-            "    ### end Alembic commands ###"
+            "    # ### end Alembic commands ###"
         )
index 66e311d1745cd86d03cf27826985305151d9141f..9399be667dc9aaa7033bfe0dc45f3ac2fa98ceec 100644 (file)
@@ -708,14 +708,14 @@ class RewriterTest(TestBase):
 
         eq_(
             autogenerate.render_python_code(directives[0].upgrade_ops),
-            "### commands auto generated by Alembic - please adjust! ###\n"
+            "# ### commands auto generated by Alembic - please adjust! ###\n"
             "    op.add_column('t1', "
             "sa.Column('x', sa.Integer(), nullable=True))\n"
             "    op.create_index('ixt', 't1', ['x'], unique=False)\n"
             "    op.alter_column('t1', 'x',\n"
             "               existing_type=sa.Integer(),\n"
             "               nullable=False)\n"
-            "    ### end Alembic commands ###"
+            "    # ### end Alembic commands ###"
         )