Skip to content

Commit

Permalink
CDK: rev mutableMapping -> Mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
  • Loading branch information
artem1205 committed Jan 3, 2025
1 parent 31c2b1a commit 9d33042
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import copy
import logging
from dataclasses import InitVar, dataclass
from typing import TYPE_CHECKING, Any, Iterable, List, Mapping, MutableMapping, Optional, Union
from typing import TYPE_CHECKING, Any, Iterable, List, Mapping, Optional, Union

import dpath

Expand Down Expand Up @@ -215,7 +215,7 @@ def _extract_extra_fields(
self,
parent_record: Mapping[str, Any] | AirbyteMessage,
extra_fields: Optional[List[List[str]]] = None,
) -> MutableMapping[str, Any]:
) -> Mapping[str, Any]:
"""
Extracts additional fields specified by their paths from the parent record.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,12 @@ def fetch_records(self, job: AsyncJob) -> Iterable[Mapping[str, Any]]:
for url in self.urls_extractor.extract_records(
self._polling_job_response_by_id[job.api_job_id()]
):
stream_slice = job.job_parameters()
stream_slice.extra_fields.update({"url": url})
job_slice = job.job_parameters()
stream_slice = StreamSlice(
partition=job_slice.partition,
cursor_slice=job_slice.cursor_slice,
extra_fields={**job_slice.extra_fields, "url": url},
)
for message in self.download_retriever.read_records({}, stream_slice):
if isinstance(message, Record):
yield message.data
Expand Down
16 changes: 3 additions & 13 deletions airbyte_cdk/sources/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@

from __future__ import annotations

from typing import (
Any,
ItemsView,
Iterator,
KeysView,
List,
Mapping,
MutableMapping,
Optional,
ValuesView,
)
from typing import Any, ItemsView, Iterator, KeysView, List, Mapping, Optional, ValuesView

import orjson

Expand Down Expand Up @@ -78,7 +68,7 @@ def __init__(
*,
partition: Mapping[str, Any],
cursor_slice: Mapping[str, Any],
extra_fields: Optional[MutableMapping[str, Any]] = None,
extra_fields: Optional[Mapping[str, Any]] = None,
) -> None:
"""
:param partition: The partition keys representing a unique partition in the stream.
Expand Down Expand Up @@ -112,7 +102,7 @@ def cursor_slice(self) -> Mapping[str, Any]:
return c

@property
def extra_fields(self) -> MutableMapping[str, Any]:
def extra_fields(self) -> Mapping[str, Any]:
"""Returns the extra fields that are not part of the partition."""
return self._extra_fields

Expand Down

0 comments on commit 9d33042

Please sign in to comment.