Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max_satisfying is not returning max #53

Open
cdalessio0131 opened this issue Nov 6, 2024 · 1 comment
Open

max_satisfying is not returning max #53

cdalessio0131 opened this issue Nov 6, 2024 · 1 comment

Comments

@cdalessio0131
Copy link

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
@podhmo
Copy link
Owner

podhmo commented Nov 7, 2024

Ah OK, if send me PR I will merging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants