Skip to content

Commit 7a96851

Browse files
committed
remove more imports from type checking blocks
1 parent c3ce1ee commit 7a96851

File tree

9 files changed

+37
-60
lines changed

9 files changed

+37
-60
lines changed

airbyte_cdk/connector_builder/connector_builder_handler.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from __future__ import annotations
55

66
import dataclasses
7+
from collections.abc import Mapping
78
from datetime import datetime
89
from typing import TYPE_CHECKING, Any
910

@@ -16,6 +17,7 @@
1617
Type,
1718
)
1819
from airbyte_cdk.models import Type as MessageType
20+
from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
1921
from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource
2022
from airbyte_cdk.sources.declarative.parsers.model_to_component_factory import (
2123
ModelToComponentFactory,
@@ -25,10 +27,7 @@
2527

2628

2729
if TYPE_CHECKING:
28-
from collections.abc import Mapping
29-
3030
from airbyte_cdk.connector_builder.models import StreamRead
31-
from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
3231

3332

3433
DEFAULT_MAXIMUM_NUMBER_OF_PAGES_PER_SLICE = 5

airbyte_cdk/connector_builder/main.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from __future__ import annotations
55

66
import sys
7+
from collections.abc import Mapping
78
from typing import TYPE_CHECKING, Any
89

910
import orjson
@@ -24,18 +25,11 @@
2425
ConfiguredAirbyteCatalog,
2526
ConfiguredAirbyteCatalogSerializer,
2627
)
28+
from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource
2729
from airbyte_cdk.sources.source import Source
2830
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
2931

3032

31-
if TYPE_CHECKING:
32-
from collections.abc import Mapping
33-
34-
from airbyte_cdk.sources.declarative.manifest_declarative_source import (
35-
ManifestDeclarativeSource,
36-
)
37-
38-
3933
def get_config_and_catalog_from_args(
4034
args: list[str],
4135
) -> tuple[str, Mapping[str, Any], ConfiguredAirbyteCatalog | None, Any]:

airbyte_cdk/connector_builder/message_grouper.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import logging
88
from copy import deepcopy
99
from json import JSONDecodeError
10-
from typing import TYPE_CHECKING, Any
10+
from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Union
1111

1212
from airbyte_cdk.connector_builder.models import (
1313
AuxiliaryRequest,
@@ -30,19 +30,14 @@
3030
TraceType,
3131
)
3232
from airbyte_cdk.models import Type as MessageType
33+
from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
3334
from airbyte_cdk.sources.utils.slice_logger import SliceLogger
35+
from airbyte_cdk.sources.utils.types import JsonType
3436
from airbyte_cdk.utils import AirbyteTracedException
3537
from airbyte_cdk.utils.datetime_format_inferrer import DatetimeFormatInferrer
3638
from airbyte_cdk.utils.schema_inferrer import SchemaInferrer, SchemaValidationException
3739

3840

39-
if TYPE_CHECKING:
40-
from collections.abc import Iterable, Iterator, Mapping
41-
42-
from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
43-
from airbyte_cdk.sources.utils.types import JsonType
44-
45-
4641
class MessageGrouper:
4742
logger = logging.getLogger("airbyte.connector-builder")
4843

airbyte_cdk/sources/declarative/async_job/job_orchestrator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets
2727
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
2828

29+
from collections.abc import Generator, Iterable, Mapping
2930

3031
if TYPE_CHECKING:
31-
from collections.abc import Generator, Iterable, Mapping
32-
3332
from airbyte_cdk import StreamSlice
3433
from airbyte_cdk.sources.declarative.async_job.repository import AsyncJobRepository
3534
from airbyte_cdk.sources.message import MessageRepository

airbyte_cdk/sources/declarative/auth/token_provider.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@
1111

1212
import dpath
1313
import pendulum
14+
from isodate import Duration
1415
from pendulum import DateTime
1516

17+
from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
1618
from airbyte_cdk.sources.declarative.decoders.json_decoder import JsonDecoder
1719
from airbyte_cdk.sources.declarative.exceptions import ReadException
1820
from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
21+
from airbyte_cdk.sources.declarative.requesters.requester import Requester
1922
from airbyte_cdk.sources.http_logger import format_http_message
2023
from airbyte_cdk.sources.message import MessageRepository, NoopMessageRepository
21-
22-
23-
if TYPE_CHECKING:
24-
from isodate import Duration
25-
26-
from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
27-
from airbyte_cdk.sources.declarative.requesters.requester import Requester
28-
from airbyte_cdk.sources.types import Config
24+
from airbyte_cdk.sources.types import Config
2925

