1111import re
1212from functools import partial
1313from typing import (
14+ TYPE_CHECKING ,
1415 Any ,
1516 Callable ,
1617 Dict ,
2728 get_type_hints ,
2829)
2930
31+ if TYPE_CHECKING :
32+ from airbyte_cdk .legacy .sources .declarative .incremental .datetime_based_cursor import (
33+ DatetimeBasedCursor ,
34+ )
35+
3036from airbyte_protocol_dataclasses .models import ConfiguredAirbyteStream
3137from isodate import parse_duration
3238from pydantic .v1 import BaseModel
@@ -3580,7 +3586,11 @@ def _get_state_delegating_stream_model(
35803586 ]
35813587 incremental_sync_sources = [s for s in incremental_sync_sources if s is not None ]
35823588 if incremental_sync_sources and self ._is_cursor_older_than_retention_period (
3583- stream_state , incremental_sync_sources , model .api_retention_period , model .name , config
3589+ stream_state ,
3590+ incremental_sync_sources ,
3591+ model .api_retention_period ,
3592+ model .name ,
3593+ config ,
35843594 ):
35853595 return model .full_refresh_stream
35863596
@@ -3603,10 +3613,6 @@ def _is_cursor_older_than_retention_period(
36033613 invalid/unparseable (should use full refresh).
36043614 Returns False if the cursor is within the retention period (safe to use incremental).
36053615 """
3606- from airbyte_cdk .legacy .sources .declarative .incremental .datetime_based_cursor import (
3607- DatetimeBasedCursor ,
3608- )
3609-
36103616 for incremental_sync in incremental_sync_sources :
36113617 if isinstance (incremental_sync , IncrementingCountCursorModel ):
36123618 raise ValueError (
@@ -3652,10 +3658,10 @@ def _create_cursor_for_age_check(
36523658 ) -> "DatetimeBasedCursor" :
36533659 """Create a lightweight DatetimeBasedCursor for cursor age validation."""
36543660 from airbyte_cdk .legacy .sources .declarative .incremental .datetime_based_cursor import (
3655- DatetimeBasedCursor ,
3661+ DatetimeBasedCursor as _DatetimeBasedCursor ,
36563662 )
36573663
3658- return DatetimeBasedCursor (
3664+ return _DatetimeBasedCursor (
36593665 start_datetime = "2000-01-01T00:00:00Z" ,
36603666 cursor_field = model .cursor_field ,
36613667 datetime_format = model .datetime_format ,
@@ -4067,7 +4073,7 @@ def _instantiate_parent_stream_state_manager(
40674073 model .stream .incremental_sync # type: ignore # if we are there, it is because there is incremental_dependency and therefore there is an incremental_sync on the parent stream
40684074 if isinstance (model .stream , DeclarativeStreamModel )
40694075 else self ._get_state_delegating_stream_model (
4070- has_parent_state , model .stream
4076+ has_parent_state , model .stream , config
40714077 ).incremental_sync
40724078 )
40734079 cursor_field = InterpolatedString .create (
0 commit comments