Skip to content

Commit

Permalink
Format short version for alpha, beta and rc according to PEP 440
Browse files Browse the repository at this point in the history
This omits the dot before the version identifier. Avoids setuptools warning about version normalization for alpha, beta and rc versions.

Note that it is still ".dev1", this is also according to PEP 440.
  • Loading branch information
phw committed Dec 16, 2019
1 parent ac171c1 commit aa372fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion picard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
PICARD_DISPLAY_NAME = "MusicBrainz Picard"
PICARD_APP_ID = "org.musicbrainz.Picard"
PICARD_DESKTOP_NAME = PICARD_APP_ID + ".desktop"
PICARD_VERSION = (2, 3, 0, 'dev', 1)
PICARD_VERSION = (2, 3, 0, 'alpha', 1)


# optional build version
Expand Down Expand Up @@ -58,6 +58,8 @@ def version_to_string(version, short=False):
version_str = '%d.%d' % version[:2]
else:
version_str = '%d.%d.%d' % version[:3]
elif short and version[3] in ('a', 'b', 'rc'):
version_str = '%d.%d.%d%s%d' % version
else:
version_str = '%d.%d.%d.%s%d' % version
return version_str
Expand Down
6 changes: 3 additions & 3 deletions test/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def test_version_conversion_short(self):
((1, 1, 1, 'final', 0), '1.1.1'),
((0, 0, 1, 'dev', 1), '0.0.1.dev1'),
((1, 1, 0, 'dev', 0), '1.1.0.dev0'),
((1, 1, 2, 'alpha', 2), '1.1.2.a2'),
((1, 1, 2, 'beta', 2), '1.1.2.b2'),
((1, 1, 2, 'rc', 2), '1.1.2.rc2'),
((1, 1, 2, 'alpha', 2), '1.1.2a2'),
((1, 1, 2, 'beta', 2), '1.1.2b2'),
((1, 1, 2, 'rc', 2), '1.1.2rc2'),
)
for l, s in versions:
self.assertEqual(version_to_string(l, short=True), s)
Expand Down

0 comments on commit aa372fb

Please sign in to comment.