Fix 'pip index versions' never printing the (latest) marker - #14178
Fix 'pip index versions' never printing the (latest) marker#141782ykwang wants to merge 5 commits into
Conversation
| [ | ||
| ("1.17.0", "1.17.0"), | ||
| # PEP 440 equality is not string equality. | ||
| ("1.17", "1.17.0"), |
There was a problem hiding this comment.
thanks for confirming @sepehr-rs I went with version parsing instead of str(). unlikely to ever matter in practice, but figured Version equality is the better comparison here.
In [1]: from packaging.version import Version
In [2]: Version("1.0") == Version("1.0.0")
Out[2]: True
In [3]: "1.0" == "1.0.0"
Out[3]: False
sepehr-rs
left a comment
There was a problem hiding this comment.
Thanks a lot for your contribution! Very nice call using version parsing instead of str().
Aside from a minor nit on the news file, this looks good to me. Thanks again!
Co-authored-by: Sepehr Rasouli <sepehrrasouli06@gmail.com>
ichard26
left a comment
There was a problem hiding this comment.
This is an obvious bugfix, thanks for noticing and fixing this. My only concern is that this command is 100% something which be called and whose output will be parsed programmatically. So, despite this being an obvious defect, I'm not entirely sure it's worth the churn.
TBH, the command itself is confusing because the latest version is already included in the first line <pkg> (<latest-version>). I have no idea why we included the latest version twice originally.
$ pip index versions six
six (1.17.0)
Available versions: 1.17.0, 1.16.0, 1.15.0, 1.14.0, 1.13.0, 1.12.0, 1.11.0, 1.10.0, 1.9.0, 1.8.0, 1.7.3, 1.7.2, 1.7.1, 1.7.0, 1.6.1, 1.6.0, 1.5.2, 1.5.1, 1.5.0, 1.4.1, 1.4.0, 1.3.0, 1.2.0, 1.1.0, 1.0.0, 0.9.2, 0.9.1, 0.9.0
INSTALLED: 1.17.0 (latest)
Ideally, people would be using --json but that wasn't added until much later...
|
Thanks @ichard26. the The code that prints My guess is that:
Also, FWIW the Coming back to it. As you said this is a clear bug, but people might be parsing the |
What does this PR do?
Fixes #14177.
The comparison was
Version == str, which made the branch that prints(latest)unreachable.Moves the existing
parse_version(latest)call before the comparison and comparesVersionobjects instead.PR Checklist: