Skip to content

Commit

Permalink
Avoid D103 linter warnings via script.py.mako
Browse files Browse the repository at this point in the history
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 sqlalchemy#1567
  • Loading branch information
peterjc committed Nov 5, 2024
1 parent a5bb01f commit fa3bcd5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions alembic/templates/async/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
2 changes: 2 additions & 0 deletions alembic/templates/generic/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
4 changes: 4 additions & 0 deletions alembic/templates/multidb/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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]()

<%
Expand All @@ -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

0 comments on commit fa3bcd5

Please sign in to comment.