Skip to content

Commit 1defe9e

Browse files
fix: Fix ruff format and mypy errors in model_to_component_factory
Co-Authored-By: alfredo.garcia@airbyte.io <freddy.garcia7.fg@gmail.com>
1 parent a2d4b56 commit 1defe9e

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import re
1212
from functools import partial
1313
from typing import (
14+
TYPE_CHECKING,
1415
Any,
1516
Callable,
1617
Dict,
@@ -27,6 +28,11 @@
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+
3036
from airbyte_protocol_dataclasses.models import ConfiguredAirbyteStream
3137
from isodate import parse_duration
3238
from 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

Comments
 (0)