Skip to content

Commit 9b94c1b

Browse files
committed
Remove unused Asset import and fix test fixtures for new annotation
The annotation on AssetAndTimeSchedule.__init__ was migrated to Collection[SerializedAsset] | SerializedAssetBase, leaving the TYPE_CHECKING-only Asset import unreferenced and breaking mypy on two test files that passed SDK Assets to the core class. The scheduler tests now import AssetAndTimeSchedule (and the matching CronTriggerTimetable) from airflow.sdk so the types align with how DAG authors use it; the timetable test fixture mirrors core_asset_timetable by constructing SerializedAsset directly.
1 parent 322fb8c commit 9b94c1b

3 files changed

Lines changed: 7 additions & 13 deletions

File tree

airflow-core/src/airflow/timetables/assets.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
import pendulum
3434

35-
from airflow.sdk.definitions.asset import Asset
3635
from airflow.timetables.base import DagRunInfo, DataInterval, TimeRestriction
3736

3837

airflow-core/tests/unit/jobs/test_scheduler_job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@
9090
DAG,
9191
Asset,
9292
AssetAlias,
93+
AssetAndTimeSchedule,
9394
AssetWatcher,
9495
CronPartitionTimetable,
96+
CronTriggerTimetable,
9597
IdentityMapper,
9698
StartOfHourMapper,
9799
task,
@@ -100,9 +102,7 @@
100102
from airflow.sdk.definitions.timetables.assets import PartitionedAssetTimetable
101103
from airflow.serialization.definitions.dag import SerializedDAG
102104
from airflow.serialization.serialized_objects import LazyDeserializedDAG
103-
from airflow.timetables.assets import AssetAndTimeSchedule
104105
from airflow.timetables.base import DagRunInfo, DataInterval
105-
from airflow.timetables.trigger import CronTriggerTimetable
106106
from airflow.utils.session import create_session, provide_session
107107
from airflow.utils.sqlalchemy import with_row_locks
108108
from airflow.utils.state import CallbackState, DagRunState, State, TaskInstanceState

airflow-core/tests/unit/timetables/test_assets_timetable.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,11 @@ def sdk_asset_and_time_timetable(test_timetable, test_assets) -> SdkAssetAndTime
137137

138138

139139
@pytest.fixture
140-
def core_asset_and_time_timetable(
141-
test_timetable: MockTimetable, test_assets: list[Asset]
142-
) -> CoreAssetAndTimeSchedule:
143-
"""
144-
Pytest fixture for creating an AssetAndTimeSchedule object.
145-
146-
:param test_timetable: The test timetable instance.
147-
:param test_assets: A list of Asset instances.
148-
"""
149-
return CoreAssetAndTimeSchedule(timetable=test_timetable, assets=test_assets)
140+
def core_asset_and_time_timetable(test_timetable: MockTimetable) -> CoreAssetAndTimeSchedule:
141+
return CoreAssetAndTimeSchedule(
142+
timetable=test_timetable,
143+
assets=SerializedAssetAll([SerializedAsset("test_asset", "test://asset/", "asset", {}, [])]),
144+
)
150145

151146

152147
@pytest.fixture

0 commit comments

Comments
 (0)