You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2026/04/28 02:07:54 UTC

(airflow) branch main updated: Fix dev/registry tomllib import on Python 3.10 (#65987)

This is an automated email from the ASF dual-hosted git repository.

kaxil pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 0c1326535d1 Fix dev/registry tomllib import on Python 3.10 (#65987)
0c1326535d1 is described below

commit 0c1326535d16b824748b9c9c01a1b05e8538967f
Author: Kaxil Naik <ka...@apache.org>
AuthorDate: Tue Apr 28 03:07:46 2026 +0100

    Fix dev/registry tomllib import on Python 3.10 (#65987)
    
    `dev/registry/extract_versions.py` and `extract_metadata.py` both
    `import tomllib` directly. `tomllib` is Python 3.11+ stdlib. uv on
    bare CI runners may pick Python 3.10 and the scripts crash on import:
    
        File "dev/registry/extract_versions.py", line 49, in <module>
            import tomllib
        ModuleNotFoundError: No module named 'tomllib'
    
    Failure observed in `Registry Backfill` workflow run 25028614525 -- every
    backfill job fails before extracting any data.
    
    The bug was latent: previously `breeze registry backfill` invoked
    `uv run python ...` from the airflow workspace root (without
    `--project dev/registry`), so uv used the airflow workspace's pyproject
    to resolve Python. After #65972 landed `--project dev/registry`, uv
    started honouring this pyproject's constraint specifically, and CI
    runners with Python 3.10 as default started picking it.
    
    This adds the standard `tomli` fallback to both scripts and declares
    `tomli` as a runtime dep on Python <3.11. The `[build-system].requires`
    already conditionally pulled `tomli`, but it wasn't a runtime dep so
    the scripts couldn't actually use it -- this PR adds it where it
    belongs (under `[project].dependencies`).
    
    The alternative -- bumping `requires-python` to `>=3.11` -- breaks the
    airflow workspace sync on the 3.10 CI image build, since uv refuses
    to mix Python versions across workspace members.
---
 dev/registry/extract_metadata.py | 6 +++++-
 dev/registry/extract_versions.py | 5 ++++-
 dev/registry/pyproject.toml      | 3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/dev/registry/extract_metadata.py b/dev/registry/extract_metadata.py
index 7c0f91d55c2..1bd866f760d 100644
--- a/dev/registry/extract_metadata.py
+++ b/dev/registry/extract_metadata.py
@@ -42,7 +42,11 @@ from dataclasses import asdict, dataclass, field
 from pathlib import Path
 from typing import Any
 
-import tomllib
+try:
+    import tomllib  # Python 3.11+ stdlib
+except ModuleNotFoundError:  # pragma: no cover -- Python 3.10 fallback
+    import tomli as tomllib
+
 import yaml
 from registry_contract_models import validate_providers_catalog
 
diff --git a/dev/registry/extract_versions.py b/dev/registry/extract_versions.py
index 5fb5719a95f..db6c352c0d0 100644
--- a/dev/registry/extract_versions.py
+++ b/dev/registry/extract_versions.py
@@ -46,7 +46,10 @@ from datetime import datetime, timezone
 from pathlib import Path
 from typing import Any
 
-import tomllib
+try:
+    import tomllib  # Python 3.11+ stdlib
+except ModuleNotFoundError:  # pragma: no cover -- Python 3.10 fallback
+    import tomli as tomllib
 from registry_contract_models import validate_provider_version_metadata
 
 try:
diff --git a/dev/registry/pyproject.toml b/dev/registry/pyproject.toml
index 1b53cb882f0..50cc50db15d 100644
--- a/dev/registry/pyproject.toml
+++ b/dev/registry/pyproject.toml
@@ -35,6 +35,9 @@ classifiers = ["Private :: Do Not Upload"]
 dependencies = [
     "pydantic>=2.12.0",
     "pyyaml>=6.0.3",
+    # extract_versions.py and extract_metadata.py read pyproject.toml via
+    # tomllib (3.11+ stdlib). Fall back to the `tomli` backport on 3.10.
+    "tomli>=2.0.0; python_version < '3.11'",
 ]
 
 [dependency-groups]