Skip to content

Commit b0d9620

Browse files
committed
Add pre-commit CI and ruff in favor of other linters
1 parent 66cf396 commit b0d9620

File tree

3 files changed

+104
-46
lines changed

3 files changed

+104
-46
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,10 @@
11
name: CI
2-
32
on:
43
push:
54
branches:
65
- main
76
pull_request:
8-
97
jobs:
10-
11-
lint:
12-
runs-on: ubuntu-latest
13-
strategy:
14-
matrix:
15-
lint-command:
16-
- bandit -r . -x ./tests
17-
- black --check --diff .
18-
- flake8 .
19-
- isort --check-only --diff .
20-
- pydocstyle .
21-
steps:
22-
- uses: actions/checkout@v5
23-
- uses: actions/setup-python@v6
24-
with:
25-
python-version: "3.x"
26-
cache: 'pip'
27-
cache-dependency-path: 'pyproject.toml'
28-
- run: python -m pip install -e .[lint]
29-
- run: ${{ matrix.lint-command }}
30-
318
dist:
329
runs-on: ubuntu-latest
3310
steps:
@@ -43,11 +20,8 @@ jobs:
4320
- uses: actions/upload-artifact@v5
4421
with:
4522
path: dist/*
46-
4723
pytest-os:
4824
name: PyTest
49-
needs:
50-
- lint
5125
strategy:
5226
matrix:
5327
os:
@@ -67,11 +41,8 @@ jobs:
6741
with:
6842
flags: ${{ matrix.os }}
6943
token: ${{ secrets.CODECOV_TOKEN }}
70-
7144
pytest-python:
7245
name: PyTest
73-
needs:
74-
- lint
7546
strategy:
7647
matrix:
7748
python-version:
@@ -80,7 +51,7 @@ jobs:
8051
- "3.12"
8152
- "3.13"
8253
django-version:
83-
- "4.2" # LTS
54+
- "4.2" # LTS
8455
runs-on: ubuntu-latest
8556
steps:
8657
- uses: actions/checkout@v5
@@ -95,11 +66,8 @@ jobs:
9566
with:
9667
flags: py${{ matrix.python-version }}
9768
token: ${{ secrets.CODECOV_TOKEN }}
98-
9969
pytest-django:
10070
name: PyTest
101-
needs:
102-
- lint
10371
strategy:
10472
matrix:
10573
python-version:
@@ -122,11 +90,8 @@ jobs:
12290
with:
12391
flags: dj${{ matrix.django-version }}
12492
token: ${{ secrets.CODECOV_TOKEN }}
125-
12693
pytest-extras:
12794
name: PyTest
128-
needs:
129-
- lint
13095
strategy:
13196
matrix:
13297
extras:
@@ -151,10 +116,9 @@ jobs:
151116
with:
152117
flags: ${{ matrix.extras }}
153118
token: ${{ secrets.CODECOV_TOKEN }}
154-
155119
codeql:
156120
name: CodeQL
157-
needs: [ dist, pytest-os, pytest-python, pytest-django, pytest-extras ]
121+
needs: [dist, pytest-os, pytest-python, pytest-django, pytest-extras]
158122
runs-on: ubuntu-latest
159123
permissions:
160124
actions: read
@@ -163,7 +127,7 @@ jobs:
163127
strategy:
164128
fail-fast: false
165129
matrix:
166-
language: [ python ]
130+
language: [python]
167131
steps:
168132
- name: Checkout
169133
uses: actions/checkout@v5

.pre-commit-config.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: check-merge-conflict
7+
- id: check-ast
8+
- id: check-json
9+
- id: pretty-format-json
10+
args: [--autofix]
11+
- id: check-toml
12+
- id: check-xml
13+
- id: check-yaml
14+
- id: check-symlinks
15+
- id: debug-statements
16+
- id: destroyed-symlinks
17+
- id: check-executables-have-shebangs
18+
- id: end-of-file-fixer
19+
- id: no-commit-to-branch
20+
args: [--branch, main]
21+
- id: detect-private-key
22+
exclude: "fizard/app/services/finapi/openapi/access/api.yaml"
23+
- repo: https://github.com/asottile/pyupgrade
24+
rev: v3.20.0
25+
hooks:
26+
- id: pyupgrade
27+
- repo: https://github.com/adamchainz/django-upgrade
28+
rev: 1.29.0
29+
hooks:
30+
- id: django-upgrade
31+
- repo: https://github.com/hukkin/mdformat
32+
rev: 0.7.22
33+
hooks:
34+
- id: mdformat
35+
additional_dependencies:
36+
- mdformat-ruff
37+
- mdformat-deflist
38+
- mdformat-footnote
39+
- mdformat-gfm
40+
- mdformat-gfm-alerts
41+
- mdformat-tables
42+
- repo: https://github.com/astral-sh/ruff-pre-commit
43+
rev: v0.13.3
44+
hooks:
45+
- id: ruff-check
46+
args: [--fix, --exit-non-zero-on-fix]
47+
- id: ruff-format
48+
- repo: https://github.com/google/yamlfmt
49+
rev: v0.19.0
50+
hooks:
51+
- id: yamlfmt
52+
ci:
53+
autoupdate_schedule: weekly
54+
skip:
55+
- no-commit-to-branch

pyproject.toml

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ test = [
4343
"pytest-django",
4444
"redis",
4545
]
46-
lint = [
47-
"bandit==1.8.6",
48-
"black==25.9.0",
49-
"flake8==7.3.0",
50-
"isort==6.1.0",
51-
"pydocstyle[toml]==6.3.0",
52-
]
5346
dramatiq = [
5447
"django-dramatiq",
5548
]
@@ -102,3 +95,49 @@ skip = ["pictures/_version.py"]
10295

10396
[tool.pydocstyle]
10497
add_ignore = "D1"
98+
99+
[tool.ruff]
100+
src = ["flit_gettext", "tests"]
101+
line-length = 88
102+
indent-width = 4
103+
104+
[tool.ruff.format]
105+
quote-style = "double"
106+
indent-style = "space"
107+
skip-magic-trailing-comma = false
108+
line-ending = "auto"
109+
preview = true
110+
111+
[tool.ruff.lint]
112+
select = [
113+
"D", # pydocstyle
114+
"EXE", # flake8-executable
115+
"F", # pyflakes
116+
"I", # isort
117+
"PT", # flake8-pytest-style
118+
"RET", # flake8-return
119+
"S", # flake8-bandit
120+
"SIM", # flake8-simplify
121+
"UP", # pyupgrade
122+
"W", # pycodestyle warnings
123+
]
124+
125+
ignore = ["D1"]
126+
127+
[tool.ruff.lint.per-file-ignores]
128+
"*/test*.py" = ["S101", "E501", "PT011"]
129+
"*/migrations/*.py" = ["E501"]
130+
131+
[tool.ruff.lint.flake8-pytest-style]
132+
fixture-parentheses = false
133+
mark-parentheses = false
134+
135+
[tool.ruff.lint.isort]
136+
combine-as-imports = true
137+
split-on-trailing-comma = true
138+
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
139+
force-wrap-aliases = true
140+
known-first-party = ["pictures", "tests"]
141+
142+
[tool.ruff.lint.pydocstyle]
143+
convention = "pep257"

0 commit comments

Comments
 (0)