3026

3127
class TokenProvider:

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,28 @@
99
import re
1010
from copy import deepcopy
1111
from importlib import metadata
12-
from typing import TYPE_CHECKING, Any
12+
from typing import (
13+
Any,
14+
Dict,
15+
Iterator,
16+
List,
17+
Mapping,
18+
Optional,
19+
Tuple,
20+
Union,
21+
)
1322

1423
import yaml
1524
from jsonschema.exceptions import ValidationError
1625
from jsonschema.validators import validate
1726

27+
from airbyte_cdk.models import (
28+
AirbyteConnectionStatus,
29+
AirbyteMessage,
30+
AirbyteStateMessage,
31+
ConfiguredAirbyteCatalog,
32+
ConnectorSpecification,
33+
)
1834
from airbyte_cdk.sources.declarative.checks.connection_checker import ConnectionChecker
1935
from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
2036
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
@@ -33,28 +49,16 @@
3349
from airbyte_cdk.sources.declarative.parsers.model_to_component_factory import (
3450
ModelToComponentFactory,
3551
)
52+
from airbyte_cdk.sources.message import MessageRepository
53+
from airbyte_cdk.sources.streams.core import Stream
54+
from airbyte_cdk.sources.types import ConnectionDefinition
3655
from airbyte_cdk.sources.utils.slice_logger import (
3756
AlwaysLogSliceLogger,
3857
DebugSliceLogger,
3958
SliceLogger,
4059
)
4160

4261

43-
if TYPE_CHECKING:
44-
from collections.abc import Iterator, Mapping
45-
46-
from airbyte_cdk.models import (
47-
AirbyteConnectionStatus,
48-
AirbyteMessage,
49-
AirbyteStateMessage,
50-
ConfiguredAirbyteCatalog,
51-
ConnectorSpecification,
52-
)
53-
from airbyte_cdk.sources.message import MessageRepository
54-
from airbyte_cdk.sources.streams.core import Stream
55-
from airbyte_cdk.sources.types import ConnectionDefinition
56-
57-
5862
class ManifestDeclarativeSource(DeclarativeSource):
5963
"""Declarative source defined by a manifest of low-code components that define source connector behavior"""
6064

airbyte_cdk/sources/declarative/yaml_declarative_source.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from __future__ import annotations
55

66
import pkgutil
7+
from collections.abc import Mapping
78
from typing import TYPE_CHECKING, Any
89

910
import yaml
@@ -12,12 +13,7 @@
1213
from airbyte_cdk.sources.declarative.concurrent_declarative_source import (
1314
ConcurrentDeclarativeSource,
1415
)
15-
16-
17-
if TYPE_CHECKING:
18-
from collections.abc import Mapping
19-
20-
from airbyte_cdk.sources.types import ConnectionDefinition
16+
from airbyte_cdk.sources.types import ConnectionDefinition
2117

2218

2319
class YamlDeclarativeSource(ConcurrentDeclarativeSource[list[AirbyteStateMessage]]):

airbyte_cdk/sources/embedded/base_integration.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from __future__ import annotations
55

66
from abc import ABC, abstractmethod
7+
from collections.abc import Iterable
78
from typing import TYPE_CHECKING, Generic, TypeVar
89

910
from airbyte_cdk.connector import TConfig
@@ -13,16 +14,11 @@
1314
get_stream,
1415
get_stream_names,
1516
)
17+
from airbyte_cdk.sources.embedded.runner import SourceRunner
1618
from airbyte_cdk.sources.embedded.tools import get_defined_id
1719
from airbyte_cdk.sources.utils.schema_helpers import check_config_against_spec_or_exit
1820

1921

20-
if TYPE_CHECKING:
21-
from collections.abc import Iterable
22-
23-
from airbyte_cdk.sources.embedded.runner import SourceRunner
24-
25-
2622
TOutput = TypeVar("TOutput")
2723

2824

unit_tests/connector_builder/test_connector_builder_handler.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import copy
77
import dataclasses
88
import json
9+
import logging
910
import os
1011
from pathlib import Path
1112
from typing import TYPE_CHECKING, Any, Literal
@@ -66,9 +67,6 @@
6667

6768

6869
if TYPE_CHECKING:
69-
import logging
70-
from pathlib import Path
71-
7270
from airbyte_cdk.sources.streams.core import Stream
7371

7472

0 commit comments

Comments
 (0)