Skip to content

Commit b872532

Browse files
authored
chore: add uv-lock --check pre-commit hook and dependency-update guidance (#1408)
## Summary - Add `uv-lock --check` pre-commit hook — fails when `pyproject.toml` and `uv.lock` drift. - Add a dependency-update section to `AGENTS.md` covering a case `--check` doesn't catch. ## Test plan - [x] Clean tree → `pre-commit run --all-files` passes. - [x] Mutate `pyproject.toml` without updating lockfile → hook fails. - [x] Revert → passes.
1 parent 59c69f6 commit b872532

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ repos:
1414
hooks:
1515
- id: mypy
1616
additional_dependencies: [types-requests]
17+
18+
- repo: https://github.com/astral-sh/uv-pre-commit
19+
rev: 0.11.6
20+
hooks:
21+
- id: uv-lock
22+
args: [--check]

AGENTS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,20 @@ Models can be configured with Databricks-specific options:
362362
3. Add validation logic if needed
363363
4. Write tests for both valid and invalid configurations
364364

365+
### Updating Dependencies (`pyproject.toml` / `uv.lock`)
366+
367+
`uv.lock` pins the exact version CI tests against. Version bounds in `pyproject.toml` are independent of the pinned version — a loosened upper bound does NOT auto-bump the pinned version.
368+
369+
**When changing a version bound in `pyproject.toml`:**
370+
371+
1. Run `uv lock --upgrade-package <name>` to pick up the newest allowed version of that package (targeted, not a full resolve).
372+
2. Inspect the `uv.lock` diff — confirm the pinned version now matches the version you actually want to test against.
373+
3. Commit both `pyproject.toml` and `uv.lock` in the same commit.
374+
375+
**Why this matters:** a pre-commit hook runs `uv lock --check` and catches pyproject↔lock *inconsistency*, but it does NOT force pinned versions forward. If the previously pinned version still satisfies the new bound (e.g. raised `<4.1.4` to `<4.1.6` while `4.1.3` is already pinned), the lock stays consistent and CI keeps testing the old version — the whole point of the bound change is lost. Always run the targeted upgrade explicitly.
376+
377+
**Adding a new dependency:** `uv add <name>` updates both files; no separate lock step needed.
378+
365379
## 🐛 Debugging Guide
366380

367381
### Common Issues

0 commit comments

Comments
 (0)