Skip to content

VersionRange.constraints are not an iterable of an iterable #22

Description

@Hritik14

Commit 80b515a changes how constraints are populated.
This messes up with the assumption that constraints are an iterable of iterables (here, list, in future - tuple).
https://github.com/nexB/univers/blob/ca2cf4da77303bc8ead9ee2c6475b7a68ac81e26/src/univers/version_range.py#L41-L43

Commit: 80b515a

-        # parse_constraints
-        version_constraints = []
-        for or_constraints in constraints.split("|"):
-            and_constraints = []
-            for constraint in or_constraints.split(","):
-                constraint = VersionConstraint.from_string(
-                    string=constraint,
-                    version_class=range_class.version_class,
-                )
-                and_constraints.append(constraint)
-            version_constraints.append(and_constraints)
+        # There is only one star: "*" must only occur once and alone in a range,
+        # without any other constraint or version.
+        if constraints.startswith("*"):
+            if constraints != "*":
+                raise ValueError(f"{vers!r} contains an invalid '*' constraint.")
+            return range_class([VersionConstraint.from_string(string="*", version_class=None)])
+
+        parsed_constraints = []
+
+        constraints = constraints.strip("|")
+        for const in constraints.split("|"):
+            constraint = VersionConstraint.from_string(
+                string=const,
+                version_class=version_class,
+            )
+            parsed_constraints.append(constraint)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions