Skip to content

Commit ea4893e

Browse files
chore: migrate to 'prek' for pre-commit hooks
1 parent f82768a commit ea4893e

File tree

9 files changed

+42
-115
lines changed

9 files changed

+42
-115
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Run pre-commit
1+
name: Run prek
22

33
on: [ push, pull_request ]
44

55
jobs:
6-
pre-commit:
6+
prek:
77
runs-on: ubuntu-latest
88
steps:
99
- name: 👾 Check out repository
@@ -15,7 +15,7 @@ jobs:
1515
activate-environment: true
1616
- name: 📦 Install the project
1717
run: uv sync
18-
- name: 🧪 Run pre-commit
19-
run: uv run pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual
18+
- name: 🧪 Run prek
19+
run: uv run prek run --show-diff-on-failure --color=always --all-files --hook-stage manual
2020
env:
2121
RUFF_FORMAT: github

.pre-commit-config.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# Pre-commit configuration.
2-
# https://pre-commit.com
1+
# Prek configuration.
2+
# https://prek.j178.dev/configuration/
33

4-
# pre-commit install
5-
# pre-commit run --all-files
4+
# uv run prek install --overwrite --prepare-hooks -t pre-commit -t commit-msg
5+
# uv run prek auto-update
6+
# uv run prek run --all-files
67

78
default_stages:
89
- pre-commit
@@ -13,7 +14,7 @@ default_stages:
1314
repos:
1415
# Fix some errors with Ruff
1516
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.14.0
17+
rev: v0.15.9
1718
hooks:
1819
- id: ruff
1920
args: [ --fix, --exit-zero ]
@@ -23,7 +24,7 @@ repos:
2324

2425
# Lint Python files with Ruff
2526
- repo: https://github.com/astral-sh/ruff-pre-commit
26-
rev: v0.14.0
27+
rev: v0.15.9
2728
hooks:
2829
- id: ruff
2930
name: "ruff: linting"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Check https://github.com/one-zero-eight/fastapi-template for updates once in a w
7676

7777
1. Run `uv sync --upgrade` to update uv.lock file and install the latest versions of the dependencies.
7878
2. Run `uv tree --outdated --depth=1` will show what package versions are installed and what are the latest versions.
79-
3. Run `uv run pre-commit autoupdate`
79+
3. Run `uv run prek auto-update`
8080

8181
Also, Dependabot will help you to keep your dependencies up-to-date, see [dependabot.yaml](.github/dependabot.yaml).
8282

docker-compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
- "8017:8000"
1515
volumes:
1616
- "./settings.yaml:/app/settings.yaml:ro" # Read-only settings file
17-
17+
1818
db:
1919
# See more: https://hub.docker.com/_/mongo
2020
image: "mongo:8.0"
@@ -31,6 +31,6 @@ services:
3131
environment:
3232
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME:-mongoadmin}
3333
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD:-secret}
34-
34+
3535
volumes:
3636
mongodb:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"cryptography>=44.0.0",
1414
"fastapi[standard]>=0.115.6",
1515
"fastapi-swagger>=0.2.3",
16-
"fastapi-derive-responses>=0.1.4",
16+
"fastapi-derive-responses>=0.1.7",
1717
"gunicorn>=23.0.0",
1818
"httpx>=0.28.1",
1919
"pydantic>=2.12.2",
@@ -22,11 +22,11 @@ dependencies = [
2222
# mongo = [
2323
"beanie>=1.30.0,<2.0.0",
2424
# ]
25+
"prek>=0.3.8",
2526
]
2627

2728
[dependency-groups]
2829
dev = [
29-
"pre-commit>=4.0.1",
3030
"pytest>=8.4.0",
3131
"pytest-asyncio>=1.1.0",
3232
"pytest-cov>=6.2.1",

src/api/dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
77

88
from src.api.exceptions import IncorrectCredentialsException
9-
from src.modules.inh_accounts_sdk import inh_accounts, UserTokenData
9+
from src.modules.inh_accounts_sdk import UserTokenData, inh_accounts
1010

1111
bearer_scheme = HTTPBearer(
1212
scheme_name="Bearer",

src/modules/user/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from src.api import docs
55
from src.api.dependencies import USER_AUTH
6-
from src.modules.inh_accounts_sdk import inh_accounts, UserSchema
6+
from src.modules.inh_accounts_sdk import UserSchema, inh_accounts
77

88
router = APIRouter(
99
prefix="/user",

src/prepare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ def is_pre_commit_installed():
6060

6161
try:
6262
subprocess.run(
63-
["poetry", "run", "pre-commit", "install", "--install-hooks", "-t", "pre-commit", "-t", "commit-msg"],
63+
["uv", "run", "prek", "install", "--overwrite", "--prepare-hooks", "-t", "pre-commit", "-t", "commit-msg"],
6464
check=True,
6565
text=True,
6666
)
6767
print("✅ Pre-commit hooks installed successfully.")
6868
except subprocess.CalledProcessError as e:
6969
print(
70-
f"❌ Error setting up pre-commit hooks:\n{e.stderr}\n Please, setup it manually with `poetry run pre-commit install --install-hooks -t pre-commit -t commit-msg`"
70+
f"❌ Error setting up pre-commit hooks:\n{e.stderr}\nPlease, setup it manually with `uv run prek install --overwrite --prepare-hooks -t pre-commit -t commit-msg`"
7171
)
7272

7373

uv.lock

Lines changed: 22 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)