Skip to content

Commit aba7d76

Browse files
zzstoatzzclaudejlowin
authored
switch from pre-commit to prek (#2309)
* switch from pre-commit to prek 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix prek tools list in contributing.mdx - include prettier, not pytest * Use prek-action for caching --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Jeremiah Lowin <[email protected]>
1 parent bbf3050 commit aba7d76

File tree

6 files changed

+47
-96
lines changed

6 files changed

+47
-96
lines changed

.github/workflows/run-static.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
exit 1
4949
fi
5050
echo "✅ Lockfile is up to date"
51-
- name: Run pre-commit
52-
run: uv run pre-commit run --all-files
51+
- name: Run prek
52+
uses: j178/prek-action@v1
5353
env:
5454
SKIP: no-commit-to-branch

AGENTS.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ FastMCP is a comprehensive Python framework (Python ≥3.10) for building Model
1010

1111
```bash
1212
uv sync # Install dependencies
13-
uv run pre-commit run --all-files # Ruff + Prettier + ty
13+
uv run prek run --all-files # Ruff + Prettier + ty
1414
uv run pytest # Run full test suite
1515
```
1616

@@ -100,12 +100,12 @@ async with Client(transport=StreamableHttpTransport(server_url)) as client:
100100

101101
### Git & CI
102102

103-
- Pre-commit hooks are required (run automatically on commits)
104-
- Never amend commits to fix pre-commit failures
103+
- Prek hooks are required (run automatically on commits)
104+
- Never amend commits to fix prek failures
105105
- Apply PR labels: bugs/breaking/enhancements/features
106106
- Improvements = enhancements (not features) unless specified
107107
- **NEVER** force-push on collaborative repos
108-
- **ALWAYS** run pre-commit before PRs
108+
- **ALWAYS** run prek before PRs
109109

110110
### Commit Messages and Agent Attribution
111111

@@ -217,7 +217,7 @@ If something needs work, your review should help it get there through specific,
217217

218218
Before approving, verify:
219219

220-
- [ ] All required development workflow steps completed (uv sync, pre-commit, pytest)
220+
- [ ] All required development workflow steps completed (uv sync, prek, pytest)
221221
- [ ] Changes align with repository patterns and conventions
222222
- [ ] API changes are documented and backwards-compatible where possible
223223
- [ ] Error handling follows project patterns (specific exception types)
@@ -237,7 +237,7 @@ uv sync # Installs all deps including dev tools
237237

238238
- **Linting**: `uv run ruff check` (or with `--fix`)
239239
- **Type Checking**: `uv run ty check`
240-
- **All Checks**: `uv run pre-commit run --all-files`
240+
- **All Checks**: `uv run prek run --all-files`
241241

242242
### Testing
243243

@@ -260,6 +260,6 @@ uv sync # Installs all deps including dev tools
260260
### Build Issues (Common Solutions)
261261

262262
1. **Dependencies**: Always `uv sync` first
263-
2. **Pre-commit fails**: Run `uv run pre-commit run --all-files` to see failures
263+
2. **Prek fails**: Run `uv run prek run --all-files` to see failures
264264
3. **Type errors**: Use `uv run ty check` directly, check `pyproject.toml` config
265265
4. **Test timeouts**: Default 5s - optimize or mark as integration tests

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,28 +481,28 @@ uv run pytest --cov=src --cov=examples --cov-report=html
481481

482482
### Static Checks
483483

484-
FastMCP uses `pre-commit` for code formatting, linting, and type-checking. All PRs must pass these checks (they run automatically in CI).
484+
FastMCP uses `prek` for code formatting, linting, and type-checking. All PRs must pass these checks (they run automatically in CI).
485485

486486
Install the hooks locally:
487487

488488
```bash
489-
uv run pre-commit install
489+
uv run prek install
490490
```
491491

492492
The hooks will now run automatically on `git commit`. You can also run them manually at any time:
493493

494494
```bash
495-
pre-commit run --all-files
495+
prek run --all-files
496496
# or via uv
497-
uv run pre-commit run --all-files
497+
uv run prek run --all-files
498498
```
499499

500500
### Pull Requests
501501

502502
1. Fork the repository on GitHub.
503503
2. Create a feature branch from `main`.
504504
3. Make your changes, including tests and documentation updates.
505-
4. Ensure tests and pre-commit hooks pass.
505+
4. Ensure tests and prek hooks pass.
506506
5. Commit your changes and push to your fork.
507507
6. Open a pull request against the `main` branch of `jlowin/fastmcp`.
508508

docs/development/contributing.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ cd fastmcp
4949
# Install all dependencies including dev tools
5050
uv sync
5151

52-
# Install pre-commit hooks
53-
uv run pre-commit install
52+
# Install prek hooks
53+
uv run prek install
5454
```
5555

5656
In addition, some development commands require [just](https://github.com/casey/just) to be installed.
5757

58-
Pre-commit hooks will run automatically on every commit to catch issues before they reach CI. If you see failures, fix them before committing - never commit broken code expecting to fix it later.
58+
Prek hooks will run automatically on every commit to catch issues before they reach CI. If you see failures, fix them before committing - never commit broken code expecting to fix it later.
5959

6060
### Development Standards
6161

@@ -100,19 +100,19 @@ The focus is on idiomatic, high-quality Python. FastMCP uses patterns like `NotS
100100

101101
**Breaking established patterns** confuses readers. If you must deviate, discuss in the issue first.
102102

103-
### Pre-Commit Checks
103+
### Prek Checks
104104

105105
```bash
106106
# Runs automatically on commit, or manually:
107-
uv run pre-commit run --all-files
107+
uv run prek run --all-files
108108
```
109109

110110
This runs three critical tools:
111111
- **Ruff**: Linting and formatting
112-
- **ty**: Static type checking
113-
- **Pytest**: Core test suite
112+
- **Prettier**: Code formatting
113+
- **ty**: Static type checking
114114

115-
CI will reject PRs that fail these checks. Always run them locally first.
115+
Pytest runs separately as a distinct workflow step after prek checks pass. CI will reject PRs that fail these checks. Always run them locally first.
116116

117117
### Testing
118118

@@ -155,7 +155,7 @@ just api-ref-all
155155

156156
#### Before Submitting
157157

158-
1. **Run all checks**: `uv run pre-commit run --all-files && uv run pytest`
158+
1. **Run all checks**: `uv run prek run --all-files && uv run pytest`
159159
2. **Keep scope small**: One feature or fix per PR
160160
3. **Write clear description**: Your PR description becomes permanent documentation
161161
4. **Update docs**: Include documentation for API changes

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ dev = [
5757
"inline-snapshot[dirty-equals]>=0.27.2",
5858
"ipython>=8.12.3",
5959
"pdbpp>=0.10.3",
60-
"pre-commit",
6160
"psutil",
6261
"pyinstrument>=5.0.2",
6362
"pyperclip>=1.9.0",
@@ -73,6 +72,7 @@ dev = [
7372
"pytest-xdist>=3.6.1",
7473
"ruff",
7574
"ty>=0.0.1a19",
75+
"prek>=0.2.12",
7676
]
7777

7878
[project.scripts]

uv.lock

Lines changed: 23 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)