Skip to content

PEP440 Version output changes between test and update #221

@wordsworthc

Description

@wordsworthc

I noticed that running bumpver test ... produces a different pep440_version output than when running bumpver update ....

Consider the following version patterns: vMAJOR.MINOR.PATCH[-PYTAGNUM], and vMAJOR.MINOR.PATCH[+localINC0], each has a very different meaning according to pep 440.

In all of my examples below I use these file patterns in my pyproject.toml:

[tool.bumpver.file_patterns]
"pyproject.toml" = [
    'version = "{pep440_version}"',
    'current_version = "{version}"',
]

vMAJOR.MINOR.PATCH[-PYTAGNUM]

Testing the above pattern with bumpver I get:

(venv) PS D:\dev\my-project> bumpver test "v1.0.0" "vMAJOR.MINOR.PATCH[-PYTAGNUM]" --tag-num --tag post
New Version: v1.0.0-post0
PEP440     : 1.0.0.post0

As expected, the PEP440 output is a pep440-compliant post-version: 1.0.0.post0. However, when I try the update command:

(venv) PS D:\dev\my-project> bumpver update --no-fetch --ignore-vcs-tag --tag-num --tag post --dry
INFO    - Old Version: v1.0.0
INFO    - New Version: v1.0.0-post0
--- pyproject.toml
+++ pyproject.toml
@@ -4,7 +4,7 @@

 [project]
 name = "my-project"
-version = "1.0.0"
+version = "1.0.0post0"
 dynamic = ["readme", "dependencies"]


@@ -32,7 +32,7 @@


 [tool.bumpver]
-current_version = "v1.0.0"
+current_version = "v1.0.0-post0"
 version_pattern = "vMAJOR.MINOR.PATCH[-PYTAGNUM]"
 commit = "True"
 tag = "True"

Notably, the pep440_version output is different (Although it is still pep440-compliant), resulting in the version 1.0.0post0.

vMAJOR.MINOR.PATCH[+localINC0]

Testing this pattern with bumpver I get:

(venv) PS D:\dev\my-project> bumpver test "v1.0.0" "vMAJOR.MINOR.PATCH[+localINC0]"
New Version: v1.0.0+local1
PEP440     : 1.0.0+local1

This time, as expected, the PEP440 output is a pep440-compliant local version. Now for bumpver update ...:

(venv) PS D:\dev\my-project> bumpver update --no-fetch --ignore-vcs-tag --dry
INFO    - Old Version: v1.0.0
INFO    - New Version: v1.0.0+local1
--- pyproject.toml
+++ pyproject.toml
@@ -4,7 +4,7 @@

 [project]
 name = "my-project"
-version = "1.0.0"
+version = "1.0.0local1"
 dynamic = ["readme", "dependencies"]


@@ -32,7 +32,7 @@


 [tool.bumpver]
-current_version = "v1.0.0"
+current_version = "v1.0.0+local1"
 version_pattern = "vMAJOR.MINOR.PATCH[+localINC0]"
 commit = "True"
 tag = "True"

Herein lies the true nature of this issue - even though I have specifically configured bumpver to provide local versions (and used bumpver test ... to make sure it would work), the end result is not pep440-compliant.

Expected Behaviour

Although I am not too heavily invested in the final resolution, it is my opinion that the current bumpver test output best matches expectations in the examples provided.

Environment

Tested in Python 3.10.6 and Python 3.11.3. Both environments use the same package versions:

(venv) PS D:\dev\my-project> pip freeze
bumpver==2023.1126
click==8.1.7
colorama==0.4.6
lexid==2021.1006
looseversion==1.3.0
toml==0.10.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions