Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proper exception subclass for invalid constraints error #124

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/univers/version_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,10 @@ def simplify_constraints(constraints):
return sorted(set(unequal_constraints + constraints))


class InvalidConstraintsError(Exception):
pass


def contains_version(version, constraints):
"""
Return True an assertion error if the ``constraints`` list contains the
Expand Down Expand Up @@ -539,7 +543,10 @@ def contains_version(version, constraints):

else:
# this should never happen as the constraints must be valid going in
raise Exception(f"Invalid constraints sequence: {constraints }")
raise InvalidConstraintsError(
f"Invalid constraints sequence: ('{cur_comp} {cur_constraint.version}',"
f"'{nxt_comp} {nxt_constraint.version}') in {constraints!r}"
)

# If this is the last iteration and next comparator is ">" or >="
# and the "tested version" is greater than the next version
Expand Down