Skip to content

Commit cfff984

Browse files
Learlojtomschr
andcommitted
Apply suggestions from code review
Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com>
1 parent 7bb3160 commit cfff984

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

docs/usage/raise-parts-of-a-version.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Raising Parts of a Version
99
For example, having version ``1.0.0`` and raising the pre-release
1010
will lead to ``1.0.0-rc.1``, but ``1.0.0-rc.1`` is smaller than ``1.0.0``.
1111

12-
You can work around this by supplying the `bump_when_empty=true` argument to the
12+
To avoid this, set `bump_when_empty=True` in the
1313
:meth:`~semver.version.Version.bump_prerelease` method, or by using the
1414
method :meth:`~semver.version.Version.next_version`
1515
in section :ref:`increase-parts-of-a-version`.
@@ -68,10 +68,9 @@ is not taken into account:
6868
>>> str(Version.parse("3.4.5-rc.1").bump_prerelease(''))
6969
'3.4.5-rc.2'
7070
71-
If the last part of the existing prerelease, split by dots (`.`), is not numeric,
72-
we will add `.0` to ensure the new prerelease is higher than the previous one
73-
(otherwise, raising `rc9` to `rc10` would result in a lower version, as non-numeric
74-
parts are sorted alphabetically):
71+
To ensure correct ordering, we append `.0` to the last prerelease identifier
72+
if it's not numeric. This prevents cases where `rc9` would incorrectly sort
73+
lower than `rc10` (non-numeric identifiers are compared alphabetically):
7574

7675
.. code-block:: python
7776

src/semver/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def bump_prerelease(
334334
Raise the prerelease part of the version, return a new object but leave
335335
self untouched.
336336
337-
.. versionchanged:: VERSION
337+
.. versionchanged:: 3.1.0
338338
Parameter `bump_when_empty` added. When set to true, bumps the patch version
339339
when called with a version that has no prerelease segment, so the return
340340
value will be considered a newer version.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy