gopidesupavan commented on code in PR #52265:
URL: https://github.com/apache/airflow/pull/52265#discussion_r2186113265
##########
scripts/ci/pre_commit/update_installers_and_pre_commit.py:
##########
@@ -65,6 +66,31 @@ def get_latest_pypi_version(package_name: str) -> str:
return latest_version
+def get_latest_python_version(python_major_minor: str) -> str | None:
+ latest_version = None
+ version_match = re.compile(rf"^v{python_major_minor}.*\.\d+$")
+ for i in range(5):
+ response = requests.get(
+
f"https://api.github.com/repos/python/cpython/tags?per_page=100&page={i + 1}",
+ headers={"User-Agent": "Python requests"},
+ )
+ response.raise_for_status() # Ensure we got a successful response
+ data = response.json()
+ versions = [str(tag["name"]) for tag in data if
version_match.match(tag.get("name", ""))]
+ if versions:
+ latest_version = sorted(versions, key=Version, reverse=True)[0]
Review Comment:
This throws error if any version tag is not in the expected format of
`Packaging version`, probably removing bad tags and checking would be better?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]