Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
VersionRange(Version(1, 2, 3, pre="beta.2"), Version(2, 0, 0), True),
),
("^1.2.3", VersionRange(Version(1, 2, 3), Version(2, 0, 0), True)),
("^0.2.3", VersionRange(Version(0, 2, 3), Version(0, 3, 0), True)),
("^0.2", VersionRange(Version(0, 2, 0), Version(0, 3, 0), True)),
("^0.2.0", VersionRange(Version(0, 2, 0), Version(0, 3, 0), True)),
("^0.0.3", VersionRange(Version(0, 0, 3), Version(0, 0, 4), True)),
],
)
def test_parse_constraint_caret(input, constraint):
assert parse_constraint(input) == constraint
def test_parse_constraint_multi(input):
assert parse_constraint(input) == VersionRange(
Version(2, 0, 0), Version(3, 0, 0), include_min=False, include_max=True
)
def v003():
return Version.parse("0.0.3")
VersionRange(Version(1, 2, 0, pre="beta"), Version(1, 3, 0), True),
),
("~1.2-b2", VersionRange(Version(1, 2, 0, pre="b2"), Version(1, 3, 0), True)),
("~0.3", VersionRange(Version(0, 3, 0), Version(0, 4, 0), True)),
("~3.5", VersionRange(Version(3, 5, 0), Version(3, 6, 0), True)),
("~=3.5", VersionRange(Version(3, 5, 0), Version(4, 0, 0), True)), # PEP 440
("~=3.5.3", VersionRange(Version(3, 5, 3), Version(3, 6, 0), True)), # PEP 440
],
)
def test_parse_constraint_tilde(input, constraint):
assert parse_constraint(input) == constraint
("~=3.5.3", VersionRange(Version(3, 5, 3), Version(3, 6, 0), True)), # PEP 440
],
)
def test_parse_constraint_tilde(input, constraint):
assert parse_constraint(input) == constraint
("~=3.5", VersionRange(Version(3, 5, 0), Version(4, 0, 0), True)), # PEP 440
("~=3.5.3", VersionRange(Version(3, 5, 3), Version(3, 6, 0), True)), # PEP 440
],
)
def test_parse_constraint_tilde(input, constraint):
assert parse_constraint(input) == constraint
("~0.3", VersionRange(Version(0, 3, 0), Version(0, 4, 0), True)),
("~3.5", VersionRange(Version(3, 5, 0), Version(3, 6, 0), True)),
("~=3.5", VersionRange(Version(3, 5, 0), Version(4, 0, 0), True)), # PEP 440
("~=3.5.3", VersionRange(Version(3, 5, 3), Version(3, 6, 0), True)), # PEP 440
],
)
def test_parse_constraint_tilde(input, constraint):
assert parse_constraint(input) == constraint
("1.0.0-post1", Version(1, 0, 0, build="1")),
("0.6c", Version(0, 6, 0, pre="rc0")),
("0.6pre", Version(0, 6, 0, pre="rc0")),
],
)
def test_parse_valid(input, version):
parsed = Version.parse(input)
assert parsed == version
assert parsed.text == input
new = version.next_major
if rule == "premajor":
new = new.first_prerelease
elif rule in {"minor", "preminor"}:
new = version.next_minor
if rule == "preminor":
new = new.first_prerelease
elif rule in {"patch", "prepatch"}:
new = version.next_patch
if rule == "prepatch":
new = new.first_prerelease
elif rule == "prerelease":
if version.is_prerelease():
pre = version.prerelease
new_prerelease = int(pre[1]) + 1
new = Version.parse(
"{}.{}.{}-{}".format(
version.major,
version.minor,
version.patch,
".".join([pre[0], str(new_prerelease)]),
)
)
else:
new = version.next_patch.first_prerelease
else:
new = Version.parse(rule)
return new
for _, extra in or_:
dep.in_extras.append(extra)
if "python_version" in markers:
ors = []
for or_ in markers["python_version"]:
ands = []
for op, version in or_:
# Expand python version
if op == "==":
version = "~" + version
op = ""
elif op == "!=":
version += ".*"
elif op in ("<=", ">"):
parsed_version = Version.parse(version)
if parsed_version.precision == 1:
if op == "<=":
op = "<"
version = parsed_version.next_major.text
elif op == ">":
op = ">="
version = parsed_version.next_major.text
elif parsed_version.precision == 2:
if op == "<=":
op = "<"
version = parsed_version.next_minor.text
elif op == ">":
op = ">="
version = parsed_version.next_minor.text
elif op in ("in", "not in"):
versions = []