Skip to content

Commit 051175d

Browse files
github-actions[bot]DaveT1991Copilot
authored andcommitted
[v3-2-test] Sync default image Python version references (#64994) (#65045)
* Sync default image Python version references * Fix mypy type error in _read_global_constants_assignment return type Since ast.literal_eval() returns Any, annotating the private helper as returning str | list[str] caused mypy errors in both callers: assigning the result to `list[str]` and returning it as `str`. Changing the return type to Any (which matches ast.literal_eval) resolves both without requiring casts. * Update scripts/ci/prek/common_prek_utils.py --------- (cherry picked from commit d212f62) Co-authored-by: DaveT1991 <129008657+DaveT1991@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8c36139 commit 051175d

12 files changed

Lines changed: 56 additions & 19 deletions

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ARG AIRFLOW_USER_HOME_DIR=/home/airflow
5151
ARG AIRFLOW_VERSION="3.1.8"
5252

5353
ARG BASE_IMAGE="debian:bookworm-slim"
54-
ARG AIRFLOW_PYTHON_VERSION="3.12.13"
54+
ARG AIRFLOW_PYTHON_VERSION="3.13.13"
5555

5656
# PYTHON_LTO: Controls whether Python is built with Link-Time Optimization (LTO).
5757
#

Dockerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ ENV DEV_APT_COMMAND=${DEV_APT_COMMAND} \
16731673
ADDITIONAL_DEV_APT_COMMAND=${ADDITIONAL_DEV_APT_COMMAND}
16741674

16751675

1676-
ARG AIRFLOW_PYTHON_VERSION="3.12.13"
1676+
ARG AIRFLOW_PYTHON_VERSION="3.13.13"
16771677
ENV AIRFLOW_PYTHON_VERSION=${AIRFLOW_PYTHON_VERSION}
16781678
ENV GOLANG_MAJOR_MINOR_VERSION="1.26.2"
16791679
ENV RUSTUP_HOME="/usr/local/rustup"

docker-stack-docs/build-arg-ref.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Those are the most common arguments that you use when you want to build a custom
3232
+==========================================+===========================================+=============================================+
3333
| ``AIRFLOW_VERSION`` | :subst-code:`|airflow-version|` | Version of Airflow. |
3434
+------------------------------------------+-------------------------------------------+---------------------------------------------+
35-
| ``AIRFLOW_PYTHON_VERSION`` | ``3.12.13`` | Version of Python. |
35+
| ``AIRFLOW_PYTHON_VERSION`` | ``3.13.13`` | Version of Python. |
3636
+------------------------------------------+-------------------------------------------+---------------------------------------------+
3737
| ``AIRFLOW_EXTRAS`` | (see below the table) | Default extras with which Airflow is |
3838
| | | installed. |

docker-stack-docs/docker-examples/customizing/add-build-essential-custom.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ docker build . \
3333
--pull \
3434
--build-arg BASE_IMAGE="debian:bookworm-slim" \
3535
--build-arg AIRFLOW_VERSION="${AIRFLOW_VERSION}" \
36-
--build-arg AIRFLOW_PYTHON_VERSION="3.12.13" \
36+
--build-arg AIRFLOW_PYTHON_VERSION="3.13.13" \
3737
--build-arg ADDITIONAL_PYTHON_DEPS="mpi4py==4.1.1" \
3838
--build-arg ADDITIONAL_DEV_APT_DEPS="libopenmpi-dev" \
3939
--build-arg ADDITIONAL_RUNTIME_APT_DEPS="openmpi-common" \

docker-stack-docs/docker-examples/customizing/custom-sources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ docker build . -f Dockerfile \
3333
--pull \
3434
--platform 'linux/amd64' \
3535
--build-arg BASE_IMAGE="debian:bookworm-slim" \
36-
--build-arg AIRFLOW_PYTHON_VERSION="3.12.13" \
36+
--build-arg AIRFLOW_PYTHON_VERSION="3.13.13" \
3737
--build-arg AIRFLOW_VERSION="${AIRFLOW_VERSION}" \
3838
--build-arg ADDITIONAL_AIRFLOW_EXTRAS="slack,odbc" \
3939
--build-arg ADDITIONAL_PYTHON_DEPS=" \

docker-stack-docs/docker-examples/customizing/pypi-dev-runtime-deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export DOCKER_BUILDKIT=1
3333
docker build . \
3434
--pull \
3535
--build-arg BASE_IMAGE="debian:bookworm-slim" \
36-
--build-arg AIRFLOW_PYTHON_VERSION="3.12.13" \
36+
--build-arg AIRFLOW_PYTHON_VERSION="3.13.13" \
3737
--build-arg AIRFLOW_VERSION="${AIRFLOW_VERSION}" \
3838
--build-arg ADDITIONAL_AIRFLOW_EXTRAS="jdbc" \
3939
--build-arg ADDITIONAL_PYTHON_DEPS="pandas==2.1.2" \

docker-stack-docs/docker-examples/customizing/pypi-extras-and-deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export DOCKER_BUILDKIT=1
3232
docker build . \
3333
--pull \
3434
--build-arg BASE_IMAGE="debian:bookworm-slim" \
35-
--build-arg AIRFLOW_PYTHON_VERSION="3.12.13" \
35+
--build-arg AIRFLOW_PYTHON_VERSION="3.13.13" \
3636
--build-arg AIRFLOW_VERSION="${AIRFLOW_VERSION}" \
3737
--build-arg ADDITIONAL_AIRFLOW_EXTRAS="mssql,hdfs" \
3838
--build-arg ADDITIONAL_PYTHON_DEPS="oauth2client" \

docker-stack-docs/docker-examples/customizing/pypi-selected-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export DOCKER_BUILDKIT=1
3131

3232
docker build . \
3333
--build-arg BASE_IMAGE="debian:bookworm-slim" \
34-
--build-arg AIRFLOW_PYTHON_VERSION="3.12.13" \
34+
--build-arg AIRFLOW_PYTHON_VERSION="3.13.13" \
3535
--build-arg AIRFLOW_VERSION="${AIRFLOW_VERSION}" \
3636
--tag "my-pypi-selected-version:0.0.1"
3737
# [END build]

docker-stack-docs/docker-examples/restricted/restricted_environments.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export DOCKER_BUILDKIT=1
4848
docker build . \
4949
--pull \
5050
--build-arg BASE_IMAGE="debian:bookworm-slim" \
51-
--build-arg AIRFLOW_PYTHON_VERSION="3.12.13" \
51+
--build-arg AIRFLOW_PYTHON_VERSION="3.13.13" \
5252
--build-arg AIRFLOW_INSTALLATION_METHOD="apache-airflow" \
5353
--build-arg AIRFLOW_VERSION="${AIRFLOW_VERSION}" \
5454
--build-arg INSTALL_MYSQL_CLIENT="false" \

scripts/ci/prek/common_prek_utils.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from contextlib import contextmanager
3030
from pathlib import Path
3131
from tempfile import NamedTemporaryFile, _TemporaryFileWrapper
32+
from typing import Any
3233

3334
AIRFLOW_ROOT_PATH = Path(__file__).parents[3].resolve()
3435
AIRFLOW_CORE_ROOT_PATH = AIRFLOW_ROOT_PATH / "airflow-core"
@@ -118,19 +119,35 @@ def read_airflow_version() -> str:
118119
)
119120

120121

122+
def _read_global_constants_assignment(name: str) -> Any:
123+
"""Read a top-level assignment from global_constants.py."""
124+
tree = ast.parse(GLOBAL_CONSTANTS_PATH.read_text())
125+
for node in tree.body:
126+
if isinstance(node, ast.Assign):
127+
for target in node.targets:
128+
if isinstance(target, ast.Name) and target.id == name:
129+
return ast.literal_eval(node.value)
130+
raise RuntimeError(f"{name} not found in global_constants.py")
131+
132+
121133
def read_allowed_kubernetes_versions() -> list[str]:
122134
"""Parse ALLOWED_KUBERNETES_VERSIONS from global_constants.py (single source of truth).
123135
124136
Returns versions without the ``v`` prefix, e.g. ``["1.30.13", "1.31.12", ...]``.
125137
"""
126-
tree = ast.parse(GLOBAL_CONSTANTS_PATH.read_text())
127-
for node in tree.body:
128-
if isinstance(node, ast.Assign):
129-
for target in node.targets:
130-
if isinstance(target, ast.Name) and target.id == "ALLOWED_KUBERNETES_VERSIONS":
131-
versions: list[str] = ast.literal_eval(node.value)
132-
return [v.lstrip("v") for v in versions]
133-
raise RuntimeError("ALLOWED_KUBERNETES_VERSIONS not found in global_constants.py")
138+
versions: list[str] = _read_global_constants_assignment("ALLOWED_KUBERNETES_VERSIONS")
139+
return [v.lstrip("v") for v in versions]
140+
141+
142+
def read_default_python_major_minor_version_for_images() -> str:
143+
"""Parse DEFAULT_PYTHON_MAJOR_MINOR_VERSION_FOR_IMAGES from global_constants.py."""
144+
value = _read_global_constants_assignment("DEFAULT_PYTHON_MAJOR_MINOR_VERSION_FOR_IMAGES")
145+
if not isinstance(value, str):
146+
raise RuntimeError(
147+
"DEFAULT_PYTHON_MAJOR_MINOR_VERSION_FOR_IMAGES in global_constants.py "
148+
f"must be a string, got {type(value).__name__}"
149+
)
150+
return value
134151

135152

136153
def pre_process_mypy_files(files: list[str]) -> list[str]:

0 commit comments

Comments
 (0)