Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com>
  • Loading branch information
Learloj and tomschr committed Jan 28, 2025
commit cfff984d0167695a96d1046c13b7c2b0daeccfce
9 changes: 4 additions & 5 deletions docs/usage/raise-parts-of-a-version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Raising Parts of a Version
For example, having version ``1.0.0`` and raising the pre-release
will lead to ``1.0.0-rc.1``, but ``1.0.0-rc.1`` is smaller than ``1.0.0``.

You can work around this by supplying the `bump_when_empty=true` argument to the
To avoid this, set `bump_when_empty=True` in the
:meth:`~semver.version.Version.bump_prerelease` method, or by using the
method :meth:`~semver.version.Version.next_version`
in section :ref:`increase-parts-of-a-version`.
Expand Down Expand Up @@ -68,10 +68,9 @@ is not taken into account:
>>> str(Version.parse("3.4.5-rc.1").bump_prerelease(''))
'3.4.5-rc.2'

If the last part of the existing prerelease, split by dots (`.`), is not numeric,
we will add `.0` to ensure the new prerelease is higher than the previous one
(otherwise, raising `rc9` to `rc10` would result in a lower version, as non-numeric
parts are sorted alphabetically):
To ensure correct ordering, we append `.0` to the last prerelease identifier
if it's not numeric. This prevents cases where `rc9` would incorrectly sort
lower than `rc10` (non-numeric identifiers are compared alphabetically):

.. code-block:: python

Expand Down
2 changes: 1 addition & 1 deletion src/semver/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def bump_prerelease(
Raise the prerelease part of the version, return a new object but leave
self untouched.

.. versionchanged:: VERSION
.. versionchanged:: 3.1.0
Parameter `bump_when_empty` added. When set to true, bumps the patch version
when called with a version that has no prerelease segment, so the return
value will be considered a newer version.
Expand Down