Skip to content

Commit 8cd988d

Browse files
authored
Fix MyPy type errors in test_dags.py (apache#56735) (apache#56770)
* Fix MyPy type errors in test_dags.py * Replace datetime with pendulum for UTC timezone handling in test_dags.py
1 parent 95c7eaa commit 8cd988d

File tree

1 file changed

+3
-3
lines changed
  • airflow-core/tests/unit/api_fastapi/core_api/routes/ui

1 file changed

+3
-3
lines changed

airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_dags.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# under the License.
1717
from __future__ import annotations
1818

19-
from datetime import datetime, timezone
2019
from typing import TYPE_CHECKING
2120
from unittest import mock
2221

@@ -56,7 +55,7 @@ def setup_dag_runs(self, session=None) -> None:
5655
for dag_id in [DAG1_ID, DAG2_ID, DAG3_ID, DAG4_ID, DAG5_ID]:
5756
dag_runs_count = 5 if dag_id in [DAG1_ID, DAG2_ID] else 2
5857
for i in range(dag_runs_count):
59-
start_date = datetime(2021 + i, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
58+
start_date = pendulum.datetime(2021 + i, 1, 1, 0, 0, 0, tz="UTC")
6059
dag_run = DagRun(
6160
dag_id=dag_id,
6261
run_id=f"run_id_{i + 1}",
@@ -67,7 +66,8 @@ def setup_dag_runs(self, session=None) -> None:
6766
state=(DagRunState.FAILED if i % 2 == 0 else DagRunState.SUCCESS),
6867
triggered_by=DagRunTriggeredByType.TEST,
6968
)
70-
dag_run.end_date = dag_run.start_date + pendulum.duration(hours=1)
69+
if dag_run.start_date is not None:
70+
dag_run.end_date = dag_run.start_date.add(hours=1)
7171
session.add(dag_run)
7272
session.commit()
7373

0 commit comments

Comments
 (0)