This is an automated email from the ASF dual-hosted git repository.
jedcunningham 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 ee643dffc40 Use sqlite3.sqlite_version_info instead of hand-parsing
the version string (#71115)
ee643dffc40 is described below
commit ee643dffc405c349ddc2b8e5f2e13ff8d97c46f6
Author: Jed Cunningham <[email protected]>
AuthorDate: Fri Aug 7 09:16:04 2026 -0600
Use sqlite3.sqlite_version_info instead of hand-parsing the version string
(#71115)
sqlite3 has exposed sqlite_version_info as a ready-made int tuple since
forever, making the regex parser that turned sqlite_version into the same
shape redundant.
---
airflow-core/src/airflow/configuration.py | 11 +----------
airflow-core/tests/unit/core/test_configuration.py | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/airflow-core/src/airflow/configuration.py
b/airflow-core/src/airflow/configuration.py
index 4eb92054cea..f9dd0af27b1 100644
--- a/airflow-core/src/airflow/configuration.py
+++ b/airflow-core/src/airflow/configuration.py
@@ -58,8 +58,6 @@ if not sys.warnoptions:
warnings.filterwarnings(action="default", category=DeprecationWarning,
module="airflow")
warnings.filterwarnings(action="default",
category=PendingDeprecationWarning, module="airflow")
-_SQLITE3_VERSION_PATTERN = re.compile(r"(?P<version>^\d+(?:\.\d+)*)\D?.*$")
-
ConfigType = str | int | float | bool
ConfigOptionsDictType = dict[str, ConfigType]
ConfigSectionSourcesType = dict[str, str | tuple[str, str]]
@@ -99,13 +97,6 @@ class ConfigModifications:
self.default_updates[(section, option)] = new_default
-def _parse_sqlite_version(s: str) -> tuple[int, ...]:
- match = _SQLITE3_VERSION_PATTERN.match(s)
- if match is None:
- return ()
- return tuple(int(p) for p in match.group("version").split("."))
-
-
@overload
def expand_env_var(env_var: None) -> None: ...
@@ -426,7 +417,7 @@ class AirflowConfigParser(_SharedAirflowConfigParser):
import sqlite3
min_sqlite_version = (3, 15, 0)
- if _parse_sqlite_version(sqlite3.sqlite_version) >= min_sqlite_version:
+ if sqlite3.sqlite_version_info >= min_sqlite_version:
return
from airflow.utils.docs import get_docs_url
diff --git a/airflow-core/tests/unit/core/test_configuration.py
b/airflow-core/tests/unit/core/test_configuration.py
index 87a083c7e02..815574a30e1 100644
--- a/airflow-core/tests/unit/core/test_configuration.py
+++ b/airflow-core/tests/unit/core/test_configuration.py
@@ -1982,6 +1982,25 @@ def test_provider_sections_do_not_overlap_with_core():
)
[email protected](
+ ("sqlite_version_info", "expect_error"),
+ [
+ ((3, 15, 0), False),
+ ((3, 14, 9), True),
+ ],
+)
+def test_validate_sqlite3_version(sqlite_version_info, expect_error,
monkeypatch):
+ """_validate_sqlite3_version compares against sqlite3.sqlite_version_info,
not a parsed string."""
+ monkeypatch.setenv("AIRFLOW__DATABASE__SQL_ALCHEMY_CONN",
"sqlite:////tmp/airflow.db")
+ test_conf = AirflowConfigParser()
+ with mock.patch("sqlite3.sqlite_version_info", sqlite_version_info):
+ if expect_error:
+ with pytest.raises(AirflowConfigException, match="SQLite C library
too old"):
+ test_conf._validate_sqlite3_version()
+ else:
+ test_conf._validate_sqlite3_version()
+
+
@skip_if_force_lowest_dependencies_marker
class TestProviderConfigPriority:
"""Tests that conf.get and conf.has_option respect provider metadata and
cfg fallbacks with correct priority."""