Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added version sorting on Web and Removed obsolete versions #52887
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
Added version sorting on Web and Removed obsolete versions #52887
Changes from 4 commits
fbb5a37
1a5140f
d98c1c0
25a6eb4
a1eb2a9
c17f2c9
04d89a4
23f0a8a
a4c6aa2
84f5969
62e9e69
1812b25
2224de4
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use
v
here instead of release. Sincestr(v) == release
I think the render on the website should stay the same. And you don't need to makereleases
andsorted_releases
lists (or generators) of tuples, but only ofVersion
objects, which makes things easier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
str(v) == release
is true judging from the code below. I think there are fields likeassets
andtag_name
in eachrelease
. So I may not understand what you mean here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@datapythonista Hi, can you give some more clarifications on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. So, here you keep a tuple to deal with versions:
(Version(1, 5, 2), '1.5.2')
. You use the first element to compare versions, and the second to display it in the template. But the template will parse to string whatever you give it when creating the html. And this is true:The second element in the tuple is not needed, since you can give the first one to the template, and when rendered it will become the second. So, you can just use
Version(...)
instead of the tuple, and simplify the code, which is a bit tricky to follow.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I am still a little confused. The first element in the tuple is indeed the object
Version(...)
, but it is parsed fromrelease[tag_name]
but not fromrelease
directly. Since eachrelease
is a dictionary with many fields includingassets
,tag_name
,published_at
etc, I can only think of making them key-values pairs in the list(v, release)
and sort the list by the key valuesv
. In other word, the listlatest_releases
consists of tuple like(Version(1,5,2), {...})
instead of(Version(1, 5, 2), '1.5.2')
. So, I'm sorting the dictionaries by the versions and then feed the dictionaries to the next loop.