Skip to content

Commit 8202ce5

Browse files
committed
chore: misc mypy typing fixes
1 parent f54eb7c commit 8202ce5

File tree

24 files changed

+214
-121
lines changed

24 files changed

+214
-121
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ updates:
1313
interval: daily
1414
labels:
1515
- chore
16-
open-pull-requests-limit: 8 # default is 5
16+
open-pull-requests-limit: 8 # default is 5
1717

1818
- package-ecosystem: github-actions
19-
open-pull-requests-limit: 5 # default is 5
19+
open-pull-requests-limit: 5 # default is 5
2020
directory: "/"
2121
commit-message:
2222
prefix: "ci(deps): "
@@ -29,5 +29,5 @@ updates:
2929
minor-and-patch:
3030
applies-to: version-updates
3131
update-types:
32-
- patch
33-
- minor
32+
- patch
33+
- minor

.github/workflows/publish_sdm_connector.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ on:
77
workflow_dispatch:
88
inputs:
99
version:
10-
description:
11-
The version to publish, ie 1.0.0 or 1.0.0-dev1.
12-
If omitted, and if run from a release branch, the version will be
13-
inferred from the git tag.
14-
If omitted, and if run from a non-release branch, then only a SHA-based
15-
Docker tag will be created.
10+
description: The version to publish, ie 1.0.0 or 1.0.0-dev1.
11+
If omitted, and if run from a release branch, the version will be
12+
inferred from the git tag.
13+
If omitted, and if run from a non-release branch, then only a SHA-based
14+
Docker tag will be created.
1615
required: false
1716
dry_run:
1817
description: If true, the workflow will not push to DockerHub.
@@ -24,7 +23,6 @@ jobs:
2423
build:
2524
runs-on: ubuntu-latest
2625
steps:
27-
2826
- name: Detect Release Tag Version
2927
if: startsWith(github.ref, 'refs/tags/v')
3028
run: |
@@ -167,7 +165,6 @@ jobs:
167165
tags: |
168166
airbyte/source-declarative-manifest:${{ env.VERSION }}
169167
170-
171168
- name: Build and push ('latest' tag)
172169
# Only run if version is set and IS_PRERELEASE is false
173170
if: env.VERSION != '' && env.IS_PRERELEASE == 'false' && github.event.inputs.dry_run == 'false'

.github/workflows/pytest_matrix.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ on:
1212
branches:
1313
- main
1414
paths:
15-
- 'airbyte_cdk/**'
16-
- 'unit_tests/**'
17-
- 'poetry.lock'
18-
- 'pyproject.toml'
15+
- "airbyte_cdk/**"
16+
- "unit_tests/**"
17+
- "poetry.lock"
18+
- "pyproject.toml"
1919
pull_request:
2020

2121
jobs:

