Skip to content

Commit 39d66af

Browse files
committed
remove unused type ignores
1 parent c29447c commit 39d66af

28 files changed

+56
-52
lines changed

airbyte_cdk/connector_builder/message_grouper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _cursor_field_to_nested_and_composite_field(
7171

7272
is_nested_key = isinstance(field[0], str)
7373
if is_nested_key:
74-
return [field] # type: ignore # the type of field is expected to be List[str] here
74+
return [field]
7575

7676
raise ValueError(f"Unknown type for cursor field `{field}")
7777

@@ -234,7 +234,7 @@ def _get_message_groups(
234234
at_least_one_page_in_group = False
235235
elif message.type == MessageType.LOG and message.log.message.startswith( # type: ignore[union-attr] # None doesn't have 'message'
236236
SliceLogger.SLICE_LOG_PREFIX
237-
): # type: ignore[union-attr] # AirbyteMessage with MessageType.LOG has log.message
237+
):
238238
# parsing the first slice
239239
current_slice_descriptor = self._parse_slice_description(message.log.message) # type: ignore[union-attr] # AirbyteMessage with MessageType.LOG has log.message
240240
elif message.type == MessageType.LOG:
@@ -281,7 +281,7 @@ def _get_message_groups(
281281
elif (
282282
message.type == MessageType.CONTROL
283283
and message.control.type == OrchestratorType.CONNECTOR_CONFIG # type: ignore[union-attr] # None doesn't have 'type'
284-
): # type: ignore[union-attr] # AirbyteMessage with MessageType.CONTROL has control.type
284+
):
285285
yield message.control
286286
elif message.type == MessageType.STATE:
287287
latest_state_message = message.state # type: ignore[assignment]
@@ -356,7 +356,7 @@ def _close_page(
356356
request=current_page_request,
357357
response=current_page_response,
358358
records=deepcopy(current_page_records), # type: ignore [arg-type]
359-
) # type: ignore
359+
)
360360
)
361361
current_page_records.clear()
362362

