Skip to content

Commit c236a2f

Browse files
authored
Fixed ruff integration with alembic. (#230)
1 parent a5f4e73 commit c236a2f

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed

fastapi_template/template/{{cookiecutter.project_name}}/alembic.ini

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ output_encoding = utf-8
77

88

99
[post_write_hooks]
10-
hooks = black,autoflake,isort
10+
hooks = black,ruff
1111

1212
black.type = console_scripts
1313
black.entrypoint = black
1414

15-
autoflake.type = console_scripts
16-
autoflake.entrypoint = autoflake
17-
18-
isort.type = console_scripts
19-
isort.entrypoint = isort
15+
ruff.type = exec
16+
ruff.executable = ruff
17+
ruff.options = check --fix REVISION_SCRIPT_FILENAME --ignore N999
2018

2119
# Logging configuration
2220
[loggers]

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_ormar/migrations/script.py.mako

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""${message}
1+
"""${message}${"." if not message.endswith(".") else ""}
22

33
Revision ID: ${up_revision}
44
Revises: ${down_revision | comma,n}
@@ -17,8 +17,10 @@ depends_on = ${repr(depends_on)}
1717

1818

1919
def upgrade() -> None:
20-
${upgrades if upgrades else "pass"}
20+
"""Run the migration."""
21+
${upgrades if upgrades else ""}
2122

2223

2324
def downgrade() -> None:
24-
${downgrades if downgrades else "pass"}
25+
"""Undo the migration."""
26+
${downgrades if downgrades else ""}

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_ormar/migrations/versions/2021-08-16-16-53_819cbf6e030b.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
"""
88

9-
109
# revision identifiers, used by Alembic.
1110
revision = "819cbf6e030b"
1211
down_revision = None
@@ -15,8 +14,8 @@
1514

1615

1716
def upgrade() -> None:
18-
pass
17+
"""Run the upgrade migrations."""
1918

2019

2120
def downgrade() -> None:
22-
pass
21+
"""Run the downgrade migrations."""

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_ormar/migrations/versions/2021-08-16-16-55_2b7380507a71.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def upgrade() -> None:
19-
# ### commands auto generated by Alembic - please adjust! ###
19+
"""Run the upgrade migrations."""
2020
op.create_table(
2121
"dummy_model",
2222
sa.Column("id", sa.Integer(), nullable=False),
@@ -27,6 +27,6 @@ def upgrade() -> None:
2727

2828

2929
def downgrade() -> None:
30-
# ### commands auto generated by Alembic - please adjust! ###
30+
"""Run the downgrade migrations."""
3131
op.drop_table("dummy_model")
3232
# ### end Alembic commands ###

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/migrations/script.py.mako

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""${message}
1+
"""${message}${"." if not message.endswith(".") else ""}
22

33
Revision ID: ${up_revision}
44
Revises: ${down_revision | comma,n}
@@ -17,8 +17,10 @@ depends_on = ${repr(depends_on)}
1717

1818

1919
def upgrade() -> None:
20-
${upgrades if upgrades else "pass"}
20+
"""Run the migration."""
21+
${upgrades if upgrades else ""}
2122

2223

2324
def downgrade() -> None:
24-
${downgrades if downgrades else "pass"}
25+
"""Undo the migration."""
26+
${downgrades if downgrades else ""}

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/migrations/versions/2021-08-16-16-53_819cbf6e030b.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515

1616

1717
def upgrade() -> None:
18+
"""Run the upgrade migrations."""
1819
pass
1920

2021

2122
def downgrade() -> None:
23+
"""Run the downgrade migrations."""
2224
pass

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/migrations/versions/2021-08-16-16-55_2b7380507a71.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def upgrade() -> None:
19-
# ### commands auto generated by Alembic - please adjust! ###
19+
"""Run the upgrade migrations."""
2020
op.create_table(
2121
"dummy_model",
2222
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
@@ -27,6 +27,6 @@ def upgrade() -> None:
2727

2828

2929
def downgrade() -> None:
30-
# ### commands auto generated by Alembic - please adjust! ###
30+
"""Run the downgrade migrations."""
3131
op.drop_table("dummy_model")
3232
# ### end Alembic commands ###

0 commit comments

Comments
 (0)