Repository navigation
Conversation
bump_version.py also rewrites this package's entry in uv.lock, so CI can install with uv sync --locked. The versioning job runs uv lock --check before committing. Tests cover the rewrite with Hypothesis properties, examples and a differential check against the real lock. Part of #2128. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99c9202 to
96a8a90
Compare
On a loaded runner Hypothesis can take over a second to draw the first set of unique package names and fails the too_slow health check, which says nothing about the rewrite under test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lock is now updated before pyproject.toml, a missing lock is an error, and only the editable project entry is rewritten. New tests run the real script on a scratch repository: both files move together, and a missing lock or a lock without this package leaves both unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Coordination note from #2324 (untyped changelog fragments, #2314), which also edits Merging the two gives one conflict, in One of your tests then fails. #2324 makes (tmp_path / "pyproject.toml").write_text(
- f'[project]\nname = "{PACKAGE}"\nversion = "1.2.3"\n'
+ f'[project]\nname = "{PACKAGE}"\nversion = "1.2.3"\n\n'
+ '[tool.towncrier]\ndirectory = "changelog.d"\n\n'
+ '[[tool.towncrier.type]]\ndirectory = "fixed"\nname = "Fixed"\n'
)On a local merge of both branches with that change, all 56 tests in 🤖 Generated with Claude Code |
Part of #2128 (step 1 of 2).
What this does
uv.lockrecords this package's own version. The versioning workflow bumpspyproject.tomlbut not the lock, so the lock has drifted: 2.125.1 against 2.126.2 on main (2026-10-10; it was 2.109.5 against 2.113.0 when this PR opened).uv sync --lockedrejects a lock in that state. The follow-up PR moves CI touv sync --locked, so the lock has to stay in step withpyproject.toml..github/bump_version.pynow also rewrites the[[package]] name = "policyengine-uk"entry'sversioninuv.lock, and only when that entry is the editable project (source = { editable = "." }). It touches that one line and nothing else. It updates the lock beforepyproject.toml, so if the lock is missing, or has no such entry or more than one, it exits non-zero before changing either file.versioning.yamlrunsuv lock --checkafter the bump and before committing, so the versioning job refuses to push its release commit with a lock thatuv sync --lockedwould reject. (A PR can still merge a dependency change withoutuv lock; the follow-up's--lockedCI is what stops that.)uv.lock. The first version bump after merge fixes main's stale line. Editing that line here would race main's own bumps, which land on almost every merge.PR CI is unchanged here, and so is the Publish job. Publish builds with
python -m buildin an isolated environment, so the lock doesn't affect release artifacts.Invariants (tested)
For any lock text containing exactly one entry for this package,
set_lock_version(text, pkg, v):v;policyengine-uk-data);These are checked by
policyengine_uk/tests/code_health/test_version_bump.py:uv.lock, which compares the regex rewrite with atomllibparse;The tests also fail on each of these mutations: a naive find-and-replace; a rewrite that leaves the lock stale; dropping
main()'supdate_lockcall; writingpyproject.tomlbefore the lock; dropping the editable-entry check.Verified locally
uv lock --checkpasses on uv 0.10.0, 0.11.7, 0.12.13 and 0.12.23 (latest, verified on PyPI).bump_version.pyon a copy of the repo bumps 2.113.0 → 2.113.1 in both files, anduv lock --checkpasses afterwards.Review: GPT-6.1 Sol, APPROVE, no must-fix (
~/reviews/uk-weekly-uv-lock/review-2129.md); its three nits are addressed in d75ce69.Re-verified 2026-10-10, after merging main (3173baa)
uv lock --checkpasses on main's lock under uv 0.13.0 (latest, per the astral-sh/uv releases API).bump_version.pyon the merged branch bumps 2.126.2 → 2.126.3 inpyproject.tomland in the lock's own entry (one line), anduv lock --checkpasses afterwards.test_version_bump.py: 9 passed (5 at first, then the 4 added after review), repeated runs. One property test had failed Hypothesis'stoo_slowhealth check on this loaded host (input generation, not the rewrite), so it now suppresses that check (16e9eee).axiom: n/a: CI and release tooling only
🤖 Generated with Claude Code
Reproducer:
policyengine_uk/tests/code_health/test_version_bump.py::test_rewriting_the_real_lock_changes_only_this_package,policyengine_uk/tests/code_health/test_version_bump.py::test_a_dependency_sharing_the_old_version_is_left_alone,policyengine_uk/tests/code_health/test_version_bump.py::test_a_missing_or_repeated_entry_is_an_error,policyengine_uk/tests/code_health/test_version_bump.py::test_rewrite_sets_only_this_package_and_is_idempotent,policyengine_uk/tests/code_health/test_version_bump.py::test_main_moves_pyproject_and_lock_together,policyengine_uk/tests/code_health/test_version_bump.py::test_main_stops_before_changing_anything