Skip to content

Commit 065a408

Browse files
authored
Merge pull request #47 from castroofelipee/main
Adding Pre-commit hooks
2 parents 2cb6dfd + 1318808 commit 065a408

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-added-large-files
8+
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: v0.12.1
11+
hooks:
12+
- id: ruff
13+
args: ["check", "crudadmin", "--fix"]
14+
- id: ruff-format
15+
args: ["crudadmin"]
16+
17+
- repo: https://github.com/pre-commit/mirrors-mypy
18+
rev: v1.16.1
19+
hooks:
20+
- id: mypy
21+
args: ["crudadmin", "--strict"]

CONTRIBUTING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,31 @@ CRUDAdmin uses pytest for testing. Run tests using:
4949
uv run pytest
5050
```
5151

52+
### Pre-commit Hooks
53+
CRUDAdmin uses pre-commit to automatically check code quality before each commit. It helps enforce
54+
linting, formatting, and type checking.
55+
56+
After installing the development dependencies:
57+
58+
```sh
59+
uv run pre-commit install
60+
```
61+
62+
This will set up thee Git hooks to run automatically before every commit.
63+
64+
*Running hooks Manually*
65+
To run all hooks on all files:
66+
```sh
67+
uv run pre-commit run --all-files
68+
```
69+
70+
This will run:
71+
- `ruff` fot linting and formatting
72+
- `mypy` for type checking
73+
- basic formatting checks (trailing whitespace, EOF, file size)
74+
75+
Make sure all pre-commit checks pass before submitting a PR.
76+
5277
### Linting
5378
Use mypy for type checking:
5479
```sh

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ dev = [
8989
"httptools>=0.6.4",
9090
"httpx>=0.28.1",
9191
"sqlalchemy[mypy]>=2.0.36",
92-
"sqlalchemy-utils>=0.41.2"
92+
"sqlalchemy-utils>=0.41.2",
93+
"pre-commit>=3.5.0"
9394
]
9495

9596
docs = [

0 commit comments

Comments
 (0)