This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-0-test by this push:
new 70b83be4c3e Fixup constraint generation script
70b83be4c3e is described below
commit 70b83be4c3e47875b7ffb67ffb318aec0a38649d
Author: Ash Berlin-Taylor <[email protected]>
AuthorDate: Sat Aug 2 23:35:00 2025 +0100
Fixup constraint generation script
This change came from #46891, but that was a much bigger change to enable
Python 3.13 which we don't want to backport
(cherry picked from commit 488744c9ada417883e223da516b7fce94b63581a)
---
.../utils/constraints_version_check.py | 27 ++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/dev/breeze/src/airflow_breeze/utils/constraints_version_check.py
b/dev/breeze/src/airflow_breeze/utils/constraints_version_check.py
index e0c4ccb7474..204c917f74d 100755
--- a/dev/breeze/src/airflow_breeze/utils/constraints_version_check.py
+++ b/dev/breeze/src/airflow_breeze/utils/constraints_version_check.py
@@ -26,6 +26,7 @@ import urllib.request
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
+from typing import TYPE_CHECKING, Any
from urllib.error import HTTPError, URLError
from rich.console import Console
@@ -43,6 +44,9 @@ from airflow_breeze.utils.shared_options import get_verbose
console = Console(color_system="standard")
+if TYPE_CHECKING:
+ from packaging.version import Version
+
def parse_constraints_generation_date(lines):
for line in lines[:5]:
@@ -58,7 +62,24 @@ def parse_constraints_generation_date(lines):
return None
-def count_versions_between(releases, current_version, latest_version):
+def is_valid_version(version_str: str, latest_version: Version) -> bool:
+ """Check if the version string is a valid one.
+
+ The version should not ve pre-release or dev release and should be below
the latest version"""
+ from packaging import version
+
+ try:
+ parsed_version = version.parse(version_str)
+ return (
+ not parsed_version.is_prerelease
+ and not parsed_version.is_devrelease
+ and parsed_version <= latest_version
+ )
+ except version.InvalidVersion:
+ return False
+
+
+def count_versions_between(releases: dict[str, Any], current_version: str,
latest_version: str):
from packaging import version
current = version.parse(current_version)
@@ -68,9 +89,7 @@ def count_versions_between(releases, current_version,
latest_version):
return 0
valid_versions = [
- v
- for v in releases.keys()
- if releases[v] and not version.parse(v).is_prerelease and current <
version.parse(v) <= latest
+ v for v in releases.keys() if releases[v] and
is_valid_version(version_str=v, latest_version=latest)
]
return max(len(valid_versions), 1) if current < latest else 0