14
14
from antsibull_core .vendored .collections import is_sequence
15
15
16
16
17
- # if a module is added in a version of Ansible older than this, don't print the version added
18
- # information in the module documentation because everyone is assumed to be running something newer
19
- # than this already.
20
- TOO_OLD_TO_BE_NOTABLE = '0.0.0'
17
+ # The following dictionary maps collection names to cut-off versions. If a version of such a
18
+ # collection is mentioned as when a feature was added that is older than the cut-off version,
19
+ # we do not print the version.
20
+ TOO_OLD_TO_BE_NOTABLE = {
21
+ 'ansible.builtin' : '2.7' ,
22
+ }
21
23
22
24
test_list : t .Callable [[t .Any ], bool ] = partial (is_sequence , include_strings = False )
23
25
24
26
25
- def still_relevant (version , cutoff = TOO_OLD_TO_BE_NOTABLE , collection = None ):
27
+ def still_relevant (version , collection = None ):
26
28
"""
27
29
Calculates whether the given version is older than a cutoff value
28
30
29
31
:arg version: Version to check
30
- :arg cutoff: Calculate whether `version` is older than this
31
- :returns: True if the `version` is older than `cutoff` otherwise True.
32
+ :returns: False if the `version` is older than the cutoff version, otherwise True.
32
33
33
34
.. note:: This is similar to the ansible `version_compare` test but needs to handle the
34
35
`historical` version and empty version.
@@ -41,13 +42,16 @@ def still_relevant(version, cutoff=TOO_OLD_TO_BE_NOTABLE, collection=None):
41
42
if version == 'historical' :
42
43
return False
43
44
45
+ cutoff = TOO_OLD_TO_BE_NOTABLE .get (collection )
46
+ if cutoff is None :
47
+ # If we do not have a cut-off version for the collection, we simply declare it to be
48
+ # still relevant
49
+ return True
50
+
44
51
if collection == 'ansible.builtin' :
45
52
Version = PypiVer
46
- elif collection is not None :
47
- Version = SemVer
48
53
else :
49
- # This used to be distutils.version.LooseVersion
50
- Version = PypiVer
54
+ Version = SemVer
51
55
52
56
try :
53
57
version = Version (version )
0 commit comments