From 4958a41ce6c36313fbc9199921e15b853a967c7b Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Wed, 10 Jun 2020 19:39:39 -0400 Subject: [PATCH 01/15] Deprecate max_ver and min_ver --- semver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/semver.py b/semver.py index 0c98af97..f9683356 100644 --- a/semver.py +++ b/semver.py @@ -812,6 +812,7 @@ def match(version, match_expr): return ver.match(match_expr) +@deprecated(replace="__builtin__.max", version="2.10.2") def max_ver(ver1, ver2): """ Returns the greater version of two versions strings. @@ -835,6 +836,7 @@ def max_ver(ver1, ver2): return ver2 +@deprecated(replace="__builtin__.min", version="2.10.2") def min_ver(ver1, ver2): """ Returns the smaller version of two versions strings. From ab4c0794352418e254557b1481498b61dd4de9e1 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Wed, 10 Jun 2020 20:34:13 -0400 Subject: [PATCH 02/15] Fix typos in docs --- docs/usage.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index b61e2847..c746bf78 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -11,9 +11,9 @@ are met. Knowing the Implemented semver.org Version ------------------------------------------ -The semver.org page is the authorative specification of how semantical -versioning is definied. -To know which version of semver.org is implemented in the semver libary, +The semver.org page is the authoritative specification of how semantic +versioning is defined. +To know which version of semver.org is implemented in the semver library, use the following constant:: >>> semver.SEMVER_SPEC_VERSION @@ -445,7 +445,7 @@ To compare two versions depends on your type: Other types cannot be compared. -If you need to convert some types into other, refer to :ref:`sec.convert.versions`. +If you need to convert some types into others, refer to :ref:`sec.convert.versions`. From 7fdcbef01dddc669d9ebef46891e9bea39f1cdbb Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Wed, 10 Jun 2020 20:44:21 -0400 Subject: [PATCH 03/15] Document use of builtins max and min --- docs/usage.rst | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index c746bf78..c9090b45 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -447,6 +447,10 @@ Other types cannot be compared. If you need to convert some types into others, refer to :ref:`sec.convert.versions`. +The use of these comparison operators also implies that you can also use builtin +functions that leverage this capability; builtins including but not limited to: :func:`max`, :func:`min` +(refer to :ref:`sec_max_min` for examples) and :func:`sorted`. + Comparing Versions through an Expression @@ -476,17 +480,29 @@ That gives you the following possibilities to express your condition: >>> semver.match("1.0.0", ">1.0.0") False +.. _sec_max_min Getting Minimum and Maximum of two Versions ------------------------------------------- +*Changed in version 2.10.2:* :func:`semver.max_ver` and :func:`semver.min_ver` functions are deprecated in favor of their builtin counterparts +:func:`max` and :func:`min`. + +Since :class:`semver.VersionInfo` implements :func:`__gt__()` and :func:`__lt__()`, it can be used with builtins requiring .. code-block:: python - >>> semver.max_ver("1.0.0", "2.0.0") + >>> str(max(semver.VersionInfo.parse("1.0.0"), semver.VersionInfo.parse("2.0.0"))) '2.0.0' - >>> semver.min_ver("1.0.0", "2.0.0") + >>> str(min(semver.VersionInfo.parse("1.0.0"), semver.VersionInfo.parse("2.0.0"))) '1.0.0' +.. code-block:: python + + >>> max([semver.VersionInfo(0, 1, 0), semver.VersionInfo(0, 2, 0), semver.VersionInfo(0, 1, 3)]) + VersionInfo(major=0, minor=2, patch=0, prerelease=None, build=None) + >>> min([semver.VersionInfo(0, 1, 0), semver.VersionInfo(0, 2, 0), semver.VersionInfo(0, 1, 3)]) + VersionInfo(major=0, minor=1, patch=0, prerelease=None, build=None) + Dealing with Invalid Versions ----------------------------- From 57c258eb65998b400b282991325b14d85d31c2e3 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Wed, 10 Jun 2020 20:46:45 -0400 Subject: [PATCH 04/15] Fix bad doc link and change section name --- docs/usage.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index c9090b45..11e6be1a 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -480,9 +480,9 @@ That gives you the following possibilities to express your condition: >>> semver.match("1.0.0", ">1.0.0") False -.. _sec_max_min +.. _sec_max_min: -Getting Minimum and Maximum of two Versions +Getting Minimum and Maximum of multiple Versions ------------------------------------------- *Changed in version 2.10.2:* :func:`semver.max_ver` and :func:`semver.min_ver` functions are deprecated in favor of their builtin counterparts :func:`max` and :func:`min`. From c9f4d99131af2c371bcd69f22aca027debc7d668 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Thu, 11 Jun 2020 18:23:56 -0400 Subject: [PATCH 05/15] Apply suggestions to fix typos and use appropriate directives Co-authored-by: Tom Schraitle --- docs/usage.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 11e6be1a..19ea2185 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -447,7 +447,7 @@ Other types cannot be compared. If you need to convert some types into others, refer to :ref:`sec.convert.versions`. -The use of these comparison operators also implies that you can also use builtin +The use of these comparison operators also implies that you can use builtin functions that leverage this capability; builtins including but not limited to: :func:`max`, :func:`min` (refer to :ref:`sec_max_min` for examples) and :func:`sorted`. @@ -482,10 +482,11 @@ That gives you the following possibilities to express your condition: .. _sec_max_min: -Getting Minimum and Maximum of multiple Versions +Getting Minimum and Maximum of Multiple Versions ------------------------------------------- -*Changed in version 2.10.2:* :func:`semver.max_ver` and :func:`semver.min_ver` functions are deprecated in favor of their builtin counterparts -:func:`max` and :func:`min`. +.. versionchanged:: 2.10.2 + The functions :func:`semver.max_ver` and :func:`semver.min_ver` are deprecated in + favor of their builtin counterparts :func:`max` and :func:`min`. Since :class:`semver.VersionInfo` implements :func:`__gt__()` and :func:`__lt__()`, it can be used with builtins requiring From 9d1b5bbf8dd230cc473f365915c3e18cc5c0e22e Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Fri, 12 Jun 2020 17:01:06 -0400 Subject: [PATCH 06/15] Reword sentence. I am fairly confident this is correct and I think it should bedazzle any native English speaker with an appreciation of literature. --- docs/usage.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 19ea2185..be40c86c 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -448,8 +448,8 @@ Other types cannot be compared. If you need to convert some types into others, refer to :ref:`sec.convert.versions`. The use of these comparison operators also implies that you can use builtin -functions that leverage this capability; builtins including but not limited to: :func:`max`, :func:`min` -(refer to :ref:`sec_max_min` for examples) and :func:`sorted`. +functions that leverage this capability; builtins including, but not limited to: :func:`max`, :func:`min` +(for examples, see :ref:`sec_max_min`) and :func:`sorted`. From 81a84ae7af7f6fad0c320cf8e7ea7fbde85af52d Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Sat, 13 Jun 2020 09:46:50 -0400 Subject: [PATCH 07/15] Change the qualified name for `replace` --- semver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/semver.py b/semver.py index f9683356..2571684c 100644 --- a/semver.py +++ b/semver.py @@ -812,7 +812,7 @@ def match(version, match_expr): return ver.match(match_expr) -@deprecated(replace="__builtin__.max", version="2.10.2") +@deprecated(replace="max", version="2.10.2") def max_ver(ver1, ver2): """ Returns the greater version of two versions strings. @@ -836,7 +836,7 @@ def max_ver(ver1, ver2): return ver2 -@deprecated(replace="__builtin__.min", version="2.10.2") +@deprecated(replace="min", version="2.10.2") def min_ver(ver1, ver2): """ Returns the smaller version of two versions strings. From 48f92c6ba2eebf2cc1788465e5df5ca0d219f59a Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Sat, 13 Jun 2020 09:48:16 -0400 Subject: [PATCH 08/15] Improve documentation with examples of how to use the builtin max and min. Keep the old way of doing for reference. --- docs/usage.rst | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index be40c86c..8ced4be6 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -483,20 +483,13 @@ That gives you the following possibilities to express your condition: .. _sec_max_min: Getting Minimum and Maximum of Multiple Versions -------------------------------------------- +------------------------------------------------ .. versionchanged:: 2.10.2 The functions :func:`semver.max_ver` and :func:`semver.min_ver` are deprecated in favor of their builtin counterparts :func:`max` and :func:`min`. Since :class:`semver.VersionInfo` implements :func:`__gt__()` and :func:`__lt__()`, it can be used with builtins requiring -.. code-block:: python - - >>> str(max(semver.VersionInfo.parse("1.0.0"), semver.VersionInfo.parse("2.0.0"))) - '2.0.0' - >>> str(min(semver.VersionInfo.parse("1.0.0"), semver.VersionInfo.parse("2.0.0"))) - '1.0.0' - .. code-block:: python >>> max([semver.VersionInfo(0, 1, 0), semver.VersionInfo(0, 2, 0), semver.VersionInfo(0, 1, 3)]) @@ -504,6 +497,39 @@ Since :class:`semver.VersionInfo` implements :func:`__gt__()` and :func:`__lt__( >>> min([semver.VersionInfo(0, 1, 0), semver.VersionInfo(0, 2, 0), semver.VersionInfo(0, 1, 3)]) VersionInfo(major=0, minor=1, patch=0, prerelease=None, build=None) +Incidentally, using :func:`map`, you can get the min or max version of any number of versions of the same type +(convertible to :class:`semver.VersionInfo`). + +For example, here are the maximum and minimum versions of a list of version strings: + +.. code-block:: python + + >>> str(max(map(semver.VersionInfo.parse, ['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99']))) + '2.1.0' + >>> str(min(map(semver.VersionInfo.parse, ['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99']))) + '0.4.99' + +And the same can be done with tuples: + +.. code-block:: python + + >>> max(map(lambda v: semver.VersionInfo(*v), [(1, 1, 0), (1, 2, 0), (2, 1, 0), (0, 5, 10), (0, 4, 99)]))).to_tuple() + (2, 1, 0) + >>> min(map(lambda v: semver.VersionInfo(*v), [(1, 1, 0), (1, 2, 0), (2, 1, 0), (0, 5, 10), (0, 4, 99)]))).to_tuple() + (0, 4, 99) + +For dictionaries, it is very similar to finding the max version tuple: see :ref:`_sec.convert.versions`. + +The Old Way +^^^^^^^^^^^ + +.. code-block:: python + + >>> semver.max_ver("1.0.0", "2.0.0") + '2.0.0' + >>> semver.min_ver("1.0.0", "2.0.0") + '1.0.0' + Dealing with Invalid Versions ----------------------------- From 2a42d6117cbf74efe9aa2a2f7ef4429877e0b9c0 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Sun, 14 Jun 2020 12:44:47 -0400 Subject: [PATCH 09/15] Apply suggestion to make doctests pass Co-authored-by: Tom Schraitle --- docs/usage.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 8ced4be6..8aeba569 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -513,10 +513,10 @@ And the same can be done with tuples: .. code-block:: python - >>> max(map(lambda v: semver.VersionInfo(*v), [(1, 1, 0), (1, 2, 0), (2, 1, 0), (0, 5, 10), (0, 4, 99)]))).to_tuple() - (2, 1, 0) - >>> min(map(lambda v: semver.VersionInfo(*v), [(1, 1, 0), (1, 2, 0), (2, 1, 0), (0, 5, 10), (0, 4, 99)]))).to_tuple() - (0, 4, 99) + >>> max(map(lambda v: semver.VersionInfo(*v), [(1, 1, 0), (1, 2, 0), (2, 1, 0), (0, 5, 10), (0, 4, 99)])).to_tuple() + (2, 1, 0, None, None) + >>> min(map(lambda v: semver.VersionInfo(*v), [(1, 1, 0), (1, 2, 0), (2, 1, 0), (0, 5, 10), (0, 4, 99)])).to_tuple() + (0, 4, 99, None, None) For dictionaries, it is very similar to finding the max version tuple: see :ref:`_sec.convert.versions`. From e6c09159387c8eb5b670184daad95a9215766420 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Mon, 15 Jun 2020 08:43:58 -0400 Subject: [PATCH 10/15] Remove lonely subsection Co-authored-by: Tom Schraitle --- docs/usage.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 8aeba569..c9140066 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -520,8 +520,7 @@ And the same can be done with tuples: For dictionaries, it is very similar to finding the max version tuple: see :ref:`_sec.convert.versions`. -The Old Way -^^^^^^^^^^^ +The "old way" with :func:`semver.max_ver` or :func:`semver.min_ver` is still available, but not recommended: .. code-block:: python From 1970c40d8449613b8f6ea5219153b94688bb35d4 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Mon, 15 Jun 2020 09:06:21 -0400 Subject: [PATCH 11/15] Test that max_ver and min_ver are deprecated. --- test_semver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test_semver.py b/test_semver.py index 015cb7d2..b23576d5 100644 --- a/test_semver.py +++ b/test_semver.py @@ -1036,6 +1036,8 @@ def test_should_versioninfo_isvalid(): (parse, ("1.2.3",), {}), (parse_version_info, ("1.2.3",), {}), (replace, ("1.2.3",), dict(major=2, patch=10)), + (max_ver, ("1.2.3", "1.2.4"), {}), + (min_ver, ("1.2.3", "1.2.4"), {}), ], ) def test_should_raise_deprecation_warnings(func, args, kwargs): From 81e526efbfc881a05e56399d97448b5aa29fba25 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Mon, 15 Jun 2020 09:06:45 -0400 Subject: [PATCH 12/15] Add deprecation to CHANGELOG.rst --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2671ef2e..74cc8f6d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -32,7 +32,7 @@ n/a Removals -------- -n/a +:gh:`160` (:pr:`264`): Deprecate :func:`semver.max_ver` and :func:`semver.min_ver`:w Version 2.10.1 From 739916dfdc499b34a5897fd63843c1fda1addd83 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Mon, 15 Jun 2020 09:14:30 -0400 Subject: [PATCH 13/15] Rename removals to deprecations and clean up the CHANGELOG.rst --- CHANGELOG.rst | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 74cc8f6d..4cd18b66 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -29,10 +29,12 @@ Additions n/a -Removals +Deprecations -------- -:gh:`160` (:pr:`264`): Deprecate :func:`semver.max_ver` and :func:`semver.min_ver`:w +* :gh:`160` (:pr:`264`): + * :func:`semver.max_ver` + * :func:`semver.min_ver` Version 2.10.1 @@ -58,14 +60,6 @@ Bug Fixes to always return a ``VersionInfo`` instance. -Additions ---------- - - -Removals --------- - - Version 2.10.0 ============== @@ -95,7 +89,7 @@ Additions * :pr:`228`: Added better doctest integration -Removals +Deprecations -------- * :gh:`225` (:pr:`229`): Output a DeprecationWarning for the following functions: @@ -139,12 +133,6 @@ Bug Fixes * :gh:`192` (:pr:`193`): Fixed "pysemver" and "pysemver bump" when called without arguments -Removals --------- - -not available - - Version 2.9.0 ============= :Released: 2019-10-30 @@ -184,7 +172,7 @@ Bug Fixes Removals -------- -* :gh:`111` (:pr:`110`): Droped Python 3.3 +* :gh:`111` (:pr:`110`): Dropped Python 3.3 * :gh:`148` (:pr:`149`): Removed and replaced ``python setup.py test`` From 8605f300296158344ee13c26cc4dc41923484843 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Mon, 15 Jun 2020 10:22:02 -0400 Subject: [PATCH 14/15] Add deprecation replacement for max_ver and min_ver --- docs/usage.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/usage.rst b/docs/usage.rst index c9140066..85b5370b 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -617,6 +617,28 @@ them with code which is compatible for future versions: >>> s1 == s2 True +* :func:`semver.max_ver` + + Replace it with ``max(version1, version2, ...)`` or ``max([version1, version2, ...])``: + + .. code-block:: python + + >>> s1 = semver.max_ver("1.2.3", "1.2.4") + >>> s2 = str(max(map(semver.VersionInfo.parse, ("1.2.3", "1.2.4")))) + >>> s1 == s2 + True + +* :func:`semver.min_ver` + + Replace it with ``min(version1, version2, ...)`` or ``min([version1, version2, ...])``: + + .. code-block:: python + + >>> s1 = semver.min_ver("1.2.3", "1.2.4") + >>> s2 = str(min(map(semver.VersionInfo.parse, ("1.2.3", "1.2.4")))) + >>> s1 == s2 + True + * :func:`semver.parse` Replace it with :func:`semver.VersionInfo.parse` and From 83239f0a7a8d41273812b102231db425c7cd26a6 Mon Sep 17 00:00:00 2001 From: Thomas Laferriere Date: Mon, 15 Jun 2020 11:21:47 -0400 Subject: [PATCH 15/15] Fix typo Co-authored-by: Tom Schraitle --- docs/usage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.rst b/docs/usage.rst index 85b5370b..2f23e571 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -518,7 +518,7 @@ And the same can be done with tuples: >>> min(map(lambda v: semver.VersionInfo(*v), [(1, 1, 0), (1, 2, 0), (2, 1, 0), (0, 5, 10), (0, 4, 99)])).to_tuple() (0, 4, 99, None, None) -For dictionaries, it is very similar to finding the max version tuple: see :ref:`_sec.convert.versions`. +For dictionaries, it is very similar to finding the max version tuple: see :ref:`sec.convert.versions`. The "old way" with :func:`semver.max_ver` or :func:`semver.min_ver` is still available, but not recommended: