Skip to content

Commit 02030b5

Browse files
author
octavia-squidington-iii
committed
Auto-fix lint and format issues
1 parent 2846522 commit 02030b5

File tree

5 files changed

+89
-84
lines changed

5 files changed

+89
-84
lines changed

airbyte_cdk/sources/declarative/concurrent_declarative_source.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,11 @@ def _group_streams(
211211
stream_name=declarative_stream.name, namespace=declarative_stream.namespace
212212
)
213213

214-
name_to_stream_mapping[declarative_stream.name] = name_to_stream_mapping[declarative_stream.name]["incremental_stream"] \
215-
if stream_state else name_to_stream_mapping[declarative_stream.name]["full_refresh_stream"]
214+
name_to_stream_mapping[declarative_stream.name] = (
215+
name_to_stream_mapping[declarative_stream.name]["incremental_stream"]
216+
if stream_state
217+
else name_to_stream_mapping[declarative_stream.name]["full_refresh_stream"]
218+
)
216219

217220
if isinstance(declarative_stream, DeclarativeStream) and (
218221
name_to_stream_mapping[declarative_stream.name]["retriever"]["type"]

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
3030
DeclarativeStream as DeclarativeStreamModel,
3131
)
32+
from airbyte_cdk.sources.declarative.models.declarative_component_schema import Spec as SpecModel
3233
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
3334
StateDelegatingStream as StateDelegatingStreamModel,
3435
)
35-
from airbyte_cdk.sources.declarative.models.declarative_component_schema import Spec as SpecModel
3636
from airbyte_cdk.sources.declarative.parsers.custom_code_compiler import (
3737
get_registered_components_module,
3838
)
@@ -146,7 +146,9 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
146146

147147
source_streams = [
148148
self._constructor.create_component(
149-
StateDelegatingStreamModel if stream_config.get("type") == StateDelegatingStreamModel.__name__ else DeclarativeStreamModel,
149+
StateDelegatingStreamModel
150+
if stream_config.get("type") == StateDelegatingStreamModel.__name__
151+
else DeclarativeStreamModel,
150152
stream_config,
151153
config,
152154
emit_connector_builder_messages=self._emit_connector_builder_messages,
@@ -197,12 +199,12 @@ def update_with_cache_parent_configs(parent_configs: list[dict[str, Any]]) -> No
197199
for stream_config in stream_configs:
198200
if stream_config["name"] in parent_streams:
199201
if stream_config["type"] == "StateDelegatingStream":
200-
stream_config["full_refresh_stream"]["retriever"]["requester"][
201-
"use_cache"
202-
] = True
203-
stream_config["incremental_stream"]["retriever"]["requester"][
204-
"use_cache"
205-
] = True
202+
stream_config["full_refresh_stream"]["retriever"]["requester"]["use_cache"] = (
203+
True
204+
)
205+
stream_config["incremental_stream"]["retriever"]["requester"]["use_cache"] = (
206+
True
207+
)
206208
else:
207209
stream_config["retriever"]["requester"]["use_cache"] = True
208210

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 35 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,7 @@ class OAuthAuthenticator(BaseModel):
609609
scopes: Optional[List[str]] = Field(
610610
None,
611611
description="List of scopes that should be granted to the access token.",
612-
examples=[
613-
["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]
614-
],
612+
examples=[["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]],
615613
title="Scopes",
616614
)
617615
token_expiry_date: Optional[str] = Field(
@@ -1080,28 +1078,24 @@ class OAuthConfigSpecification(BaseModel):
10801078
class Config:
10811079
extra = Extra.allow
10821080

1083-
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = (
1084-
Field(
1085-
None,
1086-
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 }",
1087-
examples=[
1088-
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1089-
{
1090-
"app_id": {
1091-
"type": "string",
1092-
"path_in_connector_config": ["info", "app_id"],
1093-
}
1094-
},
1095-
],
1096-
title="OAuth user input",
1097-
)
1081+
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = Field(
1082+
None,
1083+
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 }",
1084+
examples=[
1085+
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1086+
{
1087+
"app_id": {
1088+
"type": "string",
1089+
"path_in_connector_config": ["info", "app_id"],
1090+
}
1091+
},
1092+
],
1093+
title="OAuth user input",
10981094
)
1099-
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = (
1100-
Field(
1101-
None,
1102-
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 }',
1103-
title="DeclarativeOAuth Connector Specification",
1104-
)
1095+
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = Field(
1096+
None,
1097+
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 }',
1098+
title="DeclarativeOAuth Connector Specification",
11051099
)
11061100
complete_oauth_output_specification: Optional[Dict[str, Any]] = Field(
11071101
None,
@@ -1119,9 +1113,7 @@ class Config:
11191113
complete_oauth_server_input_specification: Optional[Dict[str, Any]] = Field(
11201114
None,
11211115
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 }",
1122-
examples=[
1123-
{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}
1124-
],
1116+
examples=[{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}],
11251117
title="OAuth input specification",
11261118
)
11271119
complete_oauth_server_output_specification: Optional[Dict[str, Any]] = Field(
@@ -1778,9 +1770,7 @@ class RecordSelector(BaseModel):
17781770
description="Responsible for filtering records to be emitted by the Source.",
17791771
title="Record Filter",
17801772
)
1781-
schema_normalization: Optional[
1782-
Union[SchemaNormalization, CustomSchemaNormalization]
1783-
] = Field(
1773+
schema_normalization: Optional[Union[SchemaNormalization, CustomSchemaNormalization]] = Field(
17841774
SchemaNormalization.None_,
17851775
description="Responsible for normalization according to the schema.",
17861776
title="Schema Normalization",
@@ -1979,12 +1969,12 @@ class Config:
19791969
extra = Extra.allow
19801970

19811971
type: Literal["DeclarativeStream"]
1982-
retriever: Union[
1983-
AsyncRetriever, CustomRetriever, SimpleRetriever, StateDelegatingRetriever
1984-
] = Field(
1985-
...,
1986-
description="Component used to coordinate how records are extracted across stream slices and request pages.",
1987-
title="Retriever",
1972+
retriever: Union[AsyncRetriever, CustomRetriever, SimpleRetriever, StateDelegatingRetriever] = (
1973+
Field(
1974+
...,
1975+
description="Component used to coordinate how records are extracted across stream slices and request pages.",
1976+
title="Retriever",
1977+
)
19881978
)
19891979
incremental_sync: Optional[
19901980
Union[CustomIncrementalSync, DatetimeBasedCursor, IncrementingCountCursor]
@@ -1993,9 +1983,7 @@ class Config:
19931983
description="Component used to fetch data incrementally based on a time field in the data.",
19941984
title="Incremental Sync",
19951985
)
1996-
name: Optional[str] = Field(
1997-
"", description="The stream name.", example=["Users"], title="Name"
1998-
)
1986+
name: Optional[str] = Field("", description="The stream name.", example=["Users"], title="Name")
19991987
primary_key: Optional[PrimaryKey] = Field(
20001988
"", description="The primary key of the stream.", title="Primary Key"
20011989
)
@@ -2248,9 +2236,7 @@ class ParentStreamConfig(BaseModel):
22482236

22492237
class StateDelegatingStream(BaseModel):
22502238
type: Literal["StateDelegatingStream"]
2251-
name: str = Field(
2252-
..., description="The stream name.", example=["Users"], title="Name"
2253-
)
2239+
name: str = Field(..., description="The stream name.", example=["Users"], title="Name")
22542240
full_refresh_stream: DeclarativeStream = Field(
22552241
...,
22562242
description="Component used to coordinate how records are extracted across stream slices and request pages when the state is empty or not provided.",
@@ -2287,11 +2273,7 @@ class SimpleRetriever(BaseModel):
22872273
CustomPartitionRouter,
22882274
ListPartitionRouter,
22892275
SubstreamPartitionRouter,
2290-
List[
2291-
Union[
2292-
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
2293-
]
2294-
],
2276+
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
22952277
]
22962278
] = Field(
22972279
[],
@@ -2335,9 +2317,7 @@ class AsyncRetriever(BaseModel):
23352317
)
23362318
download_extractor: Optional[
23372319
Union[CustomRecordExtractor, DpathExtractor, ResponseToFileExtractor]
2338-
] = Field(
2339-
None, description="Responsible for fetching the records from provided urls."
2340-
)
2320+
] = Field(None, description="Responsible for fetching the records from provided urls.")
23412321
creation_requester: Union[CustomRequester, HttpRequester] = Field(
23422322
...,
23432323
description="Requester component that describes how to prepare HTTP requests to send to the source API to create the async server-side job.",
@@ -2371,11 +2351,7 @@ class AsyncRetriever(BaseModel):
23712351
CustomPartitionRouter,
23722352
ListPartitionRouter,
23732353
SubstreamPartitionRouter,
2374-
List[
2375-
Union[
2376-
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
2377-
]
2378-
],
2354+
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
23792355
]
23802356
] = Field(
23812357
[],
@@ -2443,12 +2419,10 @@ class DynamicDeclarativeStream(BaseModel):
24432419
stream_template: DeclarativeStream = Field(
24442420
..., description="Reference to the stream template.", title="Stream Template"
24452421
)
2446-
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = (
2447-
Field(
2448-
...,
2449-
description="Component resolve and populates stream templates with components values.",
2450-
title="Components Resolver",
2451-
)
2422+
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = Field(
2423+
...,
2424+
description="Component resolve and populates stream templates with components values.",
2425+
title="Components Resolver",
24522426
)
24532427

24542428

0 commit comments

Comments
 (0)