Skip to content

Commit 930fdee

Browse files
Switch to prek from pre-commit (#695)
* Switch to prek from pre-commit * Update away from broken prek version
1 parent 335214b commit 930fdee

File tree

6 files changed

+69
-133
lines changed

6 files changed

+69
-133
lines changed

.github/workflows/check-build-deploy.yaml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
with:
137137
enable-cache: true
138138

139-
- name: Install pre-commit From Locked Dependencies
139+
- name: Install prek From Locked Dependencies
140140
run: uv sync --only-group pre-commit
141141

142142
- id: store-hashed-python-version
@@ -146,27 +146,23 @@ jobs:
146146

147147
- uses: actions/cache@v5
148148
with:
149-
key: pre-commit|${{steps.store-hashed-python-version.outputs.hashed_python_version}}|${{hashFiles('.pre-commit-config.yaml')}}
150-
path: ~/.cache/pre-commit
149+
key: prek|${{steps.store-hashed-python-version.outputs.hashed_python_version}}|${{hashFiles('.pre-commit-config.yaml')}}
150+
path: ~/.cache/prek
151151

152152
- name: Setup pre-commit Environments
153-
run: uv run -- pre-commit install-hooks
153+
run: uv run -- prek install-hooks
154154

155-
- name: Save pre-commit Checks Which Require Skipping
155+
- name: Run prek
156156
run: |
157+
set -o pipefail
157158
if [[ "${{github.event_name}}" == "push" && "${{github.ref_name}}" == "${{github.event.repository.default_branch}}" ]]; then
158-
echo "SKIP=flake8,ruff-check,uv-lock,gitlint-ci" >> "$GITHUB_ENV"
159+
uv run -- prek run --all-files --hook-stage manual --color never --skip ruff-check --skip uv-lock --skip gitlint-ci | tee /tmp/prek.log
159160
else
160-
echo "SKIP=flake8,ruff-check,uv-lock" >> "$GITHUB_ENV"
161+
uv run -- prek run --all-files --hook-stage manual --color never --skip ruff-check --skip uv-lock | tee /tmp/prek.log
161162
fi
162163
163-
- name: Run pre-commit
164-
run: |
165-
set -o pipefail
166-
uv run -- pre-commit run --all-files --hook-stage manual | tee /tmp/pre-commit.log
167-
168164
- name: Ensure No Warnings
169-
run: if grep -q "\[WARNING\]" /tmp/pre-commit.log; then exit 1; fi
165+
run: "if grep -q '^warning: ' /tmp/prek.log; then exit 1; fi"
170166

171167
- if: ${{!cancelled()}}
172168
uses: pre-commit-ci/[email protected]

.pre-commit-config.yaml

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ default_language_version:
44
default_stages: [pre-commit, pre-merge-commit, manual]
55

66
repos:
7+
- repo: https://github.com/tsvikas/sync-with-uv
8+
rev: v0.5.0
9+
hooks:
10+
- id: sync-with-uv
11+
12+
- repo: https://github.com/codespell-project/codespell
13+
rev: v2.4.1
14+
hooks:
15+
- id: codespell
16+
717
- repo: https://github.com/rhysd/actionlint
818
rev: v1.7.9
919
hooks:
@@ -54,31 +64,39 @@ repos:
5464
rev: v8.30.0
5565
hooks:
5666
- id: gitleaks
67+
language_version: ">=1.25.4"
5768

5869
- repo: https://github.com/pre-commit/pre-commit-hooks
5970
rev: v6.0.0
71+
hooks:
72+
- id: check-illegal-windows-names
73+
- id: check-shebang-scripts-are-executable
74+
- id: check-vcs-permalinks
75+
- id: destroyed-symlinks
76+
- id: check-case-conflict
77+
- id: name-tests-test
78+
args: [--pytest-test-first]
79+
files: (?:^|\/)tests\/(?:[^\/]+\/)*(?!_)[^\/]+\.py$ # yamllint disable-line rule:key-ordering
80+
- id: pretty-format-json
81+
args: [--autofix, --indent, "4"]
82+
83+
- repo: builtin
6084
hooks:
6185
- id: check-added-large-files
6286
- id: trailing-whitespace
6387
- id: check-executables-have-shebangs
64-
- id: check-illegal-windows-names
65-
- id: check-shebang-scripts-are-executable
6688
- id: check-json
89+
- id: check-toml
90+
- id: check-yaml
91+
- id: end-of-file-fixer
6792
- id: check-xml
6893
- id: check-symlinks
6994
- id: check-merge-conflict
70-
- id: check-vcs-permalinks
71-
- id: destroyed-symlinks
7295
- id: mixed-line-ending
7396
args: [--fix=lf]
74-
- id: check-case-conflict
7597
- id: detect-private-key
7698
- id: fix-byte-order-marker
7799
args: [-h]
78-
- id: name-tests-test
79-
args: [--pytest-test-first]
80-
- id: pretty-format-json
81-
args: [--autofix, --indent, "4"]
82100

83101
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
84102
rev: v2.15.0
@@ -98,26 +116,12 @@ repos:
98116
- id: uv-lock
99117
always_run: true
100118

101-
- repo: local
119+
- repo: https://github.com/astral-sh/ruff-pre-commit
120+
rev: v0.14.10
102121
hooks:
103122
- id: ruff-check
104123
args: [--fix]
105-
description: Run 'ruff check' for extremely fast Python linting # yamllint disable-line rule:key-ordering
106-
entry: ruff check --force-exclude # yamllint disable-line rule:key-ordering
107-
language: python
108-
minimum_pre_commit_version: 2.9.2
109-
name: ruff check
110-
require_serial: true
111-
types_or: [python, pyi]
112-
113124
- id: ruff-format
114-
description: Run 'ruff format' for extremely fast Python formatting # yamllint disable-line rule:key-ordering
115-
entry: ruff format --force-exclude # yamllint disable-line rule:key-ordering
116-
language: python
117-
minimum_pre_commit_version: 2.9.2
118-
name: ruff format
119-
require_serial: true
120-
types_or: [python, pyi]
121125

122126
- repo: https://github.com/google/yamlfmt
123127
rev: v0.20.0

cogs/committee_actions_tracking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async def _create_action(
8888
)
8989
)
9090
if not error_is_already_exits:
91-
await self.command_send_error(ctx, message="An unrecoverable error occured.")
91+
await self.command_send_error(ctx, message="An unrecoverable error occurred.")
9292
logger.critical("Error upon creating Action object: %s", create_action_error)
9393
await self.bot.close()
9494

cogs/stats/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ async def left_member_stats(self, ctx: "TeXBotApplicationContext") -> None:
317317
await ctx.defer(ephemeral=True)
318318

319319
left_member_counts: dict[str, int] = {
320-
"Total": await LeftDiscordMember.objects.acount()
320+
"Total": await LeftDiscordMember.objects.acount() # codespell:ignore acount
321321
}
322322

323323
role_name: str

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ main = [
2727
"typed_classproperties>=1.2",
2828
"validators>=0.34"
2929
]
30-
pre-commit = ["pre-commit>=4.0", { include-group = "lint-format" }]
30+
pre-commit = ["prek>=0.2,!=0.2.23"]
3131
test = ["pytest>=9", "pytest-cov>=6.1"]
3232
type-check = [
3333
"django-stubs[compatible-mypy]>=5.1",

0 commit comments

Comments
 (0)