Repository navigation
fix(util): keep the pre-release segment when bumping a dev counter - #2461
Conversation
|
Cross-review (different model, adversarial) came back NEEDS CHANGES. The rc/a/b fix is correct and verified — but the same bug remains for post-releases: Fix: carry the post segment through the same way the pre segment now is. Also flagged: the fixed docstring only mentions dropping Dispatching a fix to this branch now. |
…ersion.py bumps a dev counter (#2459) `bump()` reconstructed a dev-release bump from `base_version` plus the new `devN`, so a version carrying a pre-release and/or post-release segment alongside its dev segment lost that segment on bump: `1.6.0rc1.dev2` -> `1.6.0.dev3`, and `1.6.0.post1.dev0` -> `1.6.0.dev1`. Under PEP 440 a bare dev release sorts *before* one carrying `rc1` or `post1`, so each "bumped" version compared as older than the one it replaced -- a real ordering regression, not a cosmetic string loss. `is_devrelease` is true whenever `dev` is set, regardless of `pre` or `post`, so that branch now rebuilds both segments from `ver_obj.pre` and `ver_obj.post` before appending the dev counter, giving `1.6.0rc1.dev3` and `1.6.0.post1.dev1` respectively (and both together for `1.6.0rc1.post1.dev2` -> `1.6.0rc1.post1.dev3`). The pre-release-only and post-release-only branches are untouched. Added tests for the post-dev and pre+post+dev cases, plus a looped test sweeping plain/pre/post/pre+post dev versions with and without an epoch, each asserting the bump sorts after its input. `pytest tests/project/test_bump_version.py` passes (37 passed, 1 skipped, 16 subtests); all new cases confirmed to fail against the pre-fix code. pylint and mypy add no new findings over the file's existing baseline.
8340965 to
8e09acc
Compare
|
Fixed and verified directly (new head |
|
Cross-review (different model, adversarial) came back GOOD TO GO. Verified the fix over an exhaustive 53,760-input grid (epoch × release × pre × post × dev × local-label combinations) with zero ordering regressions, and confirmed the grid itself is valid by reproducing 53,280 regressions against pre-fix |
|
Coverage: 94.44% (unit tier, Python 3.15,
Per-file detail: the |
make pylint,make mypy,make isort)make testpasses, and a test case covers the changedocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A, centralised per docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
bump()inutil/bump_version.pyrebuilt a dev-release bump frombase_versionplus the incrementeddevN, dropping any pre-release segment:bump('1.6.0rc1.dev2')returned'1.6.0.dev3'.Version.is_devreleaseis truewhenever
devis set regardless ofpre, so that branch ran even when apre-release tag was present and never looked at it.
That is a real ordering regression, not just a lost string: under PEP 440 a bare
dev release (
1.6.0.dev3) sorts before one carryingrc1(
1.6.0rc1.dev2), so the "bumped" version compared as older than the version itwas bumped from.
Fix: when
is_devreleaseis true, rebuild the pre-release segment fromver_obj.pre(when set) before appending.devN, giving1.6.0rc1.dev3. Thepre-release-only and post-release branches are unchanged, as is the no-pre-release
dev case (
1.5.0.dev1->1.5.0.dev2).Added tests to
tests/project/test_bump_version.pycoveringrc/a/bsegmentson a dev bump, parsing the result back with
packaging.version.Versionto assert.preand.dev, and asserting the fixed ordering against the pre-fix version.Confirmed both new cases fail against the old code before the fix.
Closes #2459