Skip to content

Commit f62c91e

Browse files
authored
chore: set line length 100 (#14)
1 parent 29ae4fc commit f62c91e

File tree

374 files changed

+18598
-4712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

374 files changed

+18598
-4712
lines changed

.github/workflows/semantic_pr_check.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2323
with:
2424
# Configure which types are allowed (newline-delimited).
25+
# These are intentionally case-insensitive, allowing title casing or all lowercase.
2526
# See: https://github.com/commitizen/conventional-commit-types/blob/master/index.json
2627
types: |
2728
fix
@@ -38,17 +39,3 @@ jobs:
3839
Build
3940
test
4041
Test
41-
42-
# # We don't use scopes as of now
43-
# scopes: |
44-
# core
45-
# ui
46-
# JIRA-\d+
47-
48-
# Require capitalization for the first letter of the subject.
49-
subjectPattern: ^[A-Z].*$
50-
# The variables `subject` and `title` can be used within the message.
51-
subjectPatternError: |
52-
The subject "{subject}" found in the pull request title "{title}"
53-
didn't match the configured pattern. Please check the title against
54-
the naming rules. You can also use the [WIP] prefix to bypass this check.

airbyte_cdk/config_observation.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323

2424
class ObservedDict(dict): # type: ignore # disallow_any_generics is set to True, and dict is equivalent to dict[Any]
2525
def __init__(
26-
self, non_observed_mapping: MutableMapping[Any, Any], observer: ConfigObserver, update_on_unchanged_value: bool = True
26+
self,
27+
non_observed_mapping: MutableMapping[Any, Any],
28+
observer: ConfigObserver,
29+
update_on_unchanged_value: bool = True,
2730
) -> None:
2831
non_observed_mapping = copy(non_observed_mapping)
2932
self.observer = observer
@@ -69,11 +72,15 @@ def update(self) -> None:
6972
emit_configuration_as_airbyte_control_message(self.config)
7073

7174

72-
def observe_connector_config(non_observed_connector_config: MutableMapping[str, Any]) -> ObservedDict:
75+
def observe_connector_config(
76+
non_observed_connector_config: MutableMapping[str, Any],
77+
) -> ObservedDict:
7378
if isinstance(non_observed_connector_config, ObservedDict):
7479
raise ValueError("This connector configuration is already observed")
7580
connector_config_observer = ConfigObserver()
76-
observed_connector_config = ObservedDict(non_observed_connector_config, connector_config_observer)
81+
observed_connector_config = ObservedDict(
82+
non_observed_connector_config, connector_config_observer
83+
)
7784
connector_config_observer.set_config(observed_connector_config)
7885
return observed_connector_config
7986

airbyte_cdk/connector.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
from typing import Any, Generic, Mapping, Optional, Protocol, TypeVar
1212

1313
import yaml
14-
from airbyte_cdk.models import AirbyteConnectionStatus, ConnectorSpecification, ConnectorSpecificationSerializer
14+
from airbyte_cdk.models import (
15+
AirbyteConnectionStatus,
16+
ConnectorSpecification,
17+
ConnectorSpecificationSerializer,
18+
)
1519

1620

1721
def load_optional_package_file(package: str, filename: str) -> Optional[bytes]:
@@ -53,7 +57,9 @@ def _read_json_file(file_path: str) -> Any:
5357
try:
5458
return json.loads(contents)
5559
except json.JSONDecodeError as error:
56-
raise ValueError(f"Could not read json file {file_path}: {error}. Please ensure that it is a valid JSON.")
60+
raise ValueError(
61+
f"Could not read json file {file_path}: {error}. Please ensure that it is a valid JSON."
62+
)
5763

5864
@staticmethod
5965
def write_config(config: TConfig, config_path: str) -> None:
@@ -72,15 +78,19 @@ def spec(self, logger: logging.Logger) -> ConnectorSpecification:
7278
json_spec = load_optional_package_file(package, "spec.json")
7379

7480
if yaml_spec and json_spec:
75-
raise RuntimeError("Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.")
81+
raise RuntimeError(
82+
"Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided."
83+
)
7684

7785
if yaml_spec:
7886
spec_obj = yaml.load(yaml_spec, Loader=yaml.SafeLoader)
7987
elif json_spec:
8088
try:
8189
spec_obj = json.loads(json_spec)
8290
except json.JSONDecodeError as error:
83-
raise ValueError(f"Could not read json spec file: {error}. Please ensure that it is a valid JSON.")
91+
raise ValueError(
92+
f"Could not read json spec file: {error}. Please ensure that it is a valid JSON."
93+
)
8494
else:
8595
raise FileNotFoundError("Unable to find spec.yaml or spec.json in the package.")
8696

@@ -101,7 +111,9 @@ def write_config(config: Mapping[str, Any], config_path: str) -> None: ...
101111

102112
class DefaultConnectorMixin:
103113
# can be overridden to change an input config
104-
def configure(self: _WriteConfigProtocol, config: Mapping[str, Any], temp_dir: str) -> Mapping[str, Any]:
114+
def configure(
115+
self: _WriteConfigProtocol, config: Mapping[str, Any], temp_dir: str
116+
) -> Mapping[str, Any]:
105117
config_path = os.path.join(temp_dir, "config.json")
106118
self.write_config(config, config_path)
107119
return config

airbyte_cdk/connector_builder/connector_builder_handler.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77
from typing import Any, List, Mapping
88

99
from airbyte_cdk.connector_builder.message_grouper import MessageGrouper
10-
from airbyte_cdk.models import AirbyteMessage, AirbyteRecordMessage, AirbyteStateMessage, ConfiguredAirbyteCatalog
10+
from airbyte_cdk.models import (
11+
AirbyteMessage,
12+
AirbyteRecordMessage,
13+
AirbyteStateMessage,
14+
ConfiguredAirbyteCatalog,
15+
)
1116
from airbyte_cdk.models import Type
1217
from airbyte_cdk.models import Type as MessageType
1318
from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
1419
from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource
15-
from airbyte_cdk.sources.declarative.parsers.model_to_component_factory import ModelToComponentFactory
20+
from airbyte_cdk.sources.declarative.parsers.model_to_component_factory import (
21+
ModelToComponentFactory,
22+
)
1623
from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets
1724
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
1825

@@ -34,7 +41,9 @@ class TestReadLimits:
3441

3542
def get_limits(config: Mapping[str, Any]) -> TestReadLimits:
3643
command_config = config.get("__test_read_config", {})
37-
max_pages_per_slice = command_config.get(MAX_PAGES_PER_SLICE_KEY) or DEFAULT_MAXIMUM_NUMBER_OF_PAGES_PER_SLICE
44+
max_pages_per_slice = (
45+
command_config.get(MAX_PAGES_PER_SLICE_KEY) or DEFAULT_MAXIMUM_NUMBER_OF_PAGES_PER_SLICE
46+
)
3847
max_slices = command_config.get(MAX_SLICES_KEY) or DEFAULT_MAXIMUM_NUMBER_OF_SLICES
3948
max_records = command_config.get(MAX_RECORDS_KEY) or DEFAULT_MAXIMUM_RECORDS
4049
return TestReadLimits(max_records, max_pages_per_slice, max_slices)
@@ -64,15 +73,24 @@ def read_stream(
6473
) -> AirbyteMessage:
6574
try:
6675
handler = MessageGrouper(limits.max_pages_per_slice, limits.max_slices, limits.max_records)
67-
stream_name = configured_catalog.streams[0].stream.name # The connector builder only supports a single stream
68-
stream_read = handler.get_message_groups(source, config, configured_catalog, state, limits.max_records)
76+
stream_name = configured_catalog.streams[
77+
0
78+
].stream.name # The connector builder only supports a single stream
79+
stream_read = handler.get_message_groups(
80+
source, config, configured_catalog, state, limits.max_records
81+
)
6982
return AirbyteMessage(
7083
type=MessageType.RECORD,
71-
record=AirbyteRecordMessage(data=dataclasses.asdict(stream_read), stream=stream_name, emitted_at=_emitted_at()),
84+
record=AirbyteRecordMessage(
85+
data=dataclasses.asdict(stream_read), stream=stream_name, emitted_at=_emitted_at()
86+
),
7287
)
7388
except Exception as exc:
7489
error = AirbyteTracedException.from_exception(
75-
exc, message=filter_secrets(f"Error reading stream with config={config} and catalog={configured_catalog}: {str(exc)}")
90+
exc,
91+
message=filter_secrets(
92+
f"Error reading stream with config={config} and catalog={configured_catalog}: {str(exc)}"
93+
),
7694
)
7795
return error.as_airbyte_message()
7896

@@ -88,7 +106,9 @@ def resolve_manifest(source: ManifestDeclarativeSource) -> AirbyteMessage:
88106
),
89107
)
90108
except Exception as exc:
91-
error = AirbyteTracedException.from_exception(exc, message=f"Error resolving manifest: {str(exc)}")
109+
error = AirbyteTracedException.from_exception(
110+
exc, message=f"Error resolving manifest: {str(exc)}"
111+
)
92112
return error.as_airbyte_message()
93113

