Skip to content

Commit 3eff135

Browse files
committed
chore: fix or noqa remaining mypy issues (now 100% pass)
1 parent 92e6994 commit 3eff135

File tree

16 files changed

+86
-61
lines changed

16 files changed

+86
-61
lines changed

airbyte_cdk/cli/source_declarative_manifest/_run.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ def handle_remote_manifest_command(args: list[str]) -> None:
152152
)
153153

154154

155-
def create_declarative_source(args: list[str]) -> ConcurrentDeclarativeSource:
155+
def create_declarative_source(
156+
args: list[str],
157+
) -> ConcurrentDeclarativeSource: # type: ignore [type-arg]
156158
"""Creates the source with the injected config.
157159
158160
This essentially does what other low-code sources do at build time, but at runtime,

airbyte_cdk/connector_builder/message_grouper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def _get_message_groups(
232232
current_slice_descriptor = self._parse_slice_description(message.log.message) # type: ignore[union-attr] # AirbyteMessage with MessageType.LOG has log.message
233233
current_slice_pages = []
234234
at_least_one_page_in_group = False
235-
elif message.type == MessageType.LOG and message.log.message.startswith(
235+
elif message.type == MessageType.LOG and message.log.message.startswith( # type: ignore[union-attr] # None doesn't have 'message'
236236
SliceLogger.SLICE_LOG_PREFIX
237237
): # type: ignore[union-attr] # AirbyteMessage with MessageType.LOG has log.message
238238
# parsing the first slice
@@ -280,7 +280,7 @@ def _get_message_groups(
280280
datetime_format_inferrer.accumulate(message.record)
281281
elif (
282282
message.type == MessageType.CONTROL
283-
and message.control.type == OrchestratorType.CONNECTOR_CONFIG
283+
and message.control.type == OrchestratorType.CONNECTOR_CONFIG # type: ignore[union-attr] # None doesn't have 'type'
284284
): # type: ignore[union-attr] # AirbyteMessage with MessageType.CONTROL has control.type
285285
yield message.control
286286
elif message.type == MessageType.STATE:
@@ -310,8 +310,8 @@ def _need_to_close_page(
310310
and message.type == MessageType.LOG
311311
and (
312312
MessageGrouper._is_page_http_request(json_message)
313-
or message.log.message.startswith("slice:")
314-
) # type: ignore[union-attr] # AirbyteMessage with MessageType.LOG has log.message
313+
or message.log.message.startswith("slice:") # type: ignore[union-attr] # AirbyteMessage with MessageType.LOG has log.message
314+
)
315315
)
316316

317317
@staticmethod

airbyte_cdk/destinations/vector_db_based/embedder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def embedding_dimensions(self) -> int:
107107
class OpenAIEmbedder(BaseOpenAIEmbedder):
108108
def __init__(self, config: OpenAIEmbeddingConfigModel, chunk_size: int):
109109
super().__init__(
110-
OpenAIEmbeddings(
110+
OpenAIEmbeddings( # type: ignore [call-arg]
111111
openai_api_key=config.openai_key, max_retries=15, disallowed_special=()
112112
),
113113
chunk_size,
@@ -118,7 +118,7 @@ class AzureOpenAIEmbedder(BaseOpenAIEmbedder):
118118
def __init__(self, config: AzureOpenAIEmbeddingConfigModel, chunk_size: int):
119119
# Azure OpenAI API has — as of 20230927 — a limit of 16 documents per request
120120
super().__init__(
121-
OpenAIEmbeddings(
121+
OpenAIEmbeddings( # type: ignore [call-arg]
122122
openai_api_key=config.openai_key,
123123
chunk_size=16,
124124
max_retries=15,

airbyte_cdk/entrypoint.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,18 @@ def handle_record_counts(
248248
case Type.RECORD:
249249
stream_message_count[
250250
HashableStreamDescriptor(
251-
name=message.record.stream, namespace=message.record.namespace
251+
name=message.record.stream, # type: ignore[union-attr] # record has `stream`
252+
namespace=message.record.namespace, # type: ignore[union-attr] # record has `namespace`
252253
)
253-
] += 1.0 # type: ignore[union-attr] # record has `stream` and `namespace`
254+
] += 1.0
254255
case Type.STATE:
255256
stream_descriptor = message_utils.get_stream_descriptor(message)
256257

257258
# Set record count from the counter onto the state message
258259
message.state.sourceStats = message.state.sourceStats or AirbyteStateStats() # type: ignore[union-attr] # state has `sourceStats`
259-
message.state.sourceStats.recordCount = stream_message_count.get(
260+
message.state.sourceStats.recordCount = stream_message_count.get( # type: ignore[union-attr] # state has `sourceStats`
260261
stream_descriptor, 0.0
261-
) # type: ignore[union-attr] # state has `sourceStats`
262+
)
262263

263264
# Reset the counter
264265
stream_message_count[stream_descriptor] = 0.0

airbyte_cdk/sources/declarative/datetime/min_max_datetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def create(
111111
if isinstance(interpolated_string_or_min_max_datetime, InterpolatedString) or isinstance(
112112
interpolated_string_or_min_max_datetime, str
113113
):
114-
return MinMaxDatetime(
114+
return MinMaxDatetime( # type: ignore [call-arg]
115115
datetime=interpolated_string_or_min_max_datetime, parameters=parameters
116116
)
117117
else:

airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def set_initial_state(self, stream_state: StreamState) -> None:
133133
:param stream_state: The state of the stream as returned by get_stream_state
134134
"""
135135
self._cursor = (
136-
stream_state.get(self.cursor_field.eval(self.config)) if stream_state else None
136+
stream_state.get(self.cursor_field.eval(self.config)) if stream_state else None # type: ignore [union-attr]
137137
) # type: ignore # cursor_field is converted to an InterpolatedString in __post_init__
138138

139139
def observe(self, stream_slice: StreamSlice, record: Record) -> None:
@@ -158,7 +158,9 @@ def observe(self, stream_slice: StreamSlice, record: Record) -> None:
158158
)
159159
if (
160160
self._is_within_daterange_boundaries(
161-
record, stream_slice.get(start_field), stream_slice.get(end_field)
161+
record,
162+
stream_slice.get(start_field), # type: ignore [arg-type]
163+
stream_slice.get(end_field), # type: ignore [arg-type]
162164
) # type: ignore # we know that stream_slices for these cursors will use a string representing an unparsed date
163165
and is_highest_observed_cursor_value
164166
):
@@ -368,7 +370,7 @@ def _get_request_options(
368370
self._partition_field_start.eval(self.config)
369371
)
370372
if self.end_time_option and self.end_time_option.inject_into == option_type:
371-
options[self.end_time_option.field_name.eval(config=self.config)] = stream_slice.get(
373+
options[self.end_time_option.field_name.eval(config=self.config)] = stream_slice.get( # type: ignore [union-attr]
372374
self._partition_field_end.eval(self.config)
373375
) # type: ignore # field_name is always casted to an interpolated string
374376
return options

airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _get_request_option(
130130
if value:
131131
params.update(
132132
{
133-
parent_config.request_option.field_name.eval(
133+
parent_config.request_option.field_name.eval( # type: ignore [union-attr]
134134
config=self.config
135135
): value
136136
}
@@ -162,7 +162,7 @@ def stream_slices(self) -> Iterable[StreamSlice]:
162162
extra_fields = None
163163
if parent_stream_config.extra_fields:
164164
extra_fields = [
165-
[field_path_part.eval(self.config) for field_path_part in field_path]
165+
[field_path_part.eval(self.config) for field_path_part in field_path] # type: ignore [union-attr]
166166
for field_path in parent_stream_config.extra_fields
167167
] # type: ignore # extra_fields is always casted to an interpolated string
168168

@@ -192,7 +192,10 @@ def stream_slices(self) -> Iterable[StreamSlice]:
192192
message=f"Parent stream returned records as invalid type {type(parent_record)}"
193193
)
194194
try:
195-
partition_value = dpath.get(parent_record, parent_field)
195+
partition_value = dpath.get(
196+
parent_record, # type: ignore [arg-type]
197+
parent_field,
198+
)
196199
except KeyError:
197200
continue
198201

@@ -228,7 +231,10 @@ def _extract_extra_fields(
228231
if extra_fields:
229232
for extra_field_path in extra_fields:
230233
try:
231-
extra_field_value = dpath.get(parent_record, extra_field_path)
234+
extra_field_value = dpath.get(
235+
parent_record, # type: ignore [arg-type]
236+
extra_field_path,
237+
)
232238
self.logger.debug(
233239
f"Extracted extra_field_path: {extra_field_path} with value: {extra_field_value}"
234240
)
@@ -291,7 +297,7 @@ def set_initial_state(self, stream_state: StreamState) -> None:
291297
if not parent_state and incremental_dependency:
292298
# Attempt to retrieve child state
293299
substream_state = list(stream_state.values())
294-
substream_state = substream_state[0] if substream_state else {}
300+
substream_state = substream_state[0] if substream_state else {} # type: ignore [assignment] # Incorrect type for assignment
295301
parent_state = {}
296302

297303
# Copy child state to parent streams with incremental dependencies

airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,18 @@ def _create_error_message(self, response: requests.Response) -> Optional[str]:
151151
:param response: The HTTP response which can be used during interpolation
152152
:return: The evaluated error message string to be emitted
153153
"""
154-
return self.error_message.eval(
154+
return self.error_message.eval( # type: ignore [no-any-return, union-attr]
155155
self.config, response=self._safe_response_json(response), headers=response.headers
156156
) # type: ignore # error_message is always cast to an interpolated string
157157

158158
def _response_matches_predicate(self, response: requests.Response) -> bool:
159159
return (
160160
bool(
161-
self.predicate.condition
162-
and self.predicate.eval(
163-
None, response=self._safe_response_json(response), headers=response.headers
161+
self.predicate.condition # type: ignore [union-attr]
162+
and self.predicate.eval( # type: ignore [union-attr]
163+
None, # type: ignore [arg-type]
164+
response=self._safe_response_json(response), # type: ignore [arg-type]
165+
headers=response.headers,
164166
)
165167
)
166168
if self.predicate

airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def _get_request_options(self, option_type: RequestOptionType) -> MutableMapping
194194
and self.pagination_strategy.get_page_size()
195195
and self.page_size_option.inject_into == option_type
196196
):
197-
options[self.page_size_option.field_name.eval(config=self.config)] = (
197+
options[self.page_size_option.field_name.eval(config=self.config)] = ( # type: ignore [union-attr]
198198
self.pagination_strategy.get_page_size()
199199
) # type: ignore # field_name is always cast to an interpolated string
200200
return options

airbyte_cdk/sources/declarative/requesters/request_options/datetime_based_request_options_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _get_request_options(
8585
self._partition_field_start.eval(self.config)
8686
)
8787
if self.end_time_option and self.end_time_option.inject_into == option_type:
88-
options[self.end_time_option.field_name.eval(config=self.config)] = stream_slice.get(
88+
options[self.end_time_option.field_name.eval(config=self.config)] = stream_slice.get( # type: ignore [union-attr]
8989
self._partition_field_end.eval(self.config)
9090
) # type: ignore # field_name is always casted to an interpolated string
9191
return options

0 commit comments

Comments
 (0)