Skip to content

Commit bad7b6f

Browse files
author
octavia-squidington-iii
committed
Auto-fix lint and format issues
1 parent 47bbee8 commit bad7b6f

File tree

4 files changed

+42
-58
lines changed

4 files changed

+42
-58
lines changed

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 28 additions & 52 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(
@@ -1085,28 +1083,24 @@ class OAuthConfigSpecification(BaseModel):
10851083
class Config:
10861084
extra = Extra.allow
10871085

1088-
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = (
1089-
Field(
1090-
None,
1091-
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 }",
1092-
examples=[
1093-
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1094-
{
1095-
"app_id": {
1096-
"type": "string",
1097-
"path_in_connector_config": ["info", "app_id"],
1098-
}
1099-
},
1100-
],
1101-
title="OAuth user input",
1102-
)
1086+
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = Field(
1087+
None,
1088+
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 }",
1089+
examples=[
1090+
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1091+
{
1092+
"app_id": {
1093+
"type": "string",
1094+
"path_in_connector_config": ["info", "app_id"],
1095+
}
1096+
},
1097+
],
1098+
title="OAuth user input",
11031099
)
1104-
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = (
1105-
Field(
1106-
None,
1107-
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 }',
1108-
title="DeclarativeOAuth Connector Specification",
1109-
)
1100+
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = 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",
11101104
)
11111105
complete_oauth_output_specification: Optional[Dict[str, Any]] = Field(
11121106
None,
@@ -1124,9 +1118,7 @@ class Config:
11241118
complete_oauth_server_input_specification: Optional[Dict[str, Any]] = Field(
11251119
None,
11261120
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 }",
1127-
examples=[
1128-
{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}
1129-
],
1121+
examples=[{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}],
11301122
title="OAuth input specification",
11311123
)
11321124
complete_oauth_server_output_specification: Optional[Dict[str, Any]] = Field(
@@ -1789,9 +1781,7 @@ class RecordSelector(BaseModel):
17891781
description="Responsible for filtering records to be emitted by the Source.",
17901782
title="Record Filter",
17911783
)
1792-
schema_normalization: Optional[
1793-
Union[SchemaNormalization, CustomSchemaNormalization]
1794-
] = Field(
1784+
schema_normalization: Optional[Union[SchemaNormalization, CustomSchemaNormalization]] = Field(
17951785
SchemaNormalization.None_,
17961786
description="Responsible for normalization according to the schema.",
17971787
title="Schema Normalization",
@@ -2002,9 +1992,7 @@ class Config:
20021992
description="Component used to fetch data incrementally based on a time field in the data.",
20031993
title="Incremental Sync",
20041994
)
2005-
name: Optional[str] = Field(
2006-
"", description="The stream name.", example=["Users"], title="Name"
2007-
)
1995+
name: Optional[str] = Field("", description="The stream name.", example=["Users"], title="Name")
20081996
primary_key: Optional[PrimaryKey] = Field(
20091997
"", description="The primary key of the stream.", title="Primary Key"
20101998
)
@@ -2278,11 +2266,7 @@ class SimpleRetriever(BaseModel):
22782266
CustomPartitionRouter,
22792267
ListPartitionRouter,
22802268
SubstreamPartitionRouter,
2281-
List[
2282-
Union[
2283-
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
2284-
]
2285-
],
2269+
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
22862270
]
22872271
] = Field(
22882272
[],
@@ -2326,9 +2310,7 @@ class AsyncRetriever(BaseModel):
23262310
)
23272311
download_extractor: Optional[
23282312
Union[CustomRecordExtractor, DpathExtractor, ResponseToFileExtractor]
2329-
] = Field(
2330-
None, description="Responsible for fetching the records from provided urls."
2331-
)
2313+
] = Field(None, description="Responsible for fetching the records from provided urls.")
23322314
creation_requester: Union[CustomRequester, HttpRequester] = Field(
23332315
...,
23342316
description="Requester component that describes how to prepare HTTP requests to send to the source API to create the async server-side job.",
@@ -2362,11 +2344,7 @@ class AsyncRetriever(BaseModel):
23622344
CustomPartitionRouter,
23632345
ListPartitionRouter,
23642346
SubstreamPartitionRouter,
2365-
List[
2366-
Union[
2367-
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
2368-
]
2369-
],
2347+
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
23702348
]
23712349
] = Field(
23722350
[],
@@ -2434,12 +2412,10 @@ class DynamicDeclarativeStream(BaseModel):
24342412
stream_template: DeclarativeStream = Field(
24352413
..., description="Reference to the stream template.", title="Stream Template"
24362414
)
2437-
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = (
2438-
Field(
2439-
...,
2440-
description="Component resolve and populates stream templates with components values.",
2441-
title="Components Resolver",
2442-
)
2415+
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = Field(
2416+
...,
2417+
description="Component resolve and populates stream templates with components values.",
2418+
title="Components Resolver",
24432419
)
24442420

24452421

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,11 @@ def create_add_fields(self, model: AddFieldsModel, config: Config, **kwargs: Any
706706
)
707707
for added_field_definition_model in model.fields
708708
]
709-
return AddFields(fields=added_field_definitions, condition=model.condition, parameters=model.parameters or {})
709+
return AddFields(
710+
fields=added_field_definitions,
711+
condition=model.condition,
712+
parameters=model.parameters or {},
713+
)
710714

711715
def create_keys_to_lower_transformation(
712716
self, model: KeysToLowerModel, config: Config, **kwargs: Any
@@ -742,9 +746,7 @@ def create_dpath_flatten_fields(
742746
delete_origin_value=model.delete_origin_value
743747
if model.delete_origin_value is not None
744748
else False,
745-
replace_record=model.replace_record
746-
if model.replace_record is not None
747-
else False,
749+
replace_record=model.replace_record if model.replace_record is not None else False,
748750
parameters=model.parameters or {},
749751
)
750752

unit_tests/sources/declarative/transformations/test_add_fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,7 @@ def test_add_fields(
190190
AddedFieldDefinition(path=v[0], value=v[1], value_type=field_type, parameters={})
191191
for v in field
192192
]
193-
AddFields(fields=inputs, condition=condition, parameters={"alas": "i live"}).transform(input_record, **kwargs)
193+
AddFields(fields=inputs, condition=condition, parameters={"alas": "i live"}).transform(
194+
input_record, **kwargs
195+
)
194196
assert input_record == expected

unit_tests/sources/declarative/transformations/test_dpath_flatten_fields.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ def test_dpath_flatten_lists(
134134
input_record, config, field_path, delete_origin_value, replace_record, expected_record
135135
):
136136
flattener = DpathFlattenFields(
137-
field_path=field_path, parameters={}, config=config, delete_origin_value=delete_origin_value, replace_record=replace_record
137+
field_path=field_path,
138+
parameters={},
139+
config=config,
140+
delete_origin_value=delete_origin_value,
141+
replace_record=replace_record,
138142
)
139143
flattener.transform(input_record)
140144
assert input_record == expected_record

0 commit comments

Comments
 (0)