Skip to content

Commit 6d1d833

Browse files
committed
⬆️ Use prek as a pre-commit alternative
1 parent 6a91475 commit 6d1d833

File tree

3 files changed

+40
-95
lines changed

3 files changed

+40
-95
lines changed

backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dev-dependencies = [
2828
"pytest<8.0.0,>=7.4.3",
2929
"mypy<2.0.0,>=1.8.0",
3030
"ruff<1.0.0,>=0.2.2",
31-
"pre-commit<4.0.0,>=3.6.2",
31+
"prek==0.2.22",
3232
"types-passlib<2.0.0.0,>=1.7.7.20240106",
3333
"coverage<8.0.0,>=7.4.3",
3434
]

backend/uv.lock

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

development.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,48 +134,51 @@ One way to do it could be to add each environment variable to your CI/CD system,
134134

135135
## Pre-commits and code linting
136136

137-
we are using a tool called [pre-commit](https://pre-commit.com/) for code linting and formatting.
137+
we are using a tool called [prek](https://prek.j178.dev/) (modern alternative to [Pre-commit](https://pre-commit.com/)) for code linting and formatting.
138138

139139
When you install it, it runs right before making a commit in git. This way it ensures that the code is consistent and formatted even before it is committed.
140140

141141
You can find a file `.pre-commit-config.yaml` with configurations at the root of the project.
142142

143-
#### Install pre-commit to run automatically
143+
#### Install prek to run automatically
144144

145-
`pre-commit` is already part of the dependencies of the project, but you could also install it globally if you prefer to, following [the official pre-commit docs](https://pre-commit.com/).
145+
`prek` is already part of the dependencies of the project.
146146

147-
After having the `pre-commit` tool installed and available, you need to "install" it in the local repository, so that it runs automatically before each commit.
147+
After having the `prek` tool installed and available, you need to "install" it in the local repository, so that it runs automatically before each commit.
148148

149-
Using `uv`, you could do it with:
149+
Using `uv`, you could do it with (make sure you are inside `backend` folder):
150150

151151
```bash
152-
❯ uv run pre-commit install
153-
pre-commit installed at .git/hooks/pre-commit
152+
❯ uv run prek install -f
153+
prek installed at `../.git/hooks/pre-commit`
154154
```
155155

156+
The `-f` flag forces the installation, in case there was already a `pre-commit` hook previously installed.
157+
156158
Now whenever you try to commit, e.g. with:
157159

158160
```bash
159161
git commit
160162
```
161163

162-
...pre-commit will run and check and format the code you are about to commit, and will ask you to add that code (stage it) with git again before committing.
164+
...prek will run and check and format the code you are about to commit, and will ask you to add that code (stage it) with git again before committing.
163165

164166
Then you can `git add` the modified/fixed files again and now you can commit.
165167

166-
#### Running pre-commit hooks manually
168+
#### Running prek hooks manually
167169

168-
you can also run `pre-commit` manually on all the files, you can do it using `uv` with:
170+
you can also run `prek` manually on all the files, you can do it using `uv` with:
169171

170172
```bash
171-
❯ uv run pre-commit run --all-files
173+
❯ uv run prek run --all-files
172174
check for added large files..............................................Passed
173175
check toml...............................................................Passed
174176
check yaml...............................................................Passed
177+
fix end of files.........................................................Passed
178+
trim trailing whitespace.................................................Passed
175179
ruff.....................................................................Passed
176180
ruff-format..............................................................Passed
177-
eslint...................................................................Passed
178-
prettier.................................................................Passed
181+
biome check..............................................................Passed
179182
```
180183

181184
## URLs

0 commit comments

Comments
 (0)