Skip to content

Commit

Permalink
Revise the code to sort the Python versions. (#264)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
anssakthi and pre-commit-ci[bot] authored Apr 17, 2024
1 parent 899674e commit ee2f854
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
requests==2.31.0
requests==2.31.0
packaging==23.2
6 changes: 2 additions & 4 deletions scripts/update_python_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re

from packaging.version import Version
import requests


Expand Down Expand Up @@ -53,10 +54,7 @@ def get_minor_version_sublist_with_greater_patch(list: list[str], current_versio
major, minor, patch = int(major), int(minor), int(patch)
sublist = [version for version in list if version.startswith(f"{major}.{minor}.")]
sublist = [version for version in sublist if int(version.split(".")[2]) > patch]

# Since the list is nuilt in ascending order, the first element is the smallest version
# of the list. We want the list to be sorted in desscending order (always take the latest)
sublist.reverse()
sublist = sorted(sublist, key=Version, reverse=True)

return sublist

Expand Down

0 comments on commit ee2f854

Please sign in to comment.