Skip to content

Commit e02ee97

Browse files
committed
Fix with linter
1 parent 95370b2 commit e02ee97

File tree

2 files changed

+41
-63
lines changed

2 files changed

+41
-63
lines changed

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

+37-61
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,7 @@ class OAuthAuthenticator(BaseModel):
528528
scopes: Optional[List[str]] = Field(
529529
None,
530530
description="List of scopes that should be granted to the access token.",
531-
examples=[
532-
["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]
533-
],
531+
examples=[["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]],
534532
title="Scopes",
535533
)
536534
token_expiry_date: Optional[str] = Field(
@@ -876,28 +874,24 @@ class OAuthConfigSpecification(BaseModel):
876874
class Config:
877875
extra = Extra.allow
878876

879-
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = (
880-
Field(
881-
None,
882-
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 }",
883-
examples=[
884-
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
885-
{
886-
"app_id": {
887-
"type": "string",
888-
"path_in_connector_config": ["info", "app_id"],
889-
}
890-
},
891-
],
892-
title="OAuth user input",
893-
)
877+
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = Field(
878+
None,
879+
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 }",
880+
examples=[
881+
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
882+
{
883+
"app_id": {
884+
"type": "string",
885+
"path_in_connector_config": ["info", "app_id"],
886+
}
887+
},
888+
],
889+
title="OAuth user input",
894890
)
895-
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = (
896-
Field(
897-
None,
898-
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`, {base64Encoder:{my_var_a}:{my_var_b}}\n + base64Decorer - decode from `base64` encoded string, {base64Decoder:{my_string_variable_or_string_value}}\n + urlEncoder - encode the input string to URL-like format, {urlEncoder:https://test.host.com/endpoint}\n + urlDecorer - decode the input url-encoded string into text format, {urlDecoder:https%3A%2F%2Fairbyte.io}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {codeChallengeS256:{state_value}}\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_key}}&{redirect_uri_key}={urlEncoder:{{redirect_uri_key}}}&{state_key}={{state_key}}",\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_key}}",\n "{client_id_key}": "{{client_id_key}}",\n "{client_secret_key}": "{{client_secret_key}}"\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 }',
899-
title="DeclarativeOAuth Connector Specification",
900-
)
891+
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = Field(
892+
None,
893+
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`, {base64Encoder:{my_var_a}:{my_var_b}}\n + base64Decorer - decode from `base64` encoded string, {base64Decoder:{my_string_variable_or_string_value}}\n + urlEncoder - encode the input string to URL-like format, {urlEncoder:https://test.host.com/endpoint}\n + urlDecorer - decode the input url-encoded string into text format, {urlDecoder:https%3A%2F%2Fairbyte.io}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {codeChallengeS256:{state_value}}\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_key}}&{redirect_uri_key}={urlEncoder:{{redirect_uri_key}}}&{state_key}={{state_key}}",\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_key}}",\n "{client_id_key}": "{{client_id_key}}",\n "{client_secret_key}": "{{client_secret_key}}"\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 }',
894+
title="DeclarativeOAuth Connector Specification",
901895
)
902896
complete_oauth_output_specification: Optional[Dict[str, Any]] = Field(
903897
None,
@@ -915,9 +909,7 @@ class Config:
915909
complete_oauth_server_input_specification: Optional[Dict[str, Any]] = Field(
916910
None,
917911
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 }",
918-
examples=[
919-
{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}
920-
],
912+
examples=[{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}],
921913
title="OAuth input specification",
922914
)
923915
complete_oauth_server_output_specification: Optional[Dict[str, Any]] = Field(
@@ -1628,25 +1620,21 @@ class Config:
16281620
description="Component used to coordinate how records are extracted across stream slices and request pages.",
16291621
title="Retriever",
16301622
)
1631-
incremental_sync: Optional[Union[CustomIncrementalSync, DatetimeBasedCursor]] = (
1632-
Field(
1633-
None,
1634-
description="Component used to fetch data incrementally based on a time field in the data.",
1635-
title="Incremental Sync",
1636-
)
1637-
)
1638-
name: Optional[str] = Field(
1639-
"", description="The stream name.", example=["Users"], title="Name"
1623+
incremental_sync: Optional[Union[CustomIncrementalSync, DatetimeBasedCursor]] = Field(
1624+
None,
1625+
description="Component used to fetch data incrementally based on a time field in the data.",
1626+
title="Incremental Sync",
16401627
)
1628+
name: Optional[str] = Field("", description="The stream name.", example=["Users"], title="Name")
16411629
primary_key: Optional[PrimaryKey] = Field(
16421630
"", description="The primary key of the stream.", title="Primary Key"
16431631
)
1644-
schema_loader: Optional[
1645-
Union[InlineSchemaLoader, JsonFileSchemaLoader, CustomSchemaLoader]
1646-
] = Field(
1647-
None,
1648-
description="Component used to retrieve the schema for the current stream.",
1649-
title="Schema Loader",
1632+
schema_loader: Optional[Union[InlineSchemaLoader, JsonFileSchemaLoader, CustomSchemaLoader]] = (
1633+
Field(
1634+
None,
1635+
description="Component used to retrieve the schema for the current stream.",
1636+
title="Schema Loader",
1637+
)
16501638
)
16511639
transformations: Optional[
16521640
List[Union[AddFields, CustomTransformation, RemoveFields, KeysToLower]]
@@ -1864,11 +1852,7 @@ class SimpleRetriever(BaseModel):
18641852
CustomPartitionRouter,
18651853
ListPartitionRouter,
18661854
SubstreamPartitionRouter,
1867-
List[
1868-
Union[
1869-
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
1870-
]
1871-
],
1855+
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
18721856
]
18731857
] = Field(
18741858
[],
@@ -1910,9 +1894,7 @@ class AsyncRetriever(BaseModel):
19101894
)
19111895
download_extractor: Optional[
19121896
Union[CustomRecordExtractor, DpathExtractor, ResponseToFileExtractor]
1913-
] = Field(
1914-
None, description="Responsible for fetching the records from provided urls."
1915-
)
1897+
] = Field(None, description="Responsible for fetching the records from provided urls.")
19161898
creation_requester: Union[CustomRequester, HttpRequester] = Field(
19171899
...,
19181900
description="Requester component that describes how to prepare HTTP requests to send to the source API to create the async server-side job.",
@@ -1942,11 +1924,7 @@ class AsyncRetriever(BaseModel):
19421924
CustomPartitionRouter,
19431925
ListPartitionRouter,
19441926
SubstreamPartitionRouter,
1945-
List[
1946-
Union[
1947-
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
1948-
]
1949-
],
1927+
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
19501928
]
19511929
] = Field(
19521930
[],
@@ -2010,12 +1988,10 @@ class DynamicDeclarativeStream(BaseModel):
20101988
stream_template: DeclarativeStream = Field(
20111989
..., description="Reference to the stream template.", title="Stream Template"
20121990
)
2013-
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = (
2014-
Field(
2015-
...,
2016-
description="Component resolve and populates stream templates with components values.",
2017-
title="Components Resolver",
2018-
)
1991+
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = Field(
1992+
...,
1993+
description="Component resolve and populates stream templates with components values.",
1994+
title="Components Resolver",
20191995
)
20201996

20211997

unit_tests/sources/declarative/resolvers/test_config_components_resolver.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@
114114
(
115115
_CONFIG_WITH_STREAM_DUPLICATION,
116116
"Dynamic streams list contains a duplicate name: item_2. Please check your configuration.",
117-
None
117+
None,
118118
),
119119
],
120120
)
121-
def test_dynamic_streams_read_with_config_components_resolver(config, expected_exception, expected_stream_names):
121+
def test_dynamic_streams_read_with_config_components_resolver(
122+
config, expected_exception, expected_stream_names
123+
):
122124
if expected_exception:
123125
with pytest.raises(AirbyteTracedException) as exc_info:
124126
source = ConcurrentDeclarativeSource(

0 commit comments

Comments
 (0)