airbyte_cdk/cli/source_declarative_manifest/_run.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,14 @@ def create_declarative_source(args: list[str]) -> ConcurrentDeclarativeSource:
160160
connector builder.
161161
"""
162162
try:
163+
config: Mapping[str, Any] | None
164+
catalog: ConfiguredAirbyteCatalog | None
165+
state: list[AirbyteStateMessage]
163166
config, catalog, state = _parse_inputs_into_config_catalog_state(args)
164-
if "__injected_declarative_manifest" not in config:
167+
if config is None or "__injected_declarative_manifest" not in config:
165168
raise ValueError(
166-
f"Invalid config: `__injected_declarative_manifest` should be provided at the root of the config but config only has keys {list(config.keys())}"
169+
"Invalid config: `__injected_declarative_manifest` should be provided at the root "
170+
f"of the config but config only has keys: {list(config.keys() if config else [])}"
167171
)
168172
return ConcurrentDeclarativeSource(
169173
config=config,

airbyte_cdk/destinations/vector_db_based/writer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def write(
8585
record_chunks, record_id_to_delete = self.processor.process(message.record)
8686
self.chunks[(message.record.namespace, message.record.stream)].extend(record_chunks)
8787
if record_id_to_delete is not None:
88+
if message.record is None:
89+
raise ValueError("Record messages cannot have null `record` property.")
90+
8891
self.ids_to_delete[(message.record.namespace, message.record.stream)].append(
8992
record_id_to_delete
9093
)

airbyte_cdk/sources/connector_state_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _extract_from_state_message(
131131
else:
132132
streams = {
133133
HashableStreamDescriptor(
134-
name=per_stream_state.stream.stream_descriptor.name,
134+
name=per_stream_state.stream.stream_descriptor.name, # type: ignore[union-attr] # stream has stream_descriptor
135135
namespace=per_stream_state.stream.stream_descriptor.namespace, # type: ignore[union-attr] # stream has stream_descriptor
136136
): per_stream_state.stream.stream_state # type: ignore[union-attr] # stream has stream_state
137137
for per_stream_state in state

airbyte_cdk/sources/declarative/auth/selective_authenticator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ def __new__( # type: ignore[misc]
2828
**kwargs: Any,
2929
) -> DeclarativeAuthenticator:
3030
try:
31-
selected_key = str(dpath.get(config, authenticator_selection_path))
31+
selected_key = str(
32+
dpath.get(
33+
config, # type: ignore [arg-type] # Dpath wants mutable mapping but doesn't need it.
34+
authenticator_selection_path,
35+
)
36+
)
3237
except KeyError as err:
3338
raise ValueError(
3439
"The path from `authenticator_selection_path` is not found in the config."

airbyte_cdk/sources/declarative/declarative_component_schema.yaml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,17 +2044,18 @@ definitions:
20442044
The DeclarativeOAuth Specific URL templated string to obtain the `access_token`, `refresh_token` etc.
20452045
The placeholders are replaced during the processing to provide neccessary values.
20462046
examples:
2047-
- access_token_url: https://auth.host.com/oauth2/token?{client_id_key}={{client_id_key}}&{client_secret_key}={{client_secret_key}}&{auth_code_key}={{auth_code_key}}&{redirect_uri_key}={urlEncoder:{{redirect_uri_key}}}
2047+
- access_token_url: https://auth.host.com/oauth2/token?{client_id_key}={{client_id_key}}&{client_secret_key}={{client_secret_key}}&{auth_code_key}={{auth_code_key}}&{redirect_uri_key}={urlEncoder:{{redirect_uri_key}}}
20482048
access_token_headers:
20492049
title: (Optional) DeclarativeOAuth Access Token Headers
20502050
type: object
20512051
additionalProperties: true
20522052
description: |-
20532053
The DeclarativeOAuth Specific optional headers to inject while exchanging the `auth_code` to `access_token` during `completeOAuthFlow` step.
20542054
examples:
2055-
- access_token_headers: {
2056-
"Authorization": "Basic {base64Encoder:{client_id}:{client_secret}}"
2057-
}
2055+
- access_token_headers:
2056+
{
2057+
"Authorization": "Basic {base64Encoder:{client_id}:{client_secret}}",
2058+
}
20582059
access_token_params:
20592060
title: (Optional) DeclarativeOAuth Access Token Query Params (Json Encoded)
20602061
type: object
@@ -2063,18 +2064,19 @@ definitions:
20632064
The DeclarativeOAuth Specific optional query parameters to inject while exchanging the `auth_code` to `access_token` during `completeOAuthFlow` step.
20642065
When this property is provided, the query params will be encoded as `Json` and included in the outgoing API request.
20652066
examples:
2066-
- access_token_params: {
2067-
"{auth_code_key}": "{{auth_code_key}}",
2068-
"{client_id_key}": "{{client_id_key}}",
2069-
"{client_secret_key}": "{{client_secret_key}}"
2070-
}
2067+
- access_token_params:
2068+
{
2069+
"{auth_code_key}": "{{auth_code_key}}",
2070+
"{client_id_key}": "{{client_id_key}}",
2071+
"{client_secret_key}": "{{client_secret_key}}",
2072+
}
20712073
extract_output:
20722074
title: DeclarativeOAuth Extract Output
20732075
type: array
20742076
items:
20752077
type: string
20762078
description: |-
2077-
The DeclarativeOAuth Specific list of strings to indicate which keys should be extracted and returned back to the input config.
2079+
The DeclarativeOAuth Specific list of strings to indicate which keys should be extracted and returned back to the input config.
20782080
examples:
20792081
- extract_output: ["access_token", "refresh_token", "other_field"]
20802082
state:
@@ -2086,17 +2088,14 @@ definitions:
20862088
- max
20872089
description: |-
20882090
The DeclarativeOAuth Specific object to provide the criteria of how the `state` query param should be constructed,
2089-
including length and complexity.
2091+
including length and complexity.
20902092
properties:
20912093
min:
20922094
type: integer
20932095
max:
20942096
type: integer
20952097
examples:
2096-
- state: {
2097-
"min": 7,
2098-
"max": 128,
2099-
}
2098+
- state: { "min": 7, "max": 128 }
21002099
client_id_key:
21012100
title: (Optional) DeclarativeOAuth Client ID Key Override
21022101
type: string
@@ -2122,14 +2121,14 @@ definitions:
21222121
title: (Optional) DeclarativeOAuth State Key Override
21232122
type: string
21242123
description: |-
2125-
The DeclarativeOAuth Specific optional override to provide the custom `state` key name, if required by data-provider.
2124+
The DeclarativeOAuth Specific optional override to provide the custom `state` key name, if required by data-provider.
21262125
examples:
21272126
- state_key: "my_custom_state_key_key_name"
21282127
auth_code_key:
21292128
title: (Optional) DeclarativeOAuth Auth Code Key Override
21302129
type: string
21312130
description: |-
2132-
The DeclarativeOAuth Specific optional override to provide the custom `code` key name to something like `auth_code` or `custom_auth_code`, if required by data-provider.
2131+
The DeclarativeOAuth Specific optional override to provide the custom `code` key name to something like `auth_code` or `custom_auth_code`, if required by data-provider.
21332132
examples:
21342133
- auth_code_key: "my_custom_auth_code_key_name"
21352134
redirect_uri_key:

airbyte_cdk/sources/declarative/decoders/noop_decoder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ class NoopDecoder(Decoder):
1414
def is_stream_response(self) -> bool:
1515
return False
1616

17-
def decode(self, response: requests.Response) -> Generator[Mapping[str, Any], None, None]:
17+
def decode( # type: ignore[override]
18+
self,
19+
response: requests.Response,
20+
) -> Generator[Mapping[str, Any], None, None]:
1821
yield from [{}]

airbyte_cdk/sources/file_based/availability_strategy/abstract_file_based_availability_strategy.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222

2323
class AbstractFileBasedAvailabilityStrategy(AvailabilityStrategy):
2424
@abstractmethod
25-
def check_availability(
26-
self, stream: Stream, logger: logging.Logger, _: Optional[Source]
25+
def check_availability( # type: ignore[override]
26+
self,
27+
stream: Stream,
28+
logger: logging.Logger,
29+
_: Optional[Source],
2730
) -> Tuple[bool, Optional[str]]:
2831
"""
2932
Perform a connection check for the stream.
@@ -34,7 +37,10 @@ def check_availability(
3437

3538
@abstractmethod
3639
def check_availability_and_parsability(
37-
self, stream: "AbstractFileBasedStream", logger: logging.Logger, _: Optional[Source]
40+
self,
41+
stream: AbstractFileBasedStream,
42+
logger: logging.Logger,
43+
_: Optional[Source],
3844
) -> Tuple[bool, Optional[str]]:
3945
"""
4046
Performs a connection check for the stream, as well as additional checks that
@@ -46,7 +52,7 @@ def check_availability_and_parsability(
4652

4753

4854
class AbstractFileBasedAvailabilityStrategyWrapper(AbstractAvailabilityStrategy):
49-
def __init__(self, stream: "AbstractFileBasedStream"):
55+
def __init__(self, stream: AbstractFileBasedStream) -> None:
5056
self.stream = stream
5157

5258
def check_availability(self, logger: logging.Logger) -> StreamAvailability:

0 commit comments

Comments
 (0)