Skip to content

PyPI prerelease versions are mis-parsed (5.2b1 becomes 5.0.0) #24

Description

@marylinmilo1

Prerelease versions like 5.2b1 are not parsed correctly. The suffix is dropped and the version is reduced to 5.0.0, which makes comparisons and bounded ranges wrong.

n, _ := vers.Normalize("5.2b1")
fmt.Println(n) // "5.0.0"  (should be ordered as 5.2 beta 1)

fmt.Println(vers.CompareWithScheme("5.1", "5.2b1", "pypi")) // 1  (says 5.1 > 5.2b1, which is wrong)

r, _ := vers.Parse("vers:pypi/<5.2b1|>=5.1")
fmt.Println(r.Contains("6.0.3")) // true  (should be false; 6.0.3 is well outside the range)

Because 5.2b1 is read as 5.0.0, a range meant to cover a small prerelease window ends up matching everything from the lower bound on.

This affects all PEP 440 prerelease forms (a, b, rc, .dev, .post). Expected ordering per PEP 440: 1.0.dev1 < 1.0a1 < 1.0b1 < 1.0rc1 < 1.0 < 1.0.post1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions