potiuk commented on code in PR #52265: URL: https://github.com/apache/airflow/pull/52265#discussion_r2186909682
########## 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: Also. We can do it better without earlier filtering: ```python def is_valid_final_version(v): try: version = Version(v) return version == version.base_version except InvalidVersion: return False valid_versions = list(filter(is_valid_final_version, versions)) ```` -- 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