Skip to content

Cannot convert VersionSpecifier to canonical representation and back #7

Description

@Hritik14

The offending code is:
https://github.com/nexB/univers/blob/63bd5aec16ec95b5b811ede638ac225f3ab1f6c6/src/univers/version_specifier.py#L147-L153

Further
self.ranges is a VersionRange object and is converted to str by the following block
https://github.com/nexB/univers/blob/63bd5aec16ec95b5b811ede638ac225f3ab1f6c6/src/univers/version_range.py#L84-L85

the self.version is of type BaseVersion and is converted to str by
https://github.com/nexB/univers/blob/63bd5aec16ec95b5b811ede638ac225f3ab1f6c6/src/univers/versions.py#L51-L52

Which yields a string like
<=semver:1.20.0,>=semver:0.6.18 with multiple schemes which is incompatible to be converted back via
https://github.com/nexB/univers/blob/63bd5aec16ec95b5b811ede638ac225f3ab1f6c6/src/univers/version_specifier.py#L100-L104

Possible [dirty] fix:

        ranges = ",".join([f"{rng.operator}{rng.version.value}" for rng in self.version_specifier.ranges])
        return f"{self.scheme}:{ranges}"

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