From f65517589c64b902230d98a944f63670c75fb00c Mon Sep 17 00:00:00 2001 From: Laurent-Dx Date: Thu, 8 Aug 2024 03:14:05 +0300 Subject: [PATCH 1/2] Fix doc for canonicalize_version to mention `strip_trailing_zero` and a typo in a docstring (#801) Co-authored-by: Laurent Dufloux --- docs/utils.rst | 5 +++-- src/packaging/metadata.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/utils.rst b/docs/utils.rst index ff2ca31a..f598a636 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -56,11 +56,12 @@ Reference >>> is_normalized_name("Django") False -.. function:: canonicalize_version(version) +.. function:: canonicalize_version(version, strip_trailing_zero=True) This function takes a string representing a package version (or a :class:`~packaging.version.Version` instance), and returns the - normalized form of it. + normalized form of it. By default, it strips trailing zeros from + the release segment. :param str version: The version to normalize. diff --git a/src/packaging/metadata.py b/src/packaging/metadata.py index 697afe49..e01ef0a5 100644 --- a/src/packaging/metadata.py +++ b/src/packaging/metadata.py @@ -167,7 +167,7 @@ class RawMetadata(TypedDict, total=False): def _parse_keywords(data: str) -> list[str]: - """Split a string of comma-separate keyboards into a list of keywords.""" + """Split a string of comma-separated keywords into a list of keywords.""" return [k.strip() for k in data.split(",")] From 24e5350b2ff3c5c7a36676c2af5f2cb39fd1baf8 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 8 Aug 2024 18:02:39 -0400 Subject: [PATCH 2/2] make the public/base_version comparison clearer (#818) Signed-off-by: Henry Schreiner --- src/packaging/version.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packaging/version.py b/src/packaging/version.py index fc3ebec9..b72a27ee 100644 --- a/src/packaging/version.py +++ b/src/packaging/version.py @@ -350,8 +350,8 @@ def public(self) -> str: '1.2.3' >>> Version("1.2.3+abc").public '1.2.3' - >>> Version("1.2.3+abc.dev1").public - '1.2.3' + >>> Version("1!1.2.3dev1+abc").public + '1!1.2.3.dev1' """ return str(self).split("+", 1)[0] @@ -363,7 +363,7 @@ def base_version(self) -> str: '1.2.3' >>> Version("1.2.3+abc").base_version '1.2.3' - >>> Version("1!1.2.3+abc.dev1").base_version + >>> Version("1!1.2.3dev1+abc").base_version '1!1.2.3' The "base version" is the public version of the project without any pre or post