Skip to content

Commit d473660

Browse files
feat(dev): use prek instead of pre-commit (#1380)
Signed-off-by: arielle <[email protected]> Co-authored-by: vi <[email protected]>
1 parent 558072d commit d473660

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

.github/workflows/lint-test.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,24 @@ jobs:
114114
115115
lint:
116116
runs-on: ubuntu-latest
117+
env:
118+
RUFF_OUTPUT_FORMAT: github
117119
steps:
120+
118121
- uses: actions/checkout@v4
119122

120-
- name: Cache pre-commit
123+
- name: Cache pip cache
121124
uses: actions/cache@v4
122125
with:
123-
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
126+
key: ${{ runner.os }}-prek-pip-${{ hashFiles('**/pyproject.toml') }}
124127
path: ~/.cache/pip
125128

126-
- name: Run pre-commit
127-
id: pre-commit
128-
uses: pre-commit/[email protected]
129-
env:
130-
RUFF_OUTPUT_FORMAT: github
129+
- name: Run prek
130+
id: prek
131+
uses: j178/[email protected]
132+
# given the interoperability and the nature of prek, we stay unpinned for now
133+
# note that this action by default uses the latest version of prek
134+
# this is exactly how the pre-commit action worked, and we never had any issues
131135

132136
docs:
133137
# unlike the other workflows, we explicitly use the same version as

.pre-commit-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# SPDX-License-Identifier: MIT
22

3-
## Pre-commit setup
4-
53
repos:
64
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
# note that this version is ignored by prek when using the fastpath
76
rev: v5.0.0
87
hooks:
98
- id: check-case-conflict

CONTRIBUTING.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ The following is a set of guidelines for contributing to the repository. These a
88

99
## Table of Contents
1010

11-
- [Table of Contents](#table-of-contents)
12-
- [This is too much to read! I want to ask a question!](#this-is-too-much-to-read-i-want-to-ask-a-question)
13-
- [Good Bug Reports](#good-bug-reports)
14-
- [Creating a Pull Request](#creating-a-pull-request)
15-
- [Overview](#overview)
16-
- [Initial setup](#initial-setup)
17-
- [Commit/PR Naming Guidelines](#commitpr-naming-guidelines)
18-
- [Formatting](#formatting)
19-
- [Pyright](#pyright)
20-
- [Changelogs](#changelogs)
21-
- [Documentation](#documentation)
22-
- [Migrating development environments](#migrating-development-environments)
23-
- [Migrating from `pdm` to `uv`](#migrating-from-pdm-to-uv)
24-
- [Migrating `pdm`'s scripts to `nox`](#migrating-pdms-scripts-to-nox)
11+
- [Contributing to disnake](#contributing-to-disnake)
12+
- [Table of Contents](#table-of-contents)
13+
- [This is too much to read! I want to ask a question!](#this-is-too-much-to-read-i-want-to-ask-a-question)
14+
- [Good Bug Reports](#good-bug-reports)
15+
- [Creating a Pull Request](#creating-a-pull-request)
16+
- [Overview](#overview)
17+
- [Initial setup](#initial-setup)
18+
- [Commit/PR Naming Guidelines](#commitpr-naming-guidelines)
19+
- [Formatting](#formatting)
20+
- [Pyright](#pyright)
21+
- [Changelogs](#changelogs)
22+
- [Documentation](#documentation)
23+
- [Migrating development environments](#migrating-development-environments)
24+
- [Migrating from `pdm` to `uv`](#migrating-from-pdm-to-uv)
25+
- [Migrating `pdm`'s scripts to `nox`](#migrating-pdms-scripts-to-nox)
2526

2627
## This is too much to read! I want to ask a question!
2728

@@ -83,7 +84,7 @@ This will:
8384
- create `uv.lock`
8485
- create a venv at `.venv`
8586
- install all dependencies to `.venv`
86-
- install pre-commit hooks at `.git/hooks/pre-commit`
87+
- install pre-commit hooks (via prek) at `.git/hooks/pre-commit`
8788

8889
Other tools used in this project include [ruff](https://docs.astral.sh/ruff) (formatter and linter), and [pyright](https://microsoft.github.io/pyright/#/) (type-checker). For the most part, these automatically run on every commit with no additional action required - see below for details.
8990

@@ -113,9 +114,9 @@ Details about the specific commit types can be found on the [conventional commit
113114

114115
This project follows PEP-8 guidelines (mostly) with a column limit of 100 characters, and uses the tools mentioned above to enforce a consistent coding style.
115116

116-
The installed [`pre-commit`](https://pre-commit.com/) hooks will automatically run before every commit, which will format/lint the code
117+
The installed [`prek`](https://github.com/j178/prek) hooks will automatically run before every commit, which will format/lint the code
117118
to match the project's style. Note that you will have to stage and commit again if anything was updated!
118-
Most of the time, running pre-commit will automatically fix any issues that arise.
119+
Most of the time, running prek will automatically fix any issues that arise.
119120

120121
### Pyright
121122

@@ -182,4 +183,4 @@ $ nox -s dev
182183
```
183184

184185
> [!TIP]
185-
> To provide arguments to the selected sessions with `nox`, pass them **after** `--`. For example, to tell `pre-commit` to only run `ruff format`, run `nox -s lint -- ruff-format`.
186+
> To provide arguments to the selected sessions with `nox`, pass them **after** `--`. For example, to tell `prek` to only run `ruff format`, run `nox -s lint -- ruff-format`.

noxfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def docs(session: nox.Session) -> None:
247247
def lint(session: nox.Session) -> None:
248248
"""Check all paths for linting errors"""
249249
install_deps(session)
250-
session.run("pre-commit", "run", "--all-files", *session.posargs)
250+
session.run("prek", "run", "--all-files", *session.posargs)
251251

252252

253253
@nox.session(name="check-manifest")
@@ -466,12 +466,12 @@ def dev(session: nox.Session) -> None:
466466
- lock all dependencies with pdm
467467
- create a .venv/ directory, overwriting the existing one,
468468
- install all dependencies needed for development.
469-
- install the pre-commit hook
469+
- install the pre-commit hook (prek)
470470
"""
471471
session.run("uv", "lock", external=True)
472472
session.run("uv", "venv", "--clear", external=True)
473473
session.run("uv", "sync", "--all-extras", "--all-groups", external=True)
474-
session.run("uv", "run", "pre-commit", "install", external=True)
474+
session.run("uv", "run", "prek", "install", "--overwrite", external=True)
475475

476476

477477
if __name__ == "__main__":

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ ruff = [
8585
"ruff==0.13.0",
8686
]
8787
tools = [
88-
"pre-commit~=3.0",
88+
"prek>=0.2.0",
8989
"slotscheck~=0.16.4",
9090
"check-manifest==0.49",
9191
{ include-group = "ruff" },

0 commit comments

Comments
 (0)