From fa3bcd5926cc2523ac6f05c3c1e8c4eeafc55dda Mon Sep 17 00:00:00 2001 From: Peter Cock Date: Tue, 5 Nov 2024 14:37:32 +0000 Subject: [PATCH] Avoid D103 linter warnings via script.py.mako This will silence the commonly used pydocstyle D103 warnings from flake8 or ruff check: http://www.pydocstyle.org/en/stable/error_codes.html#grouping https://docs.astral.sh/ruff/rules/undocumented-public-function/ Closes #1567 --- alembic/templates/async/script.py.mako | 2 ++ alembic/templates/generic/script.py.mako | 2 ++ alembic/templates/multidb/script.py.mako | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/alembic/templates/async/script.py.mako b/alembic/templates/async/script.py.mako index fbc4b07d..480b130d 100644 --- a/alembic/templates/async/script.py.mako +++ b/alembic/templates/async/script.py.mako @@ -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"} diff --git a/alembic/templates/generic/script.py.mako b/alembic/templates/generic/script.py.mako index fbc4b07d..480b130d 100644 --- a/alembic/templates/generic/script.py.mako +++ b/alembic/templates/generic/script.py.mako @@ -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"} diff --git a/alembic/templates/multidb/script.py.mako b/alembic/templates/multidb/script.py.mako index 6108b8a0..3caca7bf 100644 --- a/alembic/templates/multidb/script.py.mako +++ b/alembic/templates/multidb/script.py.mako @@ -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