Skip to content

Commit bba1a93

Browse files
committed
Airbyte CDK: fix mypy
1 parent 3fe7ac4 commit bba1a93

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

airbyte_cdk/sources/declarative/decoders/json_decoder.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
from dataclasses import InitVar, dataclass
77
from gzip import decompress
8-
from typing import Any, Generator, Mapping
8+
from typing import Any, Generator, Mapping, MutableMapping
99

1010
import requests
1111
from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
@@ -25,7 +25,7 @@ class JsonDecoder(Decoder):
2525
def is_stream_response(self) -> bool:
2626
return False
2727

28-
def decode(self, response: requests.Response) -> Generator[Mapping[str, Any], None, None]:
28+
def decode(self, response: requests.Response) -> Generator[MutableMapping[str, Any], None, None]:
2929
"""
3030
Given the response is an empty string or an emtpy list, the function will return a generator with an empty mapping.
3131
"""
@@ -41,7 +41,7 @@ def decode(self, response: requests.Response) -> Generator[Mapping[str, Any], No
4141
@staticmethod
4242
def parse_body_json(
4343
body_json: Mapping[str, Any] | list,
44-
) -> Generator[Mapping[str, Any], None, None]:
44+
) -> Generator[MutableMapping[str, Any], None, None]:
4545
if not isinstance(body_json, list):
4646
body_json = [body_json]
4747
if len(body_json) == 0:
@@ -61,7 +61,7 @@ class IterableDecoder(Decoder):
6161
def is_stream_response(self) -> bool:
6262
return True
6363

64-
def decode(self, response: requests.Response) -> Generator[Mapping[str, Any], None, None]:
64+
def decode(self, response: requests.Response) -> Generator[MutableMapping[str, Any], None, None]:
6565
for line in response.iter_lines():
6666
yield {"record": line.decode()}
6767

@@ -77,7 +77,7 @@ class JsonlDecoder(Decoder):
7777
def is_stream_response(self) -> bool:
7878
return True
7979

80-
def decode(self, response: requests.Response) -> Generator[Mapping[str, Any], None, None]:
80+
def decode(self, response: requests.Response) -> Generator[MutableMapping[str, Any], None, None]:
8181
# TODO???: set delimiter? usually it is `\n` but maybe it would be useful to set optional?
8282
# https://github.com/airbytehq/airbyte-internal-issues/issues/8436
8383
for record in response.iter_lines():
@@ -88,6 +88,6 @@ def decode(self, response: requests.Response) -> Generator[Mapping[str, Any], No
8888
class GzipJsonDecoder(JsonDecoder):
8989
encoding: str = "utf-8"
9090

91-
def decode(self, response: requests.Response) -> Generator[Mapping[str, Any], None, None]:
91+
def decode(self, response: requests.Response) -> Generator[MutableMapping[str, Any], None, None]:
9292
raw_string = decompress(response.content).decode(encoding=self.encoding)
9393
yield from self.parse_body_json(orjson.loads(raw_string))

0 commit comments

Comments
 (0)