94114

airbyte_cdk/connector_builder/main.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
from typing import Any, List, Mapping, Optional, Tuple
88

99
from airbyte_cdk.connector import BaseConnector
10-
from airbyte_cdk.connector_builder.connector_builder_handler import TestReadLimits, create_source, get_limits, read_stream, resolve_manifest
10+
from airbyte_cdk.connector_builder.connector_builder_handler import (
11+
TestReadLimits,
12+
create_source,
13+
get_limits,
14+
read_stream,
15+
resolve_manifest,
16+
)
1117
from airbyte_cdk.entrypoint import AirbyteEntrypoint
1218
from airbyte_cdk.models import (
1319
AirbyteMessage,
@@ -22,11 +28,17 @@
2228
from orjson import orjson
2329

2430

25-
def get_config_and_catalog_from_args(args: List[str]) -> Tuple[str, Mapping[str, Any], Optional[ConfiguredAirbyteCatalog], Any]:
31+
def get_config_and_catalog_from_args(
32+
args: List[str],
33+
) -> Tuple[str, Mapping[str, Any], Optional[ConfiguredAirbyteCatalog], Any]:
2634
# TODO: Add functionality for the `debug` logger.
2735
# Currently, no one `debug` level log will be displayed during `read` a stream for a connector created through `connector-builder`.
2836
parsed_args = AirbyteEntrypoint.parse_args(args)
29-
config_path, catalog_path, state_path = parsed_args.config, parsed_args.catalog, parsed_args.state
37+
config_path, catalog_path, state_path = (
38+
parsed_args.config,
39+
parsed_args.catalog,
40+
parsed_args.state,
41+
)
3042
if parsed_args.command != "read":
3143
raise ValueError("Only read commands are allowed for Connector Builder requests.")
3244

@@ -64,7 +76,9 @@ def handle_connector_builder_request(
6476
if command == "resolve_manifest":
6577
return resolve_manifest(source)
6678
elif command == "test_read":
67-
assert catalog is not None, "`test_read` requires a valid `ConfiguredAirbyteCatalog`, got None."
79+
assert (
80+
catalog is not None
81+
), "`test_read` requires a valid `ConfiguredAirbyteCatalog`, got None."
6882
return read_stream(source, config, catalog, state, limits)
6983
else:
7084
raise ValueError(f"Unrecognized command {command}.")
@@ -75,14 +89,18 @@ def handle_request(args: List[str]) -> str:
7589
limits = get_limits(config)
7690
source = create_source(config, limits)
7791
return orjson.dumps(
78-
AirbyteMessageSerializer.dump(handle_connector_builder_request(source, command, config, catalog, state, limits))
92+
AirbyteMessageSerializer.dump(
93+
handle_connector_builder_request(source, command, config, catalog, state, limits)
94+
)
7995
).decode() # type: ignore[no-any-return] # Serializer.dump() always returns AirbyteMessage
8096

8197

8298
if __name__ == "__main__":
8399
try:
84100
print(handle_request(sys.argv[1:]))
85101
except Exception as exc:
86-
error = AirbyteTracedException.from_exception(exc, message=f"Error handling request: {str(exc)}")
102+
error = AirbyteTracedException.from_exception(
103+
exc, message=f"Error handling request: {str(exc)}"
104+
)
87105
m = error.as_airbyte_message()
88106
print(orjson.dumps(AirbyteMessageSerializer.dump(m)).decode())

0 commit comments

Comments
 (0)