Skip to content

Drop build metadata when bumping an old-style prerelease - #486

Merged
tomschr merged 2 commits into
python-semver:masterfrom
youdie006:next-version-old-style-build
Sep 26, 2026
Merged

tomschr merged 2 commits into
python-semver:masterfrom
youdie006:next-version-old-style-build

Conversation

@youdie006

Copy link
Copy Markdown
Contributor

next_version("prerelease") drops the build metadata on every path except the old-style one added in #485:

Version.parse("1.2.3-rc.3+build.5").next_version("prerelease")  # 1.2.3-rc.4
Version.parse("1.2.3-rc3+build.5").next_version("prerelease")   # 1.2.3-rc4+build.5

The token-change branch right below it already passes build=None, and tests/test_parsing.py pins build being dropped for the dot form (("1.2.3-rc.1+build.5", "prerelease", "1.2.3-rc.2")). This adds build=None to the old-style branch, a matching table row, and a test in tests/test_issue484.py.

Verification

Base 8c0a3f7.

row version.py md5 test_parsing.py + test_issue484.py
master 4caab6b242 2 failed (the new row and test_issue_484_old_style_drops_build)
this PR 0ec9530375 48 passed
num + 2 instead of num + 1 0d7332a0 4 failed, including the existing rc3_to_rc4 and rc9_to_rc10
build="" instead of build=None 9bbb4881 1 failed (.build is None)

Following python-testing.yml: uv sync --all-extras --dev, uv pip install tox tox-gh-actions, uv run tox run -e 3.12 gives 445 passed, 1 skipped (3.10 and 3.14 also pass). ruff check reports the same 156 findings by rule on master and on this branch. Not run: macOS, 3.11, 3.13, 3.15.

Written with AI assistance (Claude); the measurements above were run locally and I have reviewed the change.

next_version("prerelease") drops the build on every path except the
old-style one added in python-semver#485: 1.2.3-rc.3+build.5 becomes 1.2.3-rc.4, but
1.2.3-rc3+build.5 became 1.2.3-rc4+build.5. Pass build=None there as the
token-change branch below it already does.

@tomschr tomschr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @youdie006! 👍 Looks good.

@tomschr
tomschr merged commit 887d057 into python-semver:master Sep 26, 2026
17 checks passed
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.

2 participants