Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Run ruff as post-hook for alembic autogen migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsDrike committed Jul 21, 2024
1 parent 35975b9 commit 2147785
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
"""Initial migration
Revision ID: c55da3c62644
Revises:
Revises:
Create Date: 2024-07-21 18:54:26.159716
"""

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = 'c55da3c62644'
revision: str = "c55da3c62644"
down_revision: str | None = None
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
Expand Down
22 changes: 11 additions & 11 deletions alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ sqlalchemy.url = driver://user:pass@localhost/dbname
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples
# https://alembic.sqlalchemy.org/en/latest/autogenerate.html#basic-post-processor-configuration

hooks = ruff-autofix, ruff-format

ruff-autofix.type = exec
ruff-autofix.executable = %(here)s/.venv/bin/ruff
ruff-autofix.options = check --fix REVISION_SCRIPT_FILENAME

ruff-format.type = exec
ruff-format.executable = %(here)s/.venv/bin/ruff
ruff-format.options = format REVISION_SCRIPT_FILENAME

# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME

# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
# hooks = ruff
# ruff.type = exec
# ruff.executable = %(here)s/.venv/bin/ruff
# ruff.options = --fix REVISION_SCRIPT_FILENAME

# Logging configuration
[loggers]
Expand Down
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
"Benji <binyamin1bbb@gmail.com>",
"Paillat-dev <me@paillat.dev>",
"v33010 <vivekgohil2606@gmail.com>",
"Ash8121 <ashtikkm@gmail.com>"
"Ash8121 <ashtikkm@gmail.com>",
]
readme = "README.md"
license = "MIT"
Expand Down Expand Up @@ -35,7 +35,7 @@ pytest-cov = "^5.0.0"


[tool.poetry.group.dev.dependencies]
datamodel-code-generator = {extras = ["http"], version = "^0.25.8"}
datamodel-code-generator = { extras = ["http"], version = "^0.25.8" }


[tool.datamodel-codegen]
Expand Down Expand Up @@ -172,17 +172,13 @@ max-statements = 75
]
"alembic-migrations/versions/*" = [
"INP001", # Implicit namespace package
"W291", # Trailing whitespace
"D103", # Missing docstring in public function
"D400", # First line should end with a period
"D415", # First line should end with a period, question mark, or exclamation point
"F401", # Unused import
"Q000", # Single quotes found but double quotes preferred
]

[tool.ruff.format]
line-ending = "lf"
exclude = ["alembic-migrations/versions/*.py"]

[tool.basedpyright]
pythonPlatform = "All"
Expand Down

0 comments on commit 2147785

Please sign in to comment.