Skip to content

Commit

Permalink
Fix more mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tolik0 committed May 23, 2024
1 parent d3b2591 commit afea860
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from typing import Any, Iterable, List, Mapping, Optional, Union

from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
from airbyte_cdk.sources.declarative.partition_routers.partition_router import PartitionRouter
from airbyte_cdk.sources.declarative.requesters.request_option import RequestOption, RequestOptionType
from airbyte_cdk.sources.declarative.stream_slicers.stream_slicer import StreamSlicer
from airbyte_cdk.sources.types import Config, StreamSlice, StreamState


@dataclass
class ListPartitionRouter(PartitionRouter):
class ListPartitionRouter(StreamSlicer):
"""
Partition router that iterates over the values of a list
If values is a string, then evaluate it as literal and assert the resulting literal is a list
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from dataclasses import InitVar, dataclass
from typing import Any, Iterable, Mapping, Optional

from airbyte_cdk.sources.declarative.partition_routers.partition_router import PartitionRouter
from airbyte_cdk.sources.declarative.stream_slicers.stream_slicer import StreamSlicer
from airbyte_cdk.sources.types import StreamSlice, StreamState


@dataclass
class SinglePartitionRouter(PartitionRouter):
class SinglePartitionRouter(StreamSlicer):
"""Partition router returning only a stream slice"""

parameters: InitVar[Mapping[str, Any]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import dpath.util
from airbyte_cdk.models import AirbyteMessage, SyncMode, Type
from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
from airbyte_cdk.sources.declarative.partition_routers.partition_router import PartitionRouter
from airbyte_cdk.sources.declarative.requesters.request_option import RequestOption, RequestOptionType
from airbyte_cdk.sources.declarative.stream_slicers.stream_slicer import StreamSlicer
from airbyte_cdk.sources.types import Config, Record, StreamSlice, StreamState

if TYPE_CHECKING:
Expand Down Expand Up @@ -42,7 +42,7 @@ def __post_init__(self, parameters: Mapping[str, Any]) -> None:


@dataclass
class SubstreamPartitionRouter(PartitionRouter):
class SubstreamPartitionRouter(StreamSlicer):
"""
Partition router that iterates over the parent's stream records and emits slices
Will populate the state with `partition_field` and `parent_slice` so they can be accessed by other components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from abc import abstractmethod
from dataclasses import dataclass
from typing import Iterable
from typing import Iterable, Optional

from airbyte_cdk.sources.declarative.requesters.request_options.request_options_provider import RequestOptionsProvider
from airbyte_cdk.sources.types import StreamSlice
from airbyte_cdk.sources.types import StreamSlice, StreamState


@dataclass
Expand All @@ -28,3 +28,21 @@ def stream_slices(self) -> Iterable[StreamSlice]:
:return: List of stream slices
"""

def set_parent_state(self, stream_state: StreamState) -> None:
"""
Set the state of the parent streams.
Args:
stream_state: The state of the streams to be set. This method can be overridden by subclasses.
"""
pass

def get_parent_state(self) -> Optional[StreamState]:
"""
Get the state of the parent streams.
Returns:
The current state of the parent streams. This method can be overridden by subclasses.
"""
return None
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest
from airbyte_cdk.sources.declarative.incremental.declarative_cursor import DeclarativeCursor
from airbyte_cdk.sources.declarative.incremental.per_partition_cursor import PerPartitionCursor, PerPartitionKeySerializer, StreamSlice
from airbyte_cdk.sources.declarative.partition_routers.partition_router import PartitionRouter
from airbyte_cdk.sources.declarative.stream_slicers.stream_slicer import StreamSlicer
from airbyte_cdk.sources.types import Record

PARTITION = {
Expand Down Expand Up @@ -105,7 +105,7 @@ def build(self):

@pytest.fixture()
def mocked_partition_router():
return Mock(spec=PartitionRouter)
return Mock(spec=StreamSlicer)


@pytest.fixture()
Expand Down

0 comments on commit afea860

Please sign in to comment.