Skip to content

Preserve version order when legacy prerelease counters roll over - #500

Open
pabszero wants to merge 3 commits into
python-semver:masterfrom
pabszero:fix-legacy-prerelease-order
Open

pabszero wants to merge 3 commits into
python-semver:masterfrom
pabszero:fix-legacy-prerelease-order

Conversation

@pabszero

Copy link
Copy Markdown

Version.parse("1.2.3-rc9").next_version("prerelease") returns 1.2.3-rc10, which is older under SemVer's lexical prerelease ordering. That contradicts next_version's ordering guarantee and can make an automated release increment move backwards.

Check the candidate in the same-token legacy-counter branch. If it would not be newer, advance the patch while retaining the incremented legacy counter: 1.2.3-rc9 becomes 1.2.4-rc10. Ordinary increments, dotted numeric counters and already-forward leading-zero transitions retain their existing patch. Build metadata is cleared, subclasses are preserved and the input stays unchanged.

Fixes #499. This applies the patch-advance precedent from #498 to the separate legacy return path. It deliberately updates test_issue_484_rc9_to_rc10, whose old expectation pinned the backwards result, and documents that behavior in the method and news fragment. Open #494/#496 address long-identifier conversion limits and are outside this patch.

Validation on Windows:

  • Original implementation with the new regressions: 8 failed, 5 controls passed.
  • Original full suite: 498 passed, 1 skipped.
  • Fixed full suite, including doctests: 511 passed, 1 skipped on CPython 3.12.14 and 3.13.5; 100% statement and branch coverage. The skip concerns the absent optional native parser.
  • Ruff 0.15.9 reports the same 159 existing findings on both trees, with no new diagnostics. The new test file passes format check and git diff --check passes. The repository-wide lint is not claimed clean.

This Windows Git checkout materializes two pre-existing test symlinks as target-name text. Validation ran in a separate source copy with those two files resolved to the exact documented source bytes; neither workaround is included in the PR. Other platforms/interpreters and the native backend have not been exercised locally.

Found by code inspection and prepared with OpenAI Codex assistance. No production incident or independent human review is claimed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

next_version returns an older version when a legacy prerelease counter rolls over

1 participant