Skip to content

max_satisfying is not returning max #53

@cdalessio0131

Description

@cdalessio0131

This looks like a bug in max_satisfying to me.

from semver import max_satisfying
versions = [ '49.0.0.2', '49.0.0.4', '49.0.0.5' ]
range_ = '>=49'
print(max_satisfying(versions, range_, loose=True, include_prerelease=True))
$ python max_satisfying.py
49.0.0.2

I would expect it to return 49.0.0.5, the highest (or max) version that satisfies.

Changing this

            if max_ is None or max_sv.compare(v) == -1:  # compare(max, v, true)

to this

            if (max_ is None or max_sv.compare(v) == -1) or (max_sv.compare(v) == 0):  # compare(max, v, true)

fixes it.

$ python max_satisfying.py
49.0.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions