Skip to content

Commit 4ee3fb5

Browse files
author
octavia-squidington-iii
committed
Auto-fix lint and format issues
1 parent 949872b commit 4ee3fb5

File tree

7 files changed

+71
-93
lines changed

7 files changed

+71
-93
lines changed

airbyte_cdk/sources/declarative/extractors/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
33
#
44

5-
from airbyte_cdk.sources.declarative.extractors.dpath_extractor import DpathExtractor
6-
from airbyte_cdk.sources.declarative.extractors.key_value_extractor import KeyValueExtractor
75
from airbyte_cdk.sources.declarative.extractors.combined_extractor import CombinedExtractor
6+
from airbyte_cdk.sources.declarative.extractors.dpath_extractor import DpathExtractor
87
from airbyte_cdk.sources.declarative.extractors.http_selector import HttpSelector
8+
from airbyte_cdk.sources.declarative.extractors.key_value_extractor import KeyValueExtractor
99
from airbyte_cdk.sources.declarative.extractors.record_filter import RecordFilter
1010
from airbyte_cdk.sources.declarative.extractors.record_selector import RecordSelector
1111
from airbyte_cdk.sources.declarative.extractors.response_to_file_extractor import (

airbyte_cdk/sources/declarative/extractors/combined_extractor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any, Iterable, List, MutableMapping
77

88
import requests
9+
910
from airbyte_cdk.sources.declarative.extractors.record_extractor import RecordExtractor
1011

1112

@@ -41,4 +42,4 @@ def extract_records(self, response: requests.Response) -> Iterable[MutableMappin
4142
merged = {}
4243
for record in records:
4344
merged.update(record) # merge all fields
44-
yield merged
45+
yield merged

airbyte_cdk/sources/declarative/extractors/key_value_extractor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
#
44

55
from dataclasses import dataclass
6+
from itertools import islice
67
from typing import Any, Iterable, MutableMapping
78

89
import requests
9-
from itertools import islice
10+
1011
from airbyte_cdk.sources.declarative.extractors.record_extractor import RecordExtractor
1112

1213

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 42 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,7 @@ class OAuthAuthenticator(BaseModel):
618618
scopes: Optional[List[str]] = Field(
619619
None,
620620
description="List of scopes that should be granted to the access token.",
621-
examples=[
622-
["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]
623-
],
621+
examples=[["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]],
624622
title="Scopes",
625623
)
626624
token_expiry_date: Optional[str] = Field(
@@ -1126,28 +1124,24 @@ class OAuthConfigSpecification(BaseModel):
11261124
class Config:
11271125
extra = Extra.allow
11281126

1129-
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = (
1130-
Field(
1131-
None,
1132-
description="OAuth specific blob. This is a Json Schema used to validate Json configurations used as input to OAuth.\nMust be a valid non-nested JSON that refers to properties from ConnectorSpecification.connectionSpecification\nusing special annotation 'path_in_connector_config'.\nThese are input values the user is entering through the UI to authenticate to the connector, that might also shared\nas inputs for syncing data via the connector.\nExamples:\nif no connector values is shared during oauth flow, oauth_user_input_from_connector_config_specification=[]\nif connector values such as 'app_id' inside the top level are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['app_id']\n }\n }\nif connector values such as 'info.app_id' nested inside another object are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['info', 'app_id']\n }\n }",
1133-
examples=[
1134-
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1135-
{
1136-
"app_id": {
1137-
"type": "string",
1138-
"path_in_connector_config": ["info", "app_id"],
1139-
}
1140-
},
1141-
],
1142-
title="OAuth user input",
1143-
)
1127+
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = Field(
1128+
None,
1129+
description="OAuth specific blob. This is a Json Schema used to validate Json configurations used as input to OAuth.\nMust be a valid non-nested JSON that refers to properties from ConnectorSpecification.connectionSpecification\nusing special annotation 'path_in_connector_config'.\nThese are input values the user is entering through the UI to authenticate to the connector, that might also shared\nas inputs for syncing data via the connector.\nExamples:\nif no connector values is shared during oauth flow, oauth_user_input_from_connector_config_specification=[]\nif connector values such as 'app_id' inside the top level are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['app_id']\n }\n }\nif connector values such as 'info.app_id' nested inside another object are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['info', 'app_id']\n }\n }",
1130+
examples=[
1131+
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1132+
{
1133+
"app_id": {
1134+
"type": "string",
1135+
"path_in_connector_config": ["info", "app_id"],
1136+
}
1137+
},
1138+
],
1139+
title="OAuth user input",
11441140
)
1145-
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = (
1146-
Field(
1147-
None,
1148-
description='The DeclarativeOAuth specific blob.\nPertains to the fields defined by the connector relating to the OAuth flow.\n\nInterpolation capabilities:\n- The variables placeholders are declared as `{{my_var}}`.\n- The nested resolution variables like `{{ {{my_nested_var}} }}` is allowed as well.\n\n- The allowed interpolation context is:\n + base64Encoder - encode to `base64`, {{ {{my_var_a}}:{{my_var_b}} | base64Encoder }}\n + base64Decorer - decode from `base64` encoded string, {{ {{my_string_variable_or_string_value}} | base64Decoder }}\n + urlEncoder - encode the input string to URL-like format, {{ https://test.host.com/endpoint | urlEncoder}}\n + urlDecorer - decode the input url-encoded string into text format, {{ urlDecoder:https%3A%2F%2Fairbyte.io | urlDecoder}}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {{ {{state_value}} | codeChallengeS256 }}\n\nExamples:\n - The TikTok Marketing DeclarativeOAuth spec:\n {\n "oauth_connector_input_specification": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "consent_url": "https://ads.tiktok.com/marketing_api/auth?{{client_id_key}}={{client_id_value}}&{{redirect_uri_key}}={{ {{redirect_uri_value}} | urlEncoder}}&{{state_key}}={{state_value}}",\n "access_token_url": "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/",\n "access_token_params": {\n "{{ auth_code_key }}": "{{ auth_code_value }}",\n "{{ client_id_key }}": "{{ client_id_value }}",\n "{{ client_secret_key }}": "{{ client_secret_value }}"\n },\n "access_token_headers": {\n "Content-Type": "application/json",\n "Accept": "application/json"\n },\n "extract_output": ["data.access_token"],\n "client_id_key": "app_id",\n "client_secret_key": "secret",\n "auth_code_key": "auth_code"\n }\n }\n }',
1149-
title="DeclarativeOAuth Connector Specification",
1150-
)
1141+
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = Field(
1142+
None,
1143+
description='The DeclarativeOAuth specific blob.\nPertains to the fields defined by the connector relating to the OAuth flow.\n\nInterpolation capabilities:\n- The variables placeholders are declared as `{{my_var}}`.\n- The nested resolution variables like `{{ {{my_nested_var}} }}` is allowed as well.\n\n- The allowed interpolation context is:\n + base64Encoder - encode to `base64`, {{ {{my_var_a}}:{{my_var_b}} | base64Encoder }}\n + base64Decorer - decode from `base64` encoded string, {{ {{my_string_variable_or_string_value}} | base64Decoder }}\n + urlEncoder - encode the input string to URL-like format, {{ https://test.host.com/endpoint | urlEncoder}}\n + urlDecorer - decode the input url-encoded string into text format, {{ urlDecoder:https%3A%2F%2Fairbyte.io | urlDecoder}}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {{ {{state_value}} | codeChallengeS256 }}\n\nExamples:\n - The TikTok Marketing DeclarativeOAuth spec:\n {\n "oauth_connector_input_specification": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "consent_url": "https://ads.tiktok.com/marketing_api/auth?{{client_id_key}}={{client_id_value}}&{{redirect_uri_key}}={{ {{redirect_uri_value}} | urlEncoder}}&{{state_key}}={{state_value}}",\n "access_token_url": "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/",\n "access_token_params": {\n "{{ auth_code_key }}": "{{ auth_code_value }}",\n "{{ client_id_key }}": "{{ client_id_value }}",\n "{{ client_secret_key }}": "{{ client_secret_value }}"\n },\n "access_token_headers": {\n "Content-Type": "application/json",\n "Accept": "application/json"\n },\n "extract_output": ["data.access_token"],\n "client_id_key": "app_id",\n "client_secret_key": "secret",\n "auth_code_key": "auth_code"\n }\n }\n }',
1144+
title="DeclarativeOAuth Connector Specification",
11511145
)
11521146
complete_oauth_output_specification: Optional[Dict[str, Any]] = Field(
11531147
None,
@@ -1165,9 +1159,7 @@ class Config:
11651159
complete_oauth_server_input_specification: Optional[Dict[str, Any]] = Field(
11661160
None,
11671161
description="OAuth specific blob. This is a Json Schema used to validate Json configurations persisted as Airbyte Server configurations.\nMust be a valid non-nested JSON describing additional fields configured by the Airbyte Instance or Workspace Admins to be used by the\nserver when completing an OAuth flow (typically exchanging an auth code for refresh token).\nExamples:\n complete_oauth_server_input_specification={\n client_id: {\n type: string\n },\n client_secret: {\n type: string\n }\n }",
1168-
examples=[
1169-
{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}
1170-
],
1162+
examples=[{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}],
11711163
title="OAuth input specification",
11721164
)
11731165
complete_oauth_server_output_specification: Optional[Dict[str, Any]] = Field(
@@ -1498,9 +1490,7 @@ class StreamConfig(BaseModel):
14981490
examples=[["data"], ["data", "streams"], ["data", "{{ parameters.name }}"]],
14991491
title="Configs Pointer",
15001492
)
1501-
default_values: Optional[List] = Field(
1502-
None, description="placeholder", title="Default Values"
1503-
)
1493+
default_values: Optional[List] = Field(None, description="placeholder", title="Default Values")
15041494
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
15051495

15061496

@@ -1868,9 +1858,7 @@ class KeyValueExtractor(BaseModel):
18681858
class CombinedExtractor(BaseModel):
18691859
type: Literal["CombinedExtractor"]
18701860
extractors: List[
1871-
Union[
1872-
DpathExtractor, CombinedExtractor, KeyValueExtractor, CustomRecordExtractor
1873-
]
1861+
Union[DpathExtractor, CombinedExtractor, KeyValueExtractor, CustomRecordExtractor]
18741862
] = Field(..., description="placeholder")
18751863
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
18761864

@@ -1912,17 +1900,13 @@ class ListPartitionRouter(BaseModel):
19121900

19131901
class RecordSelector(BaseModel):
19141902
type: Literal["RecordSelector"]
1915-
extractor: Union[
1916-
DpathExtractor, CombinedExtractor, KeyValueExtractor, CustomRecordExtractor
1917-
]
1903+
extractor: Union[DpathExtractor, CombinedExtractor, KeyValueExtractor, CustomRecordExtractor]
19181904
record_filter: Optional[Union[RecordFilter, CustomRecordFilter]] = Field(
19191905
None,
19201906
description="Responsible for filtering records to be emitted by the Source.",
19211907
title="Record Filter",
19221908
)
1923-
schema_normalization: Optional[
1924-
Union[SchemaNormalization, CustomSchemaNormalization]
1925-
] = Field(
1909+
schema_normalization: Optional[Union[SchemaNormalization, CustomSchemaNormalization]] = Field(
19261910
None,
19271911
description="Responsible for normalization according to the schema.",
19281912
title="Schema Normalization",
@@ -2168,9 +2152,7 @@ class Config:
21682152
extra = Extra.allow
21692153

21702154
type: Literal["DeclarativeStream"]
2171-
name: Optional[str] = Field(
2172-
"", description="The stream name.", example=["Users"], title="Name"
2173-
)
2155+
name: Optional[str] = Field("", description="The stream name.", example=["Users"], title="Name")
21742156
retriever: Union[SimpleRetriever, AsyncRetriever, CustomRetriever] = Field(
21752157
...,
21762158
description="Component used to coordinate how records are extracted across stream slices and request pages.",
@@ -2348,20 +2330,18 @@ class HttpRequester(BaseModelWithDeprecations):
23482330
description="Allows for retrieving a dynamic set of properties from an API endpoint which can be injected into outbound request using the stream_partition.extra_fields.",
23492331
title="Fetch Properties from Endpoint",
23502332
)
2351-
request_parameters: Optional[Union[Dict[str, Union[str, QueryProperties]], str]] = (
2352-
Field(
2353-
None,
2354-
description="Specifies the query parameters that should be set on an outgoing HTTP request given the inputs.",
2355-
examples=[
2356-
{"unit": "day"},
2357-
{
2358-
"query": 'last_event_time BETWEEN TIMESTAMP "{{ stream_interval.start_time }}" AND TIMESTAMP "{{ stream_interval.end_time }}"'
2359-
},
2360-
{"searchIn": "{{ ','.join(config.get('search_in', [])) }}"},
2361-
{"sort_by[asc]": "updated_at"},
2362-
],
2363-
title="Query Parameters",
2364-
)
2333+
request_parameters: Optional[Union[Dict[str, Union[str, QueryProperties]], str]] = Field(
2334+
None,
2335+
description="Specifies the query parameters that should be set on an outgoing HTTP request given the inputs.",
2336+
examples=[
2337+
{"unit": "day"},
2338+
{
2339+
"query": 'last_event_time BETWEEN TIMESTAMP "{{ stream_interval.start_time }}" AND TIMESTAMP "{{ stream_interval.end_time }}"'
2340+
},
2341+
{"searchIn": "{{ ','.join(config.get('search_in', [])) }}"},
2342+
{"sort_by[asc]": "updated_at"},
2343+
],
2344+
title="Query Parameters",
23652345
)
23662346
request_headers: Optional[Union[Dict[str, str], str]] = Field(
23672347
None,
@@ -2554,9 +2534,7 @@ class QueryProperties(BaseModel):
25542534

25552535
class StateDelegatingStream(BaseModel):
25562536
type: Literal["StateDelegatingStream"]
2557-
name: str = Field(
2558-
..., description="The stream name.", example=["Users"], title="Name"
2559-
)
2537+
name: str = Field(..., description="The stream name.", example=["Users"], title="Name")
25602538
full_refresh_stream: DeclarativeStream = Field(
25612539
...,
25622540
description="Component used to coordinate how records are extracted across stream slices and request pages when the state is empty or not provided.",
@@ -2645,9 +2623,7 @@ class AsyncRetriever(BaseModel):
26452623
)
26462624
download_extractor: Optional[
26472625
Union[DpathExtractor, CustomRecordExtractor, ResponseToFileExtractor]
2648-
] = Field(
2649-
None, description="Responsible for fetching the records from provided urls."
2650-
)
2626+
] = Field(None, description="Responsible for fetching the records from provided urls.")
26512627
creation_requester: Union[HttpRequester, CustomRequester] = Field(
26522628
...,
26532629
description="Requester component that describes how to prepare HTTP requests to send to the source API to create the async server-side job.",
@@ -2787,12 +2763,10 @@ class DynamicDeclarativeStream(BaseModel):
27872763
stream_template: DeclarativeStream = Field(
27882764
..., description="Reference to the stream template.", title="Stream Template"
27892765
)
2790-
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = (
2791-
Field(
2792-
...,
2793-
description="Component resolve and populates stream templates with components values.",
2794-
title="Components Resolver",
2795-
)
2766+
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = Field(
2767+
...,
2768+
description="Component resolve and populates stream templates with components values.",
2769+
title="Components Resolver",
27962770
)
27972771

27982772

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
Parser,
8484
)
8585
from airbyte_cdk.sources.declarative.extractors import (
86+
CombinedExtractor,
8687
DpathExtractor,
8788
KeyValueExtractor,
88-
CombinedExtractor,
8989
RecordFilter,
9090
RecordSelector,
9191
ResponseToFileExtractor,
@@ -144,6 +144,9 @@
144144
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
145145
CheckStream as CheckStreamModel,
146146
)
147+
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
148+
CombinedExtractor as CombinedExtractorModel,
149+
)
147150
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
148151
ComplexFieldType as ComplexFieldTypeModel,
149152
)
@@ -225,12 +228,6 @@
225228
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
226229
DpathExtractor as DpathExtractorModel,
227230
)
228-
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
229-
KeyValueExtractor as KeyValueExtractorModel,
230-
)
231-
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
232-
CombinedExtractor as CombinedExtractorModel,
233-
)
234231
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
235232
DpathFlattenFields as DpathFlattenFieldsModel,
236233
)
@@ -312,6 +309,9 @@
312309
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
313310
KeysToSnakeCase as KeysToSnakeCaseModel,
314311
)
312+
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
313+
KeyValueExtractor as KeyValueExtractorModel,
314+
)
315315
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
316316
LegacySessionTokenAuthenticator as LegacySessionTokenAuthenticatorModel,
317317
)
@@ -2252,9 +2252,7 @@ def create_combined_extractor(
22522252
**kwargs: Any,
22532253
) -> CombinedExtractor:
22542254
extractors = [
2255-
self._create_component_from_model(
2256-
model=extractor, decoder=decoder, config=config
2257-
)
2255+
self._create_component_from_model(model=extractor, decoder=decoder, config=config)
22582256
for extractor in model.extractors
22592257
]
22602258

@@ -3697,12 +3695,16 @@ def create_stream_config(
36973695
def create_config_components_resolver(
36983696
self, model: ConfigComponentsResolverModel, config: Config
36993697
) -> Any:
3698+
model_stream_configs = (
3699+
model.stream_config if isinstance(model.stream_config, list) else [model.stream_config]
3700+
)
37003701

3701-
model_stream_configs = model.stream_config if isinstance(model.stream_config, list) else [model.stream_config]
3702-
3703-
stream_configs = [self._create_component_from_model(
3704-
stream_config, config=config, parameters=model.parameters or {}
3705-
) for stream_config in model_stream_configs]
3702+
stream_configs = [
3703+
self._create_component_from_model(
3704+
stream_config, config=config, parameters=model.parameters or {}
3705+
)
3706+
for stream_config in model_stream_configs
3707+
]
37063708

37073709
components_mapping = [
37083710
self._create_component_from_model(

0 commit comments

Comments
 (0)