You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by vi...@apache.org on 2025/11/24 18:36:07 UTC
(airflow) branch main updated: Fix mypy errors in airflow-core in api_fastapi/common/db/dag_runs.py (#58353)
This is an automated email from the ASF dual-hosted git repository.
vincbeck 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 877ba65d77b Fix mypy errors in airflow-core in api_fastapi/common/db/dag_runs.py (#58353)
877ba65d77b is described below
commit 877ba65d77b0720270e4f677012bb24e2f80cc31
Author: Anusha Kovi <pa...@gmail.com>
AuthorDate: Mon Nov 24 10:36:00 2025 -0800
Fix mypy errors in airflow-core in api_fastapi/common/db/dag_runs.py (#58353)
---
.../src/airflow/api_fastapi/common/db/dag_runs.py | 17 +++++++----------
.../core_api/routes/public/test_dag_stats.py | 3 +++
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py b/airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py
index f68f3ab2186..4eb586c851b 100644
--- a/airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py
+++ b/airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py
@@ -17,12 +17,9 @@
from __future__ import annotations
-from typing import cast
-
from sqlalchemy import func, select
from sqlalchemy.orm import joinedload, selectinload
from sqlalchemy.orm.interfaces import LoaderOption
-from sqlalchemy.sql import ColumnElement
from airflow.models.dag import DagModel
from airflow.models.dag_version import DagVersion
@@ -32,14 +29,14 @@ from airflow.models.taskinstancehistory import TaskInstanceHistory
dagruns_select_with_state_count = (
select(
- DagRun.dag_id,
- DagRun.state,
- DagModel.dag_display_name,
- cast("ColumnElement[int]", func.count(DagRun.state).label("count")),
+ DagRun.__table__.c.dag_id,
+ DagRun.__table__.c.state,
+ DagModel.__table__.c.dag_display_name,
+ func.count(DagRun.__table__.c.state).label("count"),
)
- .join(DagModel, DagRun.dag_id == DagModel.dag_id)
- .group_by(DagRun.dag_id, DagRun.state, DagModel.dag_display_name)
- .order_by(DagRun.dag_id)
+ .join(DagModel, DagRun.__table__.c.dag_id == DagModel.__table__.c.dag_id)
+ .group_by(DagRun.__table__.c.dag_id, DagRun.__table__.c.state, DagModel.__table__.c.dag_display_name)
+ .order_by(DagRun.__table__.c.dag_id)
)
diff --git a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_stats.py b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_stats.py
index 36d327528be..a3f8038fe20 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_stats.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_stats.py
@@ -67,6 +67,7 @@ class TestDagStatsEndpoint:
owners="test_owner,another_test_owner",
next_dagrun=datetime(2021, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
)
+ dag_1._dag_display_property_value = DAG1_DISPLAY_NAME
dag_1_run_1 = DagRun(
dag_id=DAG1_ID,
run_id="test_dag_run_id_1",
@@ -93,6 +94,7 @@ class TestDagStatsEndpoint:
owners="test_owner,another_test_owner",
next_dagrun=datetime(2021, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
)
+ dag_2._dag_display_property_value = DAG2_DISPLAY_NAME
dag_2_run_1 = DagRun(
dag_id=dag_2.dag_id,
run_id="test_dag_2_run_id_1",
@@ -111,6 +113,7 @@ class TestDagStatsEndpoint:
owners="test_owner,another_test_owner",
next_dagrun=datetime(2021, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
)
+ dag_3._dag_display_property_value = DAG3_DISPLAY_NAME
dag_3_run_1 = DagRun(
dag_id=dag_3.dag_id,
run_id="test_dag_3_run_id_1",