From b0f100eb3a77e4c1eae94be5fd05af4664f3cadc Mon Sep 17 00:00:00 2001 From: m-vdb Date: Fri, 14 Jun 2024 13:15:12 +0200 Subject: [PATCH 1/2] reproduce versioning issue with dev releases --- tests/version_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/version_test.py b/tests/version_test.py index 460cb2b..6299cb4 100644 --- a/tests/version_test.py +++ b/tests/version_test.py @@ -27,6 +27,7 @@ def test_copy(): ("2.0.0rc2", "2.0.0"), ("2.0.0b4", "2.0.0"), ("2.0.0b4.post1", "2.0.0"), + ("2.0.0dev1", "2.0.0"), ] @@ -48,6 +49,7 @@ def test_next_major(version_string, expected): ("1.2.0rc2", "1.2.0"), ("1.2.0b4", "1.2.0"), ("1.2.0b4.post1", "1.2.0"), + ("1.2.0dev1", "1.2.0"), ] @@ -70,6 +72,7 @@ def test_next_minor(version_string, expected): ("1.2.0rc2", "1.2.1"), ("1.2.0b4", "1.2.1"), ("1.2.0b4.post1", "1.2.1"), + ("1.2.1dev1", "1.2.1"), ] From 25d414539bae75968ba828273dea807a9c9b88a5 Mon Sep 17 00:00:00 2001 From: m-vdb Date: Fri, 14 Jun 2024 13:18:33 +0200 Subject: [PATCH 2/2] take version.dev into account when bumping versions --- pep440_version_utils/version.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pep440_version_utils/version.py b/pep440_version_utils/version.py index f50ed39..ac2ca8e 100644 --- a/pep440_version_utils/version.py +++ b/pep440_version_utils/version.py @@ -39,7 +39,7 @@ def next_major(self) -> "Version": """ version = copy(self) major = version.major + 1 - if version.pre and not version.minor and not version.micro: + if (version.pre or version.dev) and not version.minor and not version.micro: major = version.major version._version = VersionNamedTuple( epoch=version._version.epoch, @@ -58,7 +58,7 @@ def next_minor(self) -> "Version": """ version = copy(self) minor = version.minor + 1 - if version.pre and not version.micro: + if (version.pre or version.dev) and not version.micro: minor = version.minor version._version = VersionNamedTuple( epoch=version._version.epoch, @@ -77,7 +77,7 @@ def next_micro(self) -> "Version": """ version = copy(self) micro = version.micro + 1 - if version.pre and version.micro > 0: + if (version.pre or version.dev) and version.micro > 0: micro = version.micro version._version = VersionNamedTuple( epoch=version._version.epoch,