diff --git a/src/python/jw/pkg/lib/version/Dependency.py b/src/python/jw/pkg/lib/version/Dependency.py index 01c710c8..3b85413c 100644 --- a/src/python/jw/pkg/lib/version/Dependency.py +++ b/src/python/jw/pkg/lib/version/Dependency.py @@ -70,7 +70,7 @@ class Dependency: # export specified = self.__parsed_spec[1] if specified is None: return [] - if not expanded or not specified.version.is_full: + if not expanded or specified.version.is_full: return (specified, ) ret: list[Boundary] = [] match specified.op: @@ -132,7 +132,7 @@ class Dependency: # export def version_boundaries(self, expanded: bool = False) -> Sequence[Boundary]: """The parsed version boundary, or the range it spans when - expanded is True and it pins a full version. + expanded is True and it does not pin a full version. """ return self.__version_boundaries(expanded) diff --git a/src/python/jw/pkg/lib/version/Version.py b/src/python/jw/pkg/lib/version/Version.py index 0e204313..8f81f666 100644 --- a/src/python/jw/pkg/lib/version/Version.py +++ b/src/python/jw/pkg/lib/version/Version.py @@ -141,9 +141,8 @@ class Version: # export def is_full(self) -> bool: """True if the spec pins a complete version: the VERSION-REVISION macro, or a literal of the form - MAJOR.MINOR.MICRO-REVISION. Only full versions have the - exclusive upper bound (next_binary_incompatible) that range - expansion relies on. + MAJOR.MINOR.MICRO-REVISION. Range expansion leaves full + versions exact and expands the non-full specs. """ if self.__spec == 'VERSION-REVISION': return True diff --git a/test/unit/python/jw/pkg/lib/version/test.py b/test/unit/python/jw/pkg/lib/version/test.py index 74962bd1..5f03f9de 100644 --- a/test/unit/python/jw/pkg/lib/version/test.py +++ b/test/unit/python/jw/pkg/lib/version/test.py @@ -109,32 +109,28 @@ assert d.constraint_str() == 'foo = 1.2.3' assert d.constraint_str() == 'foo = 1.2.3' assert calls == ['foo'] -# as_range expands full boundaries into a revision range +# as_range expands a non-full boundary into the range it spans d = Dependency('foo = VERSION-REVISION', app.get_version) -assert d.constraint_str(as_range = True) == 'foo >= 1.2.3-45 foo < 1.2.4' +assert d.constraint_str(as_range = True) == 'foo = 1.2.3-45' d = Dependency('foo >= VERSION-REVISION', app.get_version) -assert d.constraint_str(as_range = True) == 'foo >= 1.2.3-45 foo < 1.2.4' +assert d.constraint_str(as_range = True) == 'foo >= 1.2.3-45' d = Dependency('foo > 1.0.0-259', app.get_version) -assert d.constraint_str(as_range = True) == 'foo > 1.0.0-259 foo < 1.0.1' -# A raw render keeps the macro, with the computed bound alongside it +assert d.constraint_str(as_range = True) == 'foo > 1.0.0-259' +# A raw render keeps the macro as written d = Dependency('foo = VERSION-REVISION', app.get_version) constraint = d.constraint_str(untemplated = False, as_range = True) -assert constraint == 'foo >= VERSION-REVISION foo < 1.2.4' -# VERSION is not full, so a VERSION constraint is not expanded +assert constraint == 'foo = VERSION-REVISION' +# A full version stays exact; a non-full one expands d = Dependency('foo = VERSION', app.get_version) -assert d.constraint_str(as_range = True) == 'foo = 1.2.3' +assert d.constraint_str(as_range = True) == 'foo >= 1.2.3 foo < 1.2.4' d = Dependency('foo >= VERSION', app.get_version) -assert d.constraint_str(as_range = True) == 'foo >= 1.2.3' +assert d.constraint_str(as_range = True) == 'foo >= 1.2.3 foo < 1.2.4' # '<' and '<=' are not expanded d = Dependency('foo <= VERSION', app.get_version) assert d.constraint_str(as_range = True) == 'foo <= 1.2.3' -# versions without a full major.minor.micro-revision are not expanded -d = Dependency('foo = 1.0', app.get_version) -assert d.constraint_str(as_range = True) == 'foo = 1.0' +# The bound steps a micro, so a tripartite core expands d = Dependency('foo = 1.2.3', app.get_version) -assert d.constraint_str(as_range = True) == 'foo = 1.2.3' -d = Dependency('foo = 1.0-rc1', app.get_version) -assert d.constraint_str(as_range = True) == 'foo = 1.0-rc1' +assert d.constraint_str(as_range = True) == 'foo >= 1.2.3 foo < 1.2.4' # Default syntax is SEM_VER d = Dependency('foo < 2.0') assert d.constraint_str(untemplated = False) == 'foo < 2.0'