Skip to content

Commit 3d0de11

Browse files
committed
Use from_versions for getting vers from discrete versions
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 8f0d727 commit 3d0de11

2 files changed

Lines changed: 0 additions & 39 deletions

File tree

src/univers/version_range.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,36 +1377,6 @@ def build_range_from_snyk_advisory_string(scheme: str, string: Union[str, List])
13771377
return vrc(constraints=version_constraints)
13781378

13791379

1380-
def build_range_from_discrete_version_string(scheme: str, string: Union[str, List]):
1381-
"""
1382-
Return VersionRange computed from discrete versions.
1383-
Discrete version range looks like:
1384-
["1.5","3.1.2","3.1-beta"]
1385-
1386-
For example::
1387-
1388-
# >>> vr = build_constraints_from_discrete_version_string("pypi", ["1.5","3.1.2","3.1-beta"])
1389-
# >>> assert str(vr) == "vers:pypi/1.5|3.1-beta|3.1.2"
1390-
# >>> vr = build_constraints_from_discrete_version_string("pypi","9.21")
1391-
# >>> assert str(vr) == "vers:pypi/9.21"
1392-
"""
1393-
version_constraints = []
1394-
vrc = RANGE_CLASS_BY_SCHEMES[scheme]
1395-
1396-
if isinstance(string, str):
1397-
string = [string]
1398-
1399-
for item in string:
1400-
version = item.strip()
1401-
version = vrc.version_class(version)
1402-
version_constraints.append(
1403-
VersionConstraint(
1404-
version=version,
1405-
)
1406-
)
1407-
return vrc(constraints=version_constraints)
1408-
1409-
14101380
RANGE_CLASS_BY_SCHEMES = {
14111381
"npm": NpmVersionRange,
14121382
"deb": DebianVersionRange,

tests/test_version_range.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from univers.version_range import OpensslVersionRange
2121
from univers.version_range import PypiVersionRange
2222
from univers.version_range import VersionRange
23-
from univers.version_range import build_range_from_discrete_version_string
2423
from univers.version_range import build_range_from_snyk_advisory_string
2524
from univers.version_range import from_gitlab_native
2625
from univers.versions import InvalidVersion
@@ -489,14 +488,6 @@ def test_build_range_from_snyk_advisory_string_spaced():
489488
assert str(vr) == expected
490489

491490

492-
def test_build_range_from_discrete_version_string():
493-
expression = ["4.1.0", " 4.4.1", "2.1.0 ", " 3.2.7 "]
494-
vr = build_range_from_discrete_version_string("pypi", expression)
495-
expected = "vers:pypi/2.1.0|3.2.7|4.1.0|4.4.1"
496-
497-
assert str(vr) == expected
498-
499-
500491
def test_version_range_normalize_case1():
501492
known_versions = ["4.0.0", "3.0.0", "1.0.0", "2.0.0", "1.3.0", "1.1.0", "1.2.0"]
502493

0 commit comments

Comments
 (0)