Skip to content

VersionConstraint.version is allowed to be None #33

Description

@Hritik14

Is is more of a design decision than an issue.

Let's consider that in a place far far away, someone writes a piece code to get versions from all the constraints:

>>> vr = VersionRange.from_string("vers:npm/1.1|2.2")
>>> range_versions = [c.version for c in vr.constraints]
>>> range_versions
[SemverVersion(string='1.1'), SemverVersion(string='2.2')]

Everything is nice and good until we meet vers:ANY/*

>>> vr = VersionRange.from_string("vers:npm/*")
>>> range_versions = [c.version for c in vr.constraints]
>>> range_versions
[None]

Suddenly, range_versions break all expectations and contains a value value of NoneType than Version
A possible fix would be to allow None versions, such as Version(None)

Introduced here:
https://github.com/nexB/univers/blob/83e4fa651da7868f5c6f7c05a006bfadaac8d1cd/src/univers/version_constraint.py#L70

Related:
#10
#19

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