Skip to content

Commit 41a6abf

Browse files
committed
mypy
1 parent 9eca3a2 commit 41a6abf

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

airbyte_cdk/manifest_runner/command_processor/processor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from typing import Any, Iterable, List, Mapping, Tuple
2+
from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple
33

44
from airbyte_protocol_dataclasses.models import (
55
AirbyteCatalog,
@@ -13,7 +13,7 @@
1313
from airbyte_cdk.connector_builder.models import StreamRead
1414
from airbyte_cdk.connector_builder.test_reader import TestReader
1515
from airbyte_cdk.entrypoint import AirbyteEntrypoint
16-
from airbyte_cdk.models.airbyte_protocol import (
16+
from airbyte_cdk.models import (
1717
AirbyteStateMessage,
1818
ConfiguredAirbyteCatalog,
1919
)
@@ -78,7 +78,7 @@ def check_connection(
7878
def discover(
7979
self,
8080
config: Mapping[str, Any],
81-
) -> AirbyteCatalog | None:
81+
) -> Optional[AirbyteCatalog]:
8282
"""
8383
Discover the catalog from the source.
8484
"""
@@ -91,11 +91,11 @@ def discover(
9191
def _get_messages_by_type(
9292
self,
9393
messages: Iterable[AirbyteMessage],
94-
) -> Mapping[str, Iterable[AirbyteMessage]]:
94+
) -> Dict[str, List[AirbyteMessage]]:
9595
"""
9696
Group messages by type.
9797
"""
98-
grouped = {}
98+
grouped: Dict[str, List[AirbyteMessage]] = {}
9999
for message in messages:
100100
msg_type = message.type
101101
if msg_type not in grouped:
@@ -106,7 +106,7 @@ def _get_messages_by_type(
106106
def _get_connection_status(
107107
self,
108108
messages_by_type: Mapping[str, List[AirbyteMessage]],
109-
) -> AirbyteConnectionStatus | None:
109+
) -> Optional[AirbyteConnectionStatus]:
110110
"""
111111
Get the connection status from the messages.
112112
"""
@@ -116,7 +116,7 @@ def _get_connection_status(
116116
def _get_catalog(
117117
self,
118118
messages_by_type: Mapping[str, List[AirbyteMessage]],
119-
) -> AirbyteCatalog:
119+
) -> Optional[AirbyteCatalog]:
120120
"""
121121
Get the catalog from the messages.
122122
"""

airbyte_cdk/manifest_runner/command_processor/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any, Mapping
22

3-
from airbyte_cdk.models.airbyte_protocol import (
3+
from airbyte_cdk.models import (
44
AirbyteStream,
55
ConfiguredAirbyteCatalog,
66
ConfiguredAirbyteStream,

airbyte_cdk/manifest_runner/routers/health.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Dict
2+
13
from fastapi import APIRouter
24

35
router = APIRouter(
@@ -7,5 +9,5 @@
79

810

911
@router.get("/")
10-
def health():
12+
def health() -> Dict[str, str]:
1113
return {"status": "ok"}

airbyte_cdk/manifest_runner/routers/manifest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import hashlib
22
from dataclasses import asdict
3-
from typing import Any, Dict, List
3+
from typing import Any, Dict, List, Mapping
44

55
import jsonschema
66
from fastapi import APIRouter, Depends, HTTPException
@@ -12,13 +12,15 @@
1212
DiscoverResponse,
1313
)
1414
from airbyte_cdk.models import AirbyteStateMessageSerializer
15+
from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource
1516
from airbyte_cdk.sources.declarative.parsers.custom_code_compiler import (
1617
INJECTED_COMPONENTS_PY,
1718
INJECTED_COMPONENTS_PY_CHECKSUMS,
1819
)
1920

2021
from ..api_models import (
2122
FullResolveRequest,
23+
Manifest,
2224
ManifestResponse,
2325
ResolveRequest,
2426
StreamRead,
@@ -29,7 +31,9 @@
2931
from ..command_processor.utils import build_catalog, build_source
3032

3133

32-
def safe_build_source(manifest_dict, config_dict):
34+
def safe_build_source(
35+
manifest_dict: Mapping[str, Any], config_dict: Mapping[str, Any]
36+
) -> ManifestDeclarativeSource:
3337
"""Wrapper around build_source that converts ValidationError to HTTPException."""
3438
try:
3539
return build_source(manifest_dict, config_dict)
@@ -97,7 +101,7 @@ def discover(request: DiscoverRequest) -> DiscoverResponse:
97101
def resolve(request: ResolveRequest) -> ManifestResponse:
98102
"""Resolve a manifest to its final configuration."""
99103
source = safe_build_source(request.manifest.model_dump(), {})
100-
return ManifestResponse(manifest=source.resolved_manifest)
104+
return ManifestResponse(manifest=Manifest(**source.resolved_manifest))
101105

102106

103107
@router.post("/full_resolve", operation_id="fullResolve")
@@ -125,4 +129,4 @@ def full_resolve(request: FullResolveRequest) -> ManifestResponse:
125129
streams.extend(generated_streams_list)
126130

127131
manifest["streams"] = streams
128-
return ManifestResponse(manifest=manifest)
132+
return ManifestResponse(manifest=Manifest(**manifest))

0 commit comments

Comments
 (0)