Skip to content

Commit ddf1f1a

Browse files
committed
fix: fix mypy type error in dagrun.py
1 parent 9666347 commit ddf1f1a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

airflow-core/src/airflow/models/dagrun.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@
9797

9898
from opentelemetry.sdk.trace import Span
9999
from pydantic import NonNegativeInt
100-
from sqlalchemy.orm import Query, Session
100+
from sqlalchemy.engine import ScalarResult
101+
from sqlalchemy.orm import Session
101102
from sqlalchemy.sql.elements import Case, ColumnElement
102103

103104
from airflow.models.dag_version import DagVersion
@@ -348,7 +349,7 @@ def __init__(
348349
self.conf = conf or {}
349350
if state is not None:
350351
self.state = state
351-
if queued_at is NOTSET:
352+
if isinstance(queued_at, ArgNotSet):
352353
self.queued_at = timezone.utcnow() if state == DagRunState.QUEUED else None
353354
elif queued_at is not None:
354355
self.queued_at = queued_at
@@ -572,11 +573,11 @@ def active_runs_of_dags(
572573
)
573574
if exclude_backfill:
574575
query = query.where(cls.run_type != DagRunType.BACKFILL_JOB)
575-
return dict(session.execute(query).all())
576+
return {dag_id: count for dag_id, count in session.execute(query)}
576577

577578
@classmethod
578579
@retry_db_transaction
579-
def get_running_dag_runs_to_examine(cls, session: Session) -> Query:
580+
def get_running_dag_runs_to_examine(cls, session: Session) -> ScalarResult[DagRun]:
580581
"""
581582
Return the next DagRuns that the scheduler should attempt to schedule.
582583
@@ -615,7 +616,7 @@ def get_running_dag_runs_to_examine(cls, session: Session) -> Query:
615616

616617
@classmethod
617618
@retry_db_transaction
618-
def get_queued_dag_runs_to_set_running(cls, session: Session) -> Query:
619+
def get_queued_dag_runs_to_set_running(cls, session: Session) -> ScalarResult[DagRun]:
619620
"""
620621
Return the next queued DagRuns that the scheduler should attempt to schedule.
621622

0 commit comments

Comments
 (0)