Skip to content

Commit 274a10c

Browse files
Merge pull request #2526 from VWS-Python/fix-release-join
Fix release parsing in conf.py
2 parents 5b4303a + 3a29476 commit 274a10c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/source/conf.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import importlib.metadata
77

88
from packaging.specifiers import SpecifierSet
9+
from packaging.version import Version
910

1011
project = "VWS-Python-Mock"
1112
author = "Adam Dangoor"
@@ -34,17 +35,16 @@
3435
copybutton_exclude = ".linenos, .gp"
3536

3637
# The version info for the project you're documenting, acts as replacement for
37-
# |version| and |release|, also used in various other places throughout the
38+
# |release|, also used in various other places throughout the
3839
# built documents.
3940
#
4041
# Use ``importlib.metadata.version`` as per
4142
# https://setuptools-scm.readthedocs.io/en/latest/usage/#usage-from-sphinx.
42-
version = importlib.metadata.version(distribution_name=project)
43-
# This method of getting the release from the version goes hand in hand with
44-
# the ``post-release`` versioning scheme chosen in the ``setuptools-scm``
45-
# configuration.
46-
release = version.split(sep=".post")[0]
47-
43+
_version_string = importlib.metadata.version(distribution_name=project)
44+
_version = Version(version=_version_string)
45+
# GitHub release tags have the format YYYY.MM.DD, while Python requirement
46+
# versions may have the format YYYY.M.D for single digit months and days.
47+
release = ".".join(f"{part:02d}" for part in _version.release)
4848

4949
project_metadata = importlib.metadata.metadata(distribution_name=project)
5050
requires_python = project_metadata["Requires-Python"]

0 commit comments

Comments
 (0)