Skip to content

Commit a57a069

Browse files
committed
Day 7: Pre-Commit Added
1 parent b1fee00 commit a57a069

File tree

4 files changed

+276
-0
lines changed

4 files changed

+276
-0
lines changed

.github/workflows/pre-commit.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: pre-commit
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
8+
jobs:
9+
run-pre-commit:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.11"
20+
21+
- name: Install UV
22+
uses: astral-sh/setup-uv@v3
23+
24+
- name: Install dependencies using UV
25+
run: |
26+
uv sync
27+
28+
- name: Install pre-commit
29+
run: uv tool install pre-commit
30+
31+
- name: Run pre-commit
32+
run: pre-commit run --all-files --show-diff-on-failure

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.6.5
4+
hooks:
5+
- id: ruff
6+
args: ["--fix"]
7+
files: "\\.py$"
8+
- id: ruff-format
9+
files: "\\.py$"
10+
11+
- repo: https://github.com/psf/black
12+
rev: 24.4.2
13+
hooks:
14+
- id: black
15+
language_version: python3
16+
files: "\\.py$"

pyproject.toml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,64 @@ dependencies = [
1111
"djangorestframework>=3.16.1",
1212
"djangorestframework-simplejwt>=5.5.1",
1313
"pillow>=12.0.0",
14+
"pre-commit>=4.5.1",
1415
"psycopg2-binary==2.9.11",
1516
"python-decouple>=3.8",
1617
]
18+
19+
20+
[dependency-groups]
21+
dev = [
22+
"pre-commit>=4.4.0",
23+
"ruff>=0.14.5",
24+
]
25+
26+
# ===============================
27+
# BLACK (FORMATTER ONLY)
28+
# ===============================
29+
[tool.black]
30+
line-length = 88
31+
target-version = ["py313"]
32+
33+
# ===============================
34+
# RUFF - LINT + AUTOFIX
35+
# ===============================
36+
[tool.ruff]
37+
line-length = 88
38+
target-version = "py313"
39+
exclude = ["migrations", ".venv", "env"]
40+
fix = true
41+
42+
[tool.ruff.lint]
43+
select = ["E", "F", "I", "W", "D", "UP", "B", "DJ"]
44+
ignore = [
45+
"D100",
46+
"D101",
47+
"D102",
48+
"D103",
49+
"D104",
50+
"D105",
51+
"D106",
52+
"D107",
53+
"D203",
54+
"D212",
55+
]
56+
57+
# ===============================
58+
# RUFF FORMAT CONFIG
59+
# ===============================
60+
[tool.ruff.format]
61+
quote-style = "double"
62+
indent-style = "space"
63+
line-ending = "auto"
64+
65+
# ===============================
66+
# RUFF ISORT (IMPORT MANAGEMENT)
67+
# ===============================
68+
[tool.ruff.lint.isort]
69+
combine-as-imports = true
70+
force-single-line = false
71+
known-first-party = ["backend", "api", "easyaudit"]
72+
73+
74+

0 commit comments

Comments
 (0)