airbyte_cdk/entrypoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from airbyte_cdk.connector import TConfig
2323
from airbyte_cdk.exception_handler import init_uncaught_exception_handler
2424
from airbyte_cdk.logger import init_logger
25-
from airbyte_cdk.models import ( # type: ignore [attr-defined]
25+
from airbyte_cdk.models import (
2626
AirbyteConnectionStatus,
2727
AirbyteMessage,
2828
AirbyteMessageSerializer,
@@ -281,7 +281,7 @@ def set_up_secret_filter(config: TConfig, connection_specification: Mapping[str,
281281

282282
@staticmethod
283283
def airbyte_message_to_string(airbyte_message: AirbyteMessage) -> str:
284-
return orjson.dumps(AirbyteMessageSerializer.dump(airbyte_message)).decode() # type: ignore[no-any-return] # orjson.dumps(message).decode() always returns string
284+
return orjson.dumps(AirbyteMessageSerializer.dump(airbyte_message)).decode()
285285

286286
@classmethod
287287
def extract_state(cls, args: List[str]) -> Optional[Any]:

airbyte_cdk/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def format(self, record: logging.LogRecord) -> str:
7878
log_message = AirbyteMessage(
7979
type=Type.LOG, log=AirbyteLogMessage(level=airbyte_level, message=message)
8080
)
81-
return orjson.dumps(AirbyteMessageSerializer.dump(log_message)).decode() # type: ignore[no-any-return] # orjson.dumps(message).decode() always returns string
81+
return orjson.dumps(AirbyteMessageSerializer.dump(log_message)).decode()
8282

8383
@staticmethod
8484
def extract_extra_args_from_record(record: logging.LogRecord) -> Mapping[str, Any]:

airbyte_cdk/sources/abstract_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def read(
200200
if len(stream_name_to_exception) > 0:
201201
error_message = generate_failed_streams_error_message(
202202
{key: [value] for key, value in stream_name_to_exception.items()}
203-
) # type: ignore # for some reason, mypy can't figure out the types for key and value
203+
)
204204
logger.info(error_message)
205205
# We still raise at least one exception when a stream raises an exception because the platform currently relies
206206
# on a non-zero exit code to determine if a sync attempt has failed. We also raise the exception as a config_error

airbyte_cdk/sources/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ def schema(cls, *args: Any, **kwargs: Any) -> Dict[str, Any]:
2424
rename_key(schema, old_key="anyOf", new_key="oneOf") # UI supports only oneOf
2525
expand_refs(schema)
2626
schema.pop("description", None) # description added from the docstring
27-
return schema # type: ignore[no-any-return]
27+
return schema

airbyte_cdk/sources/connector_state_manager.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import copy
66
from dataclasses import dataclass
7-
from typing import Any, List, Mapping, MutableMapping, Optional, Tuple, Union
7+
from typing import Any, List, Mapping, MutableMapping, Optional, Tuple, Union, cast
88

99
from airbyte_cdk.models import (
1010
AirbyteMessage,
@@ -15,6 +15,7 @@
1515
StreamDescriptor,
1616
)
1717
from airbyte_cdk.models import Type as MessageType
18+
from airbyte_cdk.models.airbyte_protocol import AirbyteGlobalState, AirbyteStateBlob
1819

1920

2021
@dataclass(frozen=True)
@@ -118,8 +119,12 @@ def _extract_from_state_message(
118119
is_global = cls._is_global_state(state)
119120

120121
if is_global:
121-
global_state = state[0].global_ # type: ignore # We verified state is a list in _is_global_state
122-
shared_state = copy.deepcopy(global_state.shared_state, {}) # type: ignore[union-attr] # global_state has shared_state
122+
# We already validate that this is a global state message, not None:
123+
global_state = cast(AirbyteGlobalState, state[0].global_)
124+
# global_state has shared_state, also not None:
125+
shared_state: AirbyteStateBlob = cast(
126+
AirbyteStateBlob, copy.deepcopy(global_state.shared_state, {})
127+
)
123128
streams = {
124129
HashableStreamDescriptor(
125130
name=per_stream_state.stream_descriptor.name,

airbyte_cdk/sources/declarative/auth/oauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def get_grant_type(self) -> str:
135135
return self.grant_type.eval(self.config) # type: ignore # eval returns a string in this context
136136

137137
def get_refresh_request_body(self) -> Mapping[str, Any]:
138-
return self._refresh_request_body.eval(self.config) # type: ignore # eval should return a Mapping in this context
138+
return self._refresh_request_body.eval(self.config)
139139

140140
def get_token_expiry_date(self) -> pendulum.DateTime:
141141
return self._token_expiry_date # type: ignore # _token_expiry_date is a pendulum.DateTime. It is never None despite what mypy thinks

airbyte_cdk/sources/declarative/concurrent_declarative_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(
128128
initial_number_of_partitions_to_generate=initial_number_of_partitions_to_generate,
129129
logger=self.logger,
130130
slice_logger=self._slice_logger,
131-
message_repository=self.message_repository, # type: ignore # message_repository is always instantiated with a value by factory
131+
message_repository=self.message_repository,
132132
)
133133

134134
def read(

airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def set_initial_state(self, stream_state: StreamState) -> None:
134134
"""
135135
self._cursor = (
136136
stream_state.get(self.cursor_field.eval(self.config)) if stream_state else None # type: ignore [union-attr]
137-
) # type: ignore # cursor_field is converted to an InterpolatedString in __post_init__
137+
)
138138

139139
def observe(self, stream_slice: StreamSlice, record: Record) -> None:
140140
"""
@@ -161,7 +161,7 @@ def observe(self, stream_slice: StreamSlice, record: Record) -> None:
161161
record,
162162
stream_slice.get(start_field), # type: ignore [arg-type]
163163
stream_slice.get(end_field), # type: ignore [arg-type]
164-
) # type: ignore # we know that stream_slices for these cursors will use a string representing an unparsed date
164+
)
165165
and is_highest_observed_cursor_value
166166
):
167167
self._highest_observed_cursor_field_value = record_cursor_value
@@ -372,7 +372,7 @@ def _get_request_options(
372372
if self.end_time_option and self.end_time_option.inject_into == option_type:
373373
options[self.end_time_option.field_name.eval(config=self.config)] = stream_slice.get( # type: ignore [union-attr]
374374
self._partition_field_end.eval(self.config)
375-
) # type: ignore # field_name is always casted to an interpolated string
375+
)
376376
return options
377377

378378
def should_be_synced(self, record: Record) -> bool:

airbyte_cdk/sources/declarative/interpolation/jinja.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class StreamPartitionAccessEnvironment(SandboxedEnvironment):
2727
def is_safe_attribute(self, obj: Any, attr: str, value: Any) -> bool:
2828
if attr in ["_partition"]:
2929
return True
30-
return super().is_safe_attribute(obj, attr, value) # type: ignore # for some reason, mypy says 'Returning Any from function declared to return "bool"'
30+
return super().is_safe_attribute(obj, attr, value)
3131

3232

3333
class JinjaInterpolation(Interpolation):

0 commit comments

Comments
 (0)