aritra24 commented on code in PR #52265:
URL: https://github.com/apache/airflow/pull/52265#discussion_r2186871163


##########
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:
   they don't seem to have a separate is valid method, I chose to do it with 
regex myself because I wanted to exclude alpha and beta versions from our list 
which would've been matched by their regex, so I think given our regex is a 
subset of theirs it should be fine? 



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to