Skip to content

Commit e373ebd

Browse files
authored
pre-commit uv lock check (#2932)
<!-- Thanks for opening a pull request! --> <!-- In the case this PR will resolve an issue, please replace ${GITHUB_ISSUE_ID} below with the actual Github issue id. --> <!-- Closes #${GITHUB_ISSUE_ID} --> # Rationale for this change In #2928, the `uv.lock` wasn't generated correctly after a dependency change. Adding the following changes: 1. `make uv-lock` to generate one when modifying dependencies 2. `make uv-lock-check` to check if the `uv.lock` is up to date 3. Adding a pre-commit config to check the `uv.lock` and fail if not updated correctly (uses 2.) 4. Documentation change in `mkdocs/docs/contributing.md` to add instructions for contributors. ## Are these changes tested? Locally. Added some of the dependencies in #2928 without modifying the lock file and ran `pre-commit run --all-files` to observe the following failure message ``` uv lock file check.......................................................Failed - hook id: uv-lock-check - exit code: 2 uv lock --check Resolved 221 packages in 93ms The lockfile at `uv.lock` needs to be updated, but `--check` was provided. To update the lockfile, run `uv lock`. make: *** [uv-lock-check] Error 1 ``` ## Are there any user-facing changes? No. Useful for contributions that change versions/ dependencies.
1 parent 7dd25a6 commit e373ebd

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@ repos:
7070
rev: v2.4.1
7171
hooks:
7272
- id: codespell
73+
- repo: local
74+
hooks:
75+
- id: uv-lock-check
76+
name: uv lock file check
77+
entry: make uv-lock-check
78+
language: system
79+
pass_filenames: false
80+
files: ^(pyproject\.toml|uv\.lock)$

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,11 @@ clean: ## Remove build artifacts and caches
168168
@find . -name "*.pyd" -exec echo Deleting {} \; -delete
169169
@find . -name "*.pyo" -exec echo Deleting {} \; -delete
170170
@echo "Cleanup complete."
171+
172+
uv-lock: ## Regenerate uv.lock file from pyproject.toml
173+
uv lock $(PYTHON_ARG)
174+
175+
uv-lock-check: ## Verify uv.lock is up to date
176+
@command -v uv >/dev/null || \
177+
(echo "uv is required. Run 'make install' or 'make install-uv' first." && exit 1)
178+
uv lock --check $(PYTHON_ARG)

mkdocs/docs/contributing.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ For full control over your environment, you can use uv commands directly. See th
9090
- Running commands with `uv run`
9191
- Lock file management with `uv.lock`
9292

93+
### Lock File Management
94+
95+
`uv.lock` is a cross-platform lockfile that contains exact information about the project's dependencies.
96+
See the [uv.lock documentation](https://docs.astral.sh/uv/guides/projects/#uvlock) for more details.
97+
98+
When modifying dependencies in `pyproject.toml`, regenerate the lock file:
99+
100+
```bash
101+
make uv-lock
102+
```
103+
104+
Separately, to verify that the lock file is up to date without modifying it:
105+
106+
```bash
107+
make uv-lock-check
108+
```
109+
93110
## Installation from source
94111

95112
Clone the repository for local development:

0 commit comments

Comments
 (0)