Skip to content

Commit 273a886

Browse files
committed
update typing
1 parent 5ca4561 commit 273a886

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,11 @@ def __init__(
144144
# apply additional post-processing to the manifest
145145
self._post_process_manifest()
146146

147-
self._config: Mapping[str, Any]
148-
self._spec_component: Optional[Spec]
149147
spec: Optional[Mapping[str, Any]] = self._source_config.get("spec")
150-
self._spec_component = (
148+
self._spec_component: Optional[Spec] = (
151149
self._constructor.create_component(SpecModel, spec, dict()) if spec else None
152150
)
153-
self._config = self._migrate_and_transform_config(config_path, config)
151+
self._config = self._migrate_and_transform_config(config_path, config) or {}
154152

155153
@property
156154
def resolved_manifest(self) -> Mapping[str, Any]:
@@ -216,23 +214,24 @@ def _migrate_and_transform_config(
216214
self,
217215
config_path: Optional[str],
218216
config: Optional[Config],
219-
) -> Config:
220-
mutable_config = dict(config) if config else {}
221-
if self._spec_component:
222-
self._spec_component.migrate_config(mutable_config)
223-
if mutable_config != config:
224-
if config_path:
225-
with open(config_path, "w") as f:
226-
json.dump(mutable_config, f)
227-
self.message_repository.emit_message(
228-
create_connector_config_control_message(mutable_config)
229-
)
230-
# We have no mechanism for consuming the queue, so we print the messages to stdout
231-
for message in self.message_repository.consume_queue():
232-
print(orjson.dumps(AirbyteMessageSerializer.dump(message)).decode())
233-
234-
self._spec_component.transform_config(mutable_config)
235-
217+
) -> Optional[Config]:
218+
if not config:
219+
return None
220+
if not self._spec_component:
221+
return config
222+
mutable_config = dict(config)
223+
self._spec_component.migrate_config(mutable_config)
224+
if mutable_config != config:
225+
if config_path:
226+
with open(config_path, "w") as f:
227+
json.dump(mutable_config, f)
228+
self.message_repository.emit_message(
229+
create_connector_config_control_message(mutable_config)
230+
)
231+
# We have no mechanism for consuming the queue, so we print the messages to stdout
232+
for message in self.message_repository.consume_queue():
233+
print(orjson.dumps(AirbyteMessageSerializer.dump(message)).decode())
234+
self._spec_component.transform_config(mutable_config)
236235
return mutable_config
237236

238237
def _migrate_manifest(self) -> None:

0 commit comments

Comments
 (0)