Skip to content

Commit

Permalink
appeasing sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Jun 1, 2022
1 parent 664bd51 commit f4e3732
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/poetry/core/packages/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,11 @@ def normalize_python_version_markers(disjunction: list[list[tuple[str, str]]]) -
ands = []
for op, version in or_:
# Expand python version
if op == "==":
if "*" not in version:
version = "~" + version
op = ""
elif op == "!=":
if "*" not in version:
version += ".*"
if op == "==" and "*" not in version:
version = "~" + version
op = ""
elif op == "!=" and "*" not in version:
version += ".*"
elif op in ("<=", ">"):
# Make adjustments on encountering versions with less than full
# precision.
Expand All @@ -343,18 +341,17 @@ def normalize_python_version_markers(disjunction: list[list[tuple[str, str]]]) -
# We achieve the above by fiddling with the operator and version in the
# marker.
parsed_version = Version.parse(version)
if parsed_version.precision == 1:
if op == "<=":
op = "<"
elif op == ">":
op = ">="
elif parsed_version.precision == 2:
if op == "<=":
op = "<"
version = parsed_version.next_minor().text
elif op == ">":
op = ">="
version = parsed_version.next_minor().text
if parsed_version.precision >= 3:
continue

if op == "<=":
op = "<"
elif op == ">":
op = ">="

if parsed_version.precision == 2:
version = parsed_version.next_minor().text

elif op in ("in", "not in"):
versions = []
for v in re.split("[ ,]+", version):
Expand Down

0 comments on commit f4e3732

Please sign in to comment.