Skip to content

Commit e69647e

Browse files
style: apply ruff formatting to field annotations
Co-Authored-By: AJ Steers <[email protected]>
1 parent 042a18b commit e69647e

File tree

1 file changed

+47
-71
lines changed

1 file changed

+47
-71
lines changed

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 47 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,7 @@ class OAuthAuthenticator(BaseModel):
621621
scopes: Optional[List[str]] = Field(
622622
None,
623623
description="List of scopes that should be granted to the access token.",
624-
examples=[
625-
["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]
626-
],
624+
examples=[["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]],
627625
title="Scopes",
628626
)
629627
token_expiry_date: Optional[str] = Field(
@@ -1134,28 +1132,24 @@ class OAuthConfigSpecification(BaseModel):
11341132
class Config:
11351133
extra = Extra.allow
11361134

1137-
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = (
1138-
Field(
1139-
None,
1140-
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 }",
1141-
examples=[
1142-
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1143-
{
1144-
"app_id": {
1145-
"type": "string",
1146-
"path_in_connector_config": ["info", "app_id"],
1147-
}
1148-
},
1149-
],
1150-
title="OAuth user input",
1151-
)
1135+
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = Field(
1136+
None,
1137+
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 }",
1138+
examples=[
1139+
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1140+
{
1141+
"app_id": {
1142+
"type": "string",
1143+
"path_in_connector_config": ["info", "app_id"],
1144+
}
1145+
},
1146+
],
1147+
title="OAuth user input",
11521148
)
1153-
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = (
1154-
Field(
1155-
None,
1156-
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 }',
1157-
title="DeclarativeOAuth Connector Specification",
1158-
)
1149+
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = Field(
1150+
None,
1151+
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 }',
1152+
title="DeclarativeOAuth Connector Specification",
11591153
)
11601154
complete_oauth_output_specification: Optional[Dict[str, Any]] = Field(
11611155
None,
@@ -1173,9 +1167,7 @@ class Config:
11731167
complete_oauth_server_input_specification: Optional[Dict[str, Any]] = Field(
11741168
None,
11751169
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 }",
1176-
examples=[
1177-
{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}
1178-
],
1170+
examples=[{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}],
11791171
title="OAuth input specification",
11801172
)
11811173
complete_oauth_server_output_specification: Optional[Dict[str, Any]] = Field(
@@ -1671,9 +1663,7 @@ class CustomConfigTransformation(BaseModel):
16711663
class_name: str = Field(
16721664
...,
16731665
description="Fully-qualified name of the class that will be implementing the custom config transformation. The format is `source_<name>.<package>.<class_name>`.",
1674-
examples=[
1675-
"source_declarative_manifest.components.MyCustomConfigTransformation"
1676-
],
1666+
examples=["source_declarative_manifest.components.MyCustomConfigTransformation"],
16771667
)
16781668
parameters: Optional[Dict[str, Any]] = Field(
16791669
None,
@@ -2058,9 +2048,7 @@ class RecordSelector(BaseModel):
20582048
description="Responsible for filtering records to be emitted by the Source.",
20592049
title="Record Filter",
20602050
)
2061-
schema_normalization: Optional[
2062-
Union[SchemaNormalization, CustomSchemaNormalization]
2063-
] = Field(
2051+
schema_normalization: Optional[Union[SchemaNormalization, CustomSchemaNormalization]] = Field(
20642052
None,
20652053
description="Responsible for normalization according to the schema.",
20662054
title="Schema Normalization",
@@ -2096,12 +2084,10 @@ class DpathValidator(BaseModel):
20962084
],
20972085
title="Field Path",
20982086
)
2099-
validation_strategy: Union[ValidateAdheresToSchema, CustomValidationStrategy] = (
2100-
Field(
2101-
...,
2102-
description="The condition that the specified config value will be evaluated against",
2103-
title="Validation Strategy",
2104-
)
2087+
validation_strategy: Union[ValidateAdheresToSchema, CustomValidationStrategy] = Field(
2088+
...,
2089+
description="The condition that the specified config value will be evaluated against",
2090+
title="Validation Strategy",
21052091
)
21062092

21072093

@@ -2118,12 +2104,10 @@ class PredicateValidator(BaseModel):
21182104
],
21192105
title="Value",
21202106
)
2121-
validation_strategy: Union[ValidateAdheresToSchema, CustomValidationStrategy] = (
2122-
Field(
2123-
...,
2124-
description="The validation strategy to apply to the value.",
2125-
title="Validation Strategy",
2126-
)
2107+
validation_strategy: Union[ValidateAdheresToSchema, CustomValidationStrategy] = Field(
2108+
...,
2109+
description="The validation strategy to apply to the value.",
2110+
title="Validation Strategy",
21272111
)
21282112

21292113

@@ -2313,9 +2297,9 @@ class Config:
23132297

23142298
type: Literal["DeclarativeSource"]
23152299
check: Union[CheckStream, CheckDynamicStream]
2316-
streams: Optional[
2317-
List[Union[ConditionalStreams, DeclarativeStream, StateDelegatingStream]]
2318-
] = None
2300+
streams: Optional[List[Union[ConditionalStreams, DeclarativeStream, StateDelegatingStream]]] = (
2301+
None
2302+
)
23192303
dynamic_streams: List[DynamicDeclarativeStream]
23202304
version: str = Field(
23212305
...,
@@ -2440,9 +2424,7 @@ class Config:
24402424
extra = Extra.allow
24412425

24422426
type: Literal["DeclarativeStream"]
2443-
name: Optional[str] = Field(
2444-
"", description="The stream name.", example=["Users"], title="Name"
2445-
)
2427+
name: Optional[str] = Field("", description="The stream name.", example=["Users"], title="Name")
24462428
retriever: Union[SimpleRetriever, AsyncRetriever, CustomRetriever] = Field(
24472429
...,
24482430
description="Component used to coordinate how records are extracted across stream slices and request pages.",
@@ -2627,20 +2609,18 @@ class HttpRequester(BaseModelWithDeprecations):
26272609
description="For APIs that require explicit specification of the properties to query for, this component will take a static or dynamic set of properties (which can be optionally split into chunks) and allow them to be injected into an outbound request by accessing stream_partition.extra_fields.",
26282610
title="Query Properties",
26292611
)
2630-
request_parameters: Optional[Union[Dict[str, Union[str, QueryProperties]], str]] = (
2631-
Field(
2632-
None,
2633-
description="Specifies the query parameters that should be set on an outgoing HTTP request given the inputs.",
2634-
examples=[
2635-
{"unit": "day"},
2636-
{
2637-
"query": 'last_event_time BETWEEN TIMESTAMP "{{ stream_interval.start_time }}" AND TIMESTAMP "{{ stream_interval.end_time }}"'
2638-
},
2639-
{"searchIn": "{{ ','.join(config.get('search_in', [])) }}"},
2640-
{"sort_by[asc]": "updated_at"},
2641-
],
2642-
title="Query Parameters",
2643-
)
2612+
request_parameters: Optional[Union[Dict[str, Union[str, QueryProperties]], str]] = Field(
2613+
None,
2614+
description="Specifies the query parameters that should be set on an outgoing HTTP request given the inputs.",
2615+
examples=[
2616+
{"unit": "day"},
2617+
{
2618+
"query": 'last_event_time BETWEEN TIMESTAMP "{{ stream_interval.start_time }}" AND TIMESTAMP "{{ stream_interval.end_time }}"'
2619+
},
2620+
{"searchIn": "{{ ','.join(config.get('search_in', [])) }}"},
2621+
{"sort_by[asc]": "updated_at"},
2622+
],
2623+
title="Query Parameters",
26442624
)
26452625
request_headers: Optional[Union[Dict[str, str], str]] = Field(
26462626
None,
@@ -2807,9 +2787,7 @@ class QueryProperties(BaseModel):
28072787

28082788
class StateDelegatingStream(BaseModel):
28092789
type: Literal["StateDelegatingStream"]
2810-
name: str = Field(
2811-
..., description="The stream name.", example=["Users"], title="Name"
2812-
)
2790+
name: str = Field(..., description="The stream name.", example=["Users"], title="Name")
28132791
full_refresh_stream: DeclarativeStream = Field(
28142792
...,
28152793
description="Component used to coordinate how records are extracted across stream slices and request pages when the state is empty or not provided.",
@@ -2898,9 +2876,7 @@ class AsyncRetriever(BaseModel):
28982876
)
28992877
download_extractor: Optional[
29002878
Union[DpathExtractor, CustomRecordExtractor, ResponseToFileExtractor]
2901-
] = Field(
2902-
None, description="Responsible for fetching the records from provided urls."
2903-
)
2879+
] = Field(None, description="Responsible for fetching the records from provided urls.")
29042880
creation_requester: Union[HttpRequester, CustomRequester] = Field(
29052881
...,
29062882
description="Requester component that describes how to prepare HTTP requests to send to the source API to create the async server-side job.",

0 commit comments

Comments
 (0)