From e43f69518e0049f441e50bffcdf77187c2a23f09 Mon Sep 17 00:00:00 2001 From: Yeonguk Date: Mon, 15 Dec 2025 17:46:04 +0900 Subject: [PATCH] Refactor deprecated SQLA test_dagwarning.py --- .pre-commit-config.yaml | 1 + airflow-core/tests/unit/models/test_dagwarning.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 81e24f2e8a3b3..4c9f240474f64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -413,6 +413,7 @@ repos: ^airflow-ctl.*\.py$| ^airflow-core/src/airflow/models/.*\.py$| ^airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_assets.py$| + ^airflow-core/tests/unit/models/test_dagwarning.py$| ^task_sdk.*\.py$ pass_filenames: true - id: update-supported-versions diff --git a/airflow-core/tests/unit/models/test_dagwarning.py b/airflow-core/tests/unit/models/test_dagwarning.py index 18a61e15d72eb..167244afbc1f2 100644 --- a/airflow-core/tests/unit/models/test_dagwarning.py +++ b/airflow-core/tests/unit/models/test_dagwarning.py @@ -21,6 +21,7 @@ from unittest.mock import MagicMock import pytest +from sqlalchemy import select from sqlalchemy.exc import OperationalError from airflow.models import DagModel @@ -55,7 +56,7 @@ def test_purge_inactive_dag_warnings(self, session, testing_dag_bundle): DagWarning.purge_inactive_dag_warnings(session) - remaining_dag_warnings = session.query(DagWarning).all() + remaining_dag_warnings = session.scalars(select(DagWarning)).all() assert len(remaining_dag_warnings) == 1 assert remaining_dag_warnings[0].dag_id == "dag_2"