From 5f0831e0abe24eb4e00c2ec5756a1183775aef6a Mon Sep 17 00:00:00 2001 From: Artem Inzhyyants <36314070+artem1205@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:47:46 +0100 Subject: [PATCH] feat: add sorting import option for `ruff` (#94) Signed-off-by: Artem Inzhyyants Co-authored-by: octavia-squidington-iii --- .../cli/source_declarative_manifest/_run.py | 3 ++- airbyte_cdk/config_observation.py | 3 ++- airbyte_cdk/connector.py | 1 + .../connector_builder_handler.py | 2 +- airbyte_cdk/connector_builder/main.py | 3 ++- airbyte_cdk/destinations/destination.py | 3 ++- .../destinations/vector_db_based/config.py | 3 ++- .../vector_db_based/document_processor.py | 7 ++++--- .../destinations/vector_db_based/embedder.py | 9 +++++---- airbyte_cdk/entrypoint.py | 5 +++-- airbyte_cdk/logger.py | 3 ++- airbyte_cdk/models/airbyte_protocol.py | 3 ++- airbyte_cdk/sources/config.py | 3 ++- airbyte_cdk/sources/declarative/auth/jwt.py | 1 + airbyte_cdk/sources/declarative/auth/oauth.py | 1 + .../declarative/auth/selective_authenticator.py | 1 + airbyte_cdk/sources/declarative/auth/token.py | 3 ++- .../sources/declarative/auth/token_provider.py | 5 +++-- .../concurrent_declarative_source.py | 10 ++++++---- .../declarative/decoders/json_decoder.py | 5 +++-- .../declarative/decoders/noop_decoder.py | 1 + .../decoders/pagination_decoder_decorator.py | 1 + .../sources/declarative/decoders/xml_decoder.py | 1 + .../declarative/extractors/dpath_extractor.py | 1 + .../declarative/extractors/http_selector.py | 1 + .../declarative/extractors/record_selector.py | 1 + .../extractors/response_to_file_extractor.py | 3 ++- .../incremental/datetime_based_cursor.py | 3 ++- .../sources/declarative/interpolation/jinja.py | 9 +++++---- .../declarative/manifest_declarative_source.py | 7 ++++--- .../legacy_to_per_partition_state_migration.py | 2 +- .../parsers/model_to_component_factory.py | 5 +++-- .../substream_partition_router.py | 1 + .../constant_backoff_strategy.py | 1 + .../exponential_backoff_strategy.py | 1 + .../wait_time_from_header_backoff_strategy.py | 1 + ...t_until_time_from_header_backoff_strategy.py | 1 + .../error_handlers/composite_error_handler.py | 1 + .../error_handlers/default_error_handler.py | 1 + .../default_http_response_filter.py | 1 + .../error_handlers/http_response_filter.py | 1 + .../requesters/http_job_repository.py | 3 ++- .../declarative/requesters/http_requester.py | 1 + .../requesters/paginators/default_paginator.py | 1 + .../requesters/paginators/no_pagination.py | 1 + .../requesters/paginators/paginator.py | 1 + .../strategies/cursor_pagination_strategy.py | 1 + .../paginators/strategies/offset_increment.py | 1 + .../paginators/strategies/page_increment.py | 1 + .../strategies/pagination_strategy.py | 1 + .../paginators/strategies/stop_condition.py | 1 + .../interpolated_request_options_provider.py | 3 ++- .../sources/declarative/requesters/requester.py | 1 + .../declarative/retrievers/async_retriever.py | 3 ++- .../declarative/retrievers/simple_retriever.py | 1 + .../declarative_partition_generator.py | 2 +- .../declarative/transformations/add_fields.py | 1 + .../transformations/remove_fields.py | 1 + .../declarative/yaml_declarative_source.py | 1 + airbyte_cdk/sources/embedded/tools.py | 1 + .../config/abstract_file_based_spec.py | 3 ++- .../sources/file_based/config/avro_format.py | 3 ++- .../sources/file_based/config/csv_format.py | 3 ++- .../sources/file_based/config/excel_format.py | 3 ++- .../config/file_based_stream_config.py | 3 ++- .../sources/file_based/config/jsonl_format.py | 3 ++- .../sources/file_based/config/parquet_format.py | 3 ++- .../file_based/config/unstructured_format.py | 3 ++- .../sources/file_based/file_based_source.py | 3 ++- .../file_based/file_based_stream_reader.py | 3 ++- .../file_based/file_types/avro_parser.py | 1 + .../sources/file_based/file_types/csv_parser.py | 3 ++- .../file_based/file_types/excel_parser.py | 10 +++++----- .../file_based/file_types/jsonl_parser.py | 3 ++- .../file_based/file_types/parquet_parser.py | 3 ++- .../file_types/unstructured_parser.py | 17 +++++++++-------- .../stream/abstract_file_based_stream.py | 3 ++- .../file_based/stream/concurrent/adapters.py | 3 ++- airbyte_cdk/sources/http_logger.py | 1 + airbyte_cdk/sources/streams/call_rate.py | 3 +-- .../streams/concurrent/abstract_stream.py | 3 ++- .../sources/streams/concurrent/adapters.py | 4 ++-- .../streams/concurrent/availability_strategy.py | 3 ++- .../datetime_stream_state_converter.py | 2 +- airbyte_cdk/sources/streams/core.py | 3 ++- .../error_handlers/default_error_mapping.py | 3 ++- .../error_handlers/http_status_error_handler.py | 1 + .../error_handlers/json_error_message_parser.py | 1 + .../http/error_handlers/response_models.py | 3 ++- airbyte_cdk/sources/streams/http/http.py | 5 +++-- airbyte_cdk/sources/streams/http/http_client.py | 3 ++- .../http/requests_native_auth/abstract_oauth.py | 3 ++- .../streams/http/requests_native_auth/oauth.py | 1 + airbyte_cdk/sources/utils/schema_helpers.py | 5 +++-- airbyte_cdk/sql/secrets.py | 3 ++- airbyte_cdk/sql/shared/sql_processor.py | 14 ++++++++------ airbyte_cdk/test/entrypoint_wrapper.py | 7 ++++--- airbyte_cdk/test/mock_http/mocker.py | 1 + airbyte_cdk/utils/schema_inferrer.py | 3 ++- airbyte_cdk/utils/slice_hasher.py | 2 +- airbyte_cdk/utils/traced_exception.py | 3 ++- pyproject.toml | 3 +++ .../test_connector_builder_handler.py | 5 +++-- .../connector_builder/test_message_grouper.py | 3 ++- unit_tests/destinations/test_destination.py | 3 ++- .../destinations/vector_db_based/config_test.py | 3 ++- .../vector_db_based/document_processor_test.py | 1 + .../vector_db_based/embedder_test.py | 1 + .../destinations/vector_db_based/writer_test.py | 1 + .../source_declarative_manifest/conftest.py | 3 ++- .../test_source_declarative_local_manifest.py | 1 + .../test_source_declarative_remote_manifest.py | 3 ++- .../test_concurrent_source_adapter.py | 1 + unit_tests/sources/conftest.py | 1 + .../async_job/test_job_orchestrator.py | 1 + .../declarative/async_job/test_job_tracker.py | 1 + unit_tests/sources/declarative/auth/test_jwt.py | 1 + .../sources/declarative/auth/test_oauth.py | 3 ++- .../auth/test_selective_authenticator.py | 1 + .../declarative/auth/test_session_token_auth.py | 3 ++- .../sources/declarative/auth/test_token_auth.py | 3 ++- .../declarative/auth/test_token_provider.py | 3 ++- .../declarative/checks/test_check_stream.py | 1 + .../concurrency_level/test_concurrency_level.py | 1 + .../datetime/test_datetime_parser.py | 1 + .../datetime/test_min_max_datetime.py | 1 + .../declarative/decoders/test_json_decoder.py | 3 ++- .../test_pagination_decoder_decorator.py | 1 + .../declarative/decoders/test_xml_decoder.py | 1 + .../extractors/test_dpath_extractor.py | 1 + .../extractors/test_record_filter.py | 1 + .../extractors/test_record_selector.py | 1 + .../test_response_to_file_extractor.py | 1 + .../incremental/test_datetime_based_cursor.py | 1 + .../incremental/test_per_partition_cursor.py | 1 + .../test_per_partition_cursor_integration.py | 3 ++- .../test_resumable_full_refresh_cursor.py | 1 + .../declarative/interpolation/test_filters.py | 1 + .../interpolation/test_interpolated_boolean.py | 1 + .../interpolation/test_interpolated_mapping.py | 1 + .../test_interpolated_nested_mapping.py | 1 + .../interpolation/test_interpolated_string.py | 1 + .../declarative/interpolation/test_jinja.py | 5 +++-- .../declarative/interpolation/test_macros.py | 1 + .../test_legacy_to_per_partition_migration.py | 9 ++++----- .../test_manifest_component_transformer.py | 1 + .../parsers/test_manifest_reference_resolver.py | 1 + .../parsers/test_model_to_component_factory.py | 1 + .../test_cartesian_product_partition_router.py | 1 + .../test_list_partition_router.py | 1 + .../test_parent_state_stream.py | 3 ++- .../test_substream_partition_router.py | 1 + .../backoff_strategies/test_constant_backoff.py | 1 + .../test_exponential_backoff.py | 1 + .../backoff_strategies/test_header_helper.py | 1 + .../test_wait_time_from_header.py | 3 ++- .../test_wait_until_time_from_header.py | 1 + .../test_composite_error_handler.py | 1 + .../test_default_error_handler.py | 1 + .../test_default_http_response_filter.py | 3 ++- .../error_handlers/test_http_response_filter.py | 1 + .../test_cursor_pagination_strategy.py | 1 + .../paginators/test_default_paginator.py | 1 + .../requesters/paginators/test_no_paginator.py | 1 + .../paginators/test_offset_increment.py | 1 + .../paginators/test_page_increment.py | 1 + .../paginators/test_request_option.py | 1 + .../paginators/test_stop_condition.py | 3 ++- ...t_datetime_based_request_options_provider.py | 1 + ...est_interpolated_request_options_provider.py | 1 + .../requesters/test_http_job_repository.py | 1 + .../requesters/test_http_requester.py | 3 ++- .../test_interpolated_request_input_provider.py | 1 + .../retrievers/test_simple_retriever.py | 1 + .../schema/test_default_schema_loader.py | 1 + .../schema/test_inline_schema_loader.py | 1 + .../schema/test_json_file_schema_loader.py | 1 + .../sources/declarative/spec/test_spec.py | 1 + .../test_concurrent_declarative_source.py | 3 ++- .../declarative/test_declarative_stream.py | 1 + .../test_manifest_declarative_source.py | 3 ++- unit_tests/sources/declarative/test_types.py | 1 + .../declarative/test_yaml_declarative_source.py | 3 ++- .../transformations/test_add_fields.py | 1 + .../transformations/test_remove_fields.py | 1 + .../config/test_abstract_file_based_spec.py | 5 +++-- .../file_based/config/test_csv_format.py | 3 ++- .../config/test_file_based_stream_config.py | 3 ++- .../file_based/file_types/test_avro_parser.py | 1 + .../file_based/file_types/test_csv_parser.py | 1 + .../file_based/file_types/test_excel_parser.py | 1 + .../file_based/file_types/test_jsonl_parser.py | 1 + .../file_types/test_parquet_parser.py | 3 ++- .../file_types/test_unstructured_parser.py | 5 +++-- .../file_based/in_memory_files_source.py | 5 +++-- .../file_based/scenarios/parquet_scenarios.py | 1 + .../scenarios/unstructured_scenarios.py | 1 + .../test_default_schema_validation_policy.py | 1 + .../stream/concurrent/test_adapters.py | 3 ++- .../test_file_based_concurrent_cursor.py | 3 ++- .../stream/test_default_file_based_cursor.py | 3 ++- .../stream/test_default_file_based_stream.py | 1 + .../file_based/test_file_based_scenarios.py | 3 ++- .../file_based/test_file_based_stream_reader.py | 3 ++- unit_tests/sources/file_based/test_scenarios.py | 1 + .../sources/file_based/test_schema_helpers.py | 1 + .../sources/fixtures/source_test_fixture.py | 3 ++- unit_tests/sources/message/test_repository.py | 1 + .../mock_server_tests/mock_source_fixture.py | 3 ++- .../test_helpers/airbyte_message_assertions.py | 1 + .../test_mock_server_abstract_source.py | 1 + .../test_resumable_full_refresh.py | 1 + .../checkpoint/test_checkpoint_reader.py | 1 + ...t_substream_resumable_full_refresh_cursor.py | 1 + .../scenarios/test_concurrent_scenarios.py | 1 + .../sources/streams/concurrent/test_adapters.py | 1 + .../test_concurrent_read_processor.py | 5 ++++- .../sources/streams/concurrent/test_cursor.py | 2 +- .../concurrent/test_datetime_state_converter.py | 1 + .../streams/concurrent/test_partition_reader.py | 1 + .../test_default_backoff_strategy.py | 1 + .../test_http_status_error_handler.py | 1 + .../test_json_error_message_parser.py | 1 + .../http/error_handlers/test_response_models.py | 1 + .../test_requests_native_auth.py | 5 +++-- .../streams/http/test_availability_strategy.py | 1 + unit_tests/sources/streams/http/test_http.py | 1 + .../sources/streams/http/test_http_client.py | 3 ++- unit_tests/sources/streams/test_call_rate.py | 3 ++- unit_tests/sources/streams/test_stream_read.py | 1 + unit_tests/sources/streams/test_streams_core.py | 1 + .../sources/streams/utils/test_stream_helper.py | 1 + unit_tests/sources/test_abstract_source.py | 5 +++-- unit_tests/sources/test_config.py | 3 ++- .../sources/test_connector_state_manager.py | 1 + unit_tests/sources/test_http_logger.py | 1 + unit_tests/sources/test_integration_source.py | 1 + unit_tests/sources/test_source.py | 5 +++-- unit_tests/sources/test_source_read.py | 1 + unit_tests/sources/utils/test_record_helper.py | 1 + unit_tests/sources/utils/test_schema_helpers.py | 5 +++-- unit_tests/sources/utils/test_slice_logger.py | 1 + unit_tests/sources/utils/test_transform.py | 1 + unit_tests/test/mock_http/test_mocker.py | 1 + unit_tests/test/mock_http/test_request.py | 1 + .../test/mock_http/test_response_builder.py | 1 + unit_tests/test/test_entrypoint_wrapper.py | 3 ++- unit_tests/test_config_observation.py | 1 + unit_tests/test_connector.py | 1 + unit_tests/test_entrypoint.py | 3 ++- unit_tests/test_exception_handler.py | 1 + unit_tests/test_logger.py | 1 + unit_tests/test_secure_logger.py | 1 + .../utils/test_datetime_format_inferrer.py | 1 + unit_tests/utils/test_mapping_helpers.py | 1 + unit_tests/utils/test_message_utils.py | 1 + unit_tests/utils/test_rate_limiting.py | 3 ++- unit_tests/utils/test_schema_inferrer.py | 1 + unit_tests/utils/test_secret_utils.py | 1 + unit_tests/utils/test_traced_exception.py | 3 ++- 260 files changed, 415 insertions(+), 161 deletions(-) diff --git a/airbyte_cdk/cli/source_declarative_manifest/_run.py b/airbyte_cdk/cli/source_declarative_manifest/_run.py index ece30309c..ba0517850 100644 --- a/airbyte_cdk/cli/source_declarative_manifest/_run.py +++ b/airbyte_cdk/cli/source_declarative_manifest/_run.py @@ -25,6 +25,8 @@ from pathlib import Path from typing import Any, cast +from orjson import orjson + from airbyte_cdk.entrypoint import AirbyteEntrypoint, launch from airbyte_cdk.models import ( AirbyteErrorTraceMessage, @@ -42,7 +44,6 @@ ) from airbyte_cdk.sources.declarative.yaml_declarative_source import YamlDeclarativeSource from airbyte_cdk.sources.source import TState -from orjson import orjson class SourceLocalYaml(YamlDeclarativeSource): diff --git a/airbyte_cdk/config_observation.py b/airbyte_cdk/config_observation.py index 764174f0a..9a58c0391 100644 --- a/airbyte_cdk/config_observation.py +++ b/airbyte_cdk/config_observation.py @@ -10,6 +10,8 @@ from copy import copy from typing import Any, List, MutableMapping +from orjson import orjson + from airbyte_cdk.models import ( AirbyteControlConnectorConfigMessage, AirbyteControlMessage, @@ -18,7 +20,6 @@ OrchestratorType, Type, ) -from orjson import orjson class ObservedDict(dict): # type: ignore # disallow_any_generics is set to True, and dict is equivalent to dict[Any] diff --git a/airbyte_cdk/connector.py b/airbyte_cdk/connector.py index 29cfc9683..342ecee2d 100644 --- a/airbyte_cdk/connector.py +++ b/airbyte_cdk/connector.py @@ -11,6 +11,7 @@ from typing import Any, Generic, Mapping, Optional, Protocol, TypeVar import yaml + from airbyte_cdk.models import ( AirbyteConnectionStatus, ConnectorSpecification, diff --git a/airbyte_cdk/connector_builder/connector_builder_handler.py b/airbyte_cdk/connector_builder/connector_builder_handler.py index 44d1bfe1c..2c241f6fb 100644 --- a/airbyte_cdk/connector_builder/connector_builder_handler.py +++ b/airbyte_cdk/connector_builder/connector_builder_handler.py @@ -12,8 +12,8 @@ AirbyteRecordMessage, AirbyteStateMessage, ConfiguredAirbyteCatalog, + Type, ) -from airbyte_cdk.models import Type from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource diff --git a/airbyte_cdk/connector_builder/main.py b/airbyte_cdk/connector_builder/main.py index 35ba7e460..5d3dfb68e 100644 --- a/airbyte_cdk/connector_builder/main.py +++ b/airbyte_cdk/connector_builder/main.py @@ -6,6 +6,8 @@ import sys from typing import Any, List, Mapping, Optional, Tuple +from orjson import orjson + from airbyte_cdk.connector import BaseConnector from airbyte_cdk.connector_builder.connector_builder_handler import ( TestReadLimits, @@ -25,7 +27,6 @@ from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource from airbyte_cdk.sources.source import Source from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from orjson import orjson def get_config_and_catalog_from_args( diff --git a/airbyte_cdk/destinations/destination.py b/airbyte_cdk/destinations/destination.py index febf4a1b3..f1d799945 100644 --- a/airbyte_cdk/destinations/destination.py +++ b/airbyte_cdk/destinations/destination.py @@ -9,6 +9,8 @@ from abc import ABC, abstractmethod from typing import Any, Iterable, List, Mapping +from orjson import orjson + from airbyte_cdk.connector import Connector from airbyte_cdk.exception_handler import init_uncaught_exception_handler from airbyte_cdk.models import ( @@ -20,7 +22,6 @@ ) from airbyte_cdk.sources.utils.schema_helpers import check_config_against_spec_or_exit from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from orjson import orjson logger = logging.getLogger("airbyte") diff --git a/airbyte_cdk/destinations/vector_db_based/config.py b/airbyte_cdk/destinations/vector_db_based/config.py index 904f40d3e..c7c40ecaa 100644 --- a/airbyte_cdk/destinations/vector_db_based/config.py +++ b/airbyte_cdk/destinations/vector_db_based/config.py @@ -5,9 +5,10 @@ from typing import Any, Dict, List, Literal, Optional, Union import dpath +from pydantic.v1 import BaseModel, Field + from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig from airbyte_cdk.utils.spec_schema_transformations import resolve_refs -from pydantic.v1 import BaseModel, Field class SeparatorSplitterConfigModel(BaseModel): diff --git a/airbyte_cdk/destinations/vector_db_based/document_processor.py b/airbyte_cdk/destinations/vector_db_based/document_processor.py index 6e1723cb1..c007bf9e2 100644 --- a/airbyte_cdk/destinations/vector_db_based/document_processor.py +++ b/airbyte_cdk/destinations/vector_db_based/document_processor.py @@ -8,6 +8,10 @@ from typing import Any, Dict, List, Mapping, Optional, Tuple import dpath +from langchain.text_splitter import Language, RecursiveCharacterTextSplitter +from langchain.utils import stringify_dict +from langchain_core.documents.base import Document + from airbyte_cdk.destinations.vector_db_based.config import ( ProcessingConfigModel, SeparatorSplitterConfigModel, @@ -21,9 +25,6 @@ DestinationSyncMode, ) from airbyte_cdk.utils.traced_exception import AirbyteTracedException, FailureType -from langchain.text_splitter import Language, RecursiveCharacterTextSplitter -from langchain.utils import stringify_dict -from langchain_core.documents.base import Document METADATA_STREAM_FIELD = "_ab_stream" METADATA_RECORD_ID_FIELD = "_ab_record_id" diff --git a/airbyte_cdk/destinations/vector_db_based/embedder.py b/airbyte_cdk/destinations/vector_db_based/embedder.py index 4ec56fbf2..a7610aea4 100644 --- a/airbyte_cdk/destinations/vector_db_based/embedder.py +++ b/airbyte_cdk/destinations/vector_db_based/embedder.py @@ -7,6 +7,11 @@ from dataclasses import dataclass from typing import List, Optional, Union, cast +from langchain.embeddings.cohere import CohereEmbeddings +from langchain.embeddings.fake import FakeEmbeddings +from langchain.embeddings.localai import LocalAIEmbeddings +from langchain.embeddings.openai import OpenAIEmbeddings + from airbyte_cdk.destinations.vector_db_based.config import ( AzureOpenAIEmbeddingConfigModel, CohereEmbeddingConfigModel, @@ -19,10 +24,6 @@ from airbyte_cdk.destinations.vector_db_based.utils import create_chunks, format_exception from airbyte_cdk.models import AirbyteRecordMessage from airbyte_cdk.utils.traced_exception import AirbyteTracedException, FailureType -from langchain.embeddings.cohere import CohereEmbeddings -from langchain.embeddings.fake import FakeEmbeddings -from langchain.embeddings.localai import LocalAIEmbeddings -from langchain.embeddings.openai import OpenAIEmbeddings @dataclass diff --git a/airbyte_cdk/entrypoint.py b/airbyte_cdk/entrypoint.py index 5a979a949..9de9e60a8 100644 --- a/airbyte_cdk/entrypoint.py +++ b/airbyte_cdk/entrypoint.py @@ -16,6 +16,9 @@ from urllib.parse import urlparse import requests +from orjson import orjson +from requests import PreparedRequest, Response, Session + from airbyte_cdk.connector import TConfig from airbyte_cdk.exception_handler import init_uncaught_exception_handler from airbyte_cdk.logger import init_logger @@ -38,8 +41,6 @@ from airbyte_cdk.utils.airbyte_secrets_utils import get_secrets, update_secrets from airbyte_cdk.utils.constants import ENV_REQUEST_CACHE_PATH from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from orjson import orjson -from requests import PreparedRequest, Response, Session logger = init_logger("airbyte") diff --git a/airbyte_cdk/logger.py b/airbyte_cdk/logger.py index 055d80e84..8b7f288b3 100644 --- a/airbyte_cdk/logger.py +++ b/airbyte_cdk/logger.py @@ -7,6 +7,8 @@ import logging.config from typing import Any, Callable, Mapping, Optional, Tuple +from orjson import orjson + from airbyte_cdk.models import ( AirbyteLogMessage, AirbyteMessage, @@ -15,7 +17,6 @@ Type, ) from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets -from orjson import orjson LOGGING_CONFIG = { "version": 1, diff --git a/airbyte_cdk/models/airbyte_protocol.py b/airbyte_cdk/models/airbyte_protocol.py index 6be79948e..2528f7d7e 100644 --- a/airbyte_cdk/models/airbyte_protocol.py +++ b/airbyte_cdk/models/airbyte_protocol.py @@ -5,10 +5,11 @@ from dataclasses import InitVar, dataclass from typing import Annotated, Any, Dict, List, Mapping, Optional, Union -from airbyte_cdk.models.file_transfer_record_message import AirbyteFileTransferRecordMessage from airbyte_protocol_dataclasses.models import * # noqa: F403 # Allow '*' from serpyco_rs.metadata import Alias +from airbyte_cdk.models.file_transfer_record_message import AirbyteFileTransferRecordMessage + # ruff: noqa: F405 # ignore fuzzy import issues with 'import *' diff --git a/airbyte_cdk/sources/config.py b/airbyte_cdk/sources/config.py index 8ea2b6400..8679ebbb7 100644 --- a/airbyte_cdk/sources/config.py +++ b/airbyte_cdk/sources/config.py @@ -4,9 +4,10 @@ from typing import Any, Dict -from airbyte_cdk.sources.utils.schema_helpers import expand_refs, rename_key from pydantic.v1 import BaseModel +from airbyte_cdk.sources.utils.schema_helpers import expand_refs, rename_key + class BaseConfig(BaseModel): """Base class for connector spec, adds the following behaviour: diff --git a/airbyte_cdk/sources/declarative/auth/jwt.py b/airbyte_cdk/sources/declarative/auth/jwt.py index 4095635d0..d7dd59282 100644 --- a/airbyte_cdk/sources/declarative/auth/jwt.py +++ b/airbyte_cdk/sources/declarative/auth/jwt.py @@ -8,6 +8,7 @@ from typing import Any, Mapping, Optional, Union import jwt + from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import InterpolatedMapping diff --git a/airbyte_cdk/sources/declarative/auth/oauth.py b/airbyte_cdk/sources/declarative/auth/oauth.py index 773d2818f..18bcc9fce 100644 --- a/airbyte_cdk/sources/declarative/auth/oauth.py +++ b/airbyte_cdk/sources/declarative/auth/oauth.py @@ -6,6 +6,7 @@ from typing import Any, List, Mapping, Optional, Union import pendulum + from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import InterpolatedMapping from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString diff --git a/airbyte_cdk/sources/declarative/auth/selective_authenticator.py b/airbyte_cdk/sources/declarative/auth/selective_authenticator.py index 11a2ae7dc..9f8a55193 100644 --- a/airbyte_cdk/sources/declarative/auth/selective_authenticator.py +++ b/airbyte_cdk/sources/declarative/auth/selective_authenticator.py @@ -6,6 +6,7 @@ from typing import Any, List, Mapping import dpath + from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator diff --git a/airbyte_cdk/sources/declarative/auth/token.py b/airbyte_cdk/sources/declarative/auth/token.py index dc35eb45e..12fb899b9 100644 --- a/airbyte_cdk/sources/declarative/auth/token.py +++ b/airbyte_cdk/sources/declarative/auth/token.py @@ -8,6 +8,8 @@ from typing import Any, Mapping, Union import requests +from cachetools import TTLCache, cached + from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator from airbyte_cdk.sources.declarative.auth.token_provider import TokenProvider from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString @@ -16,7 +18,6 @@ RequestOptionType, ) from airbyte_cdk.sources.types import Config -from cachetools import TTLCache, cached @dataclass diff --git a/airbyte_cdk/sources/declarative/auth/token_provider.py b/airbyte_cdk/sources/declarative/auth/token_provider.py index c3c2a41f5..ed933bc59 100644 --- a/airbyte_cdk/sources/declarative/auth/token_provider.py +++ b/airbyte_cdk/sources/declarative/auth/token_provider.py @@ -10,6 +10,9 @@ import dpath import pendulum +from isodate import Duration +from pendulum import DateTime + from airbyte_cdk.sources.declarative.decoders.decoder import Decoder from airbyte_cdk.sources.declarative.decoders.json_decoder import JsonDecoder from airbyte_cdk.sources.declarative.exceptions import ReadException @@ -18,8 +21,6 @@ from airbyte_cdk.sources.http_logger import format_http_message from airbyte_cdk.sources.message import MessageRepository, NoopMessageRepository from airbyte_cdk.sources.types import Config -from isodate import Duration -from pendulum import DateTime class TokenProvider: diff --git a/airbyte_cdk/sources/declarative/concurrent_declarative_source.py b/airbyte_cdk/sources/declarative/concurrent_declarative_source.py index 001740a35..b9405a8e0 100644 --- a/airbyte_cdk/sources/declarative/concurrent_declarative_source.py +++ b/airbyte_cdk/sources/declarative/concurrent_declarative_source.py @@ -3,7 +3,7 @@ # import logging -from typing import Any, Generic, Iterator, List, Mapping, Optional, Tuple, Union, Callable +from typing import Any, Callable, Generic, Iterator, List, Mapping, Optional, Tuple, Union from airbyte_cdk.models import ( AirbyteCatalog, @@ -27,14 +27,16 @@ ) from airbyte_cdk.sources.declarative.models.declarative_component_schema import ( DatetimeBasedCursor as DatetimeBasedCursorModel, +) +from airbyte_cdk.sources.declarative.models.declarative_component_schema import ( DeclarativeStream as DeclarativeStreamModel, ) from airbyte_cdk.sources.declarative.parsers.model_to_component_factory import ( - ModelToComponentFactory, ComponentDefinition, + ModelToComponentFactory, ) from airbyte_cdk.sources.declarative.requesters import HttpRequester -from airbyte_cdk.sources.declarative.retrievers import SimpleRetriever, Retriever +from airbyte_cdk.sources.declarative.retrievers import Retriever, SimpleRetriever from airbyte_cdk.sources.declarative.stream_slicers.declarative_partition_generator import ( DeclarativePartitionFactory, StreamSlicerPartitionGenerator, @@ -42,7 +44,6 @@ from airbyte_cdk.sources.declarative.transformations.add_fields import AddFields from airbyte_cdk.sources.declarative.types import ConnectionDefinition from airbyte_cdk.sources.source import TState -from airbyte_cdk.sources.types import Config, StreamState from airbyte_cdk.sources.streams import Stream from airbyte_cdk.sources.streams.concurrent.abstract_stream import AbstractStream from airbyte_cdk.sources.streams.concurrent.availability_strategy import ( @@ -50,6 +51,7 @@ ) from airbyte_cdk.sources.streams.concurrent.default_stream import DefaultStream from airbyte_cdk.sources.streams.concurrent.helpers import get_primary_key_from_stream +from airbyte_cdk.sources.types import Config, StreamState class ConcurrentDeclarativeSource(ManifestDeclarativeSource, Generic[TState]): diff --git a/airbyte_cdk/sources/declarative/decoders/json_decoder.py b/airbyte_cdk/sources/declarative/decoders/json_decoder.py index d04504afb..cab572ef4 100644 --- a/airbyte_cdk/sources/declarative/decoders/json_decoder.py +++ b/airbyte_cdk/sources/declarative/decoders/json_decoder.py @@ -5,11 +5,12 @@ import logging from dataclasses import InitVar, dataclass from gzip import decompress -from typing import Any, Generator, Mapping, MutableMapping, List, Optional +from typing import Any, Generator, List, Mapping, MutableMapping, Optional +import orjson import requests + from airbyte_cdk.sources.declarative.decoders.decoder import Decoder -import orjson logger = logging.getLogger("airbyte") diff --git a/airbyte_cdk/sources/declarative/decoders/noop_decoder.py b/airbyte_cdk/sources/declarative/decoders/noop_decoder.py index eb977712a..13281026d 100644 --- a/airbyte_cdk/sources/declarative/decoders/noop_decoder.py +++ b/airbyte_cdk/sources/declarative/decoders/noop_decoder.py @@ -4,6 +4,7 @@ from typing import Any, Generator, Mapping import requests + from airbyte_cdk.sources.declarative.decoders.decoder import Decoder logger = logging.getLogger("airbyte") diff --git a/airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py b/airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py index fa37607b4..e5a152711 100644 --- a/airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py +++ b/airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py @@ -7,6 +7,7 @@ from typing import Any, Generator, MutableMapping import requests + from airbyte_cdk.sources.declarative.decoders import Decoder logger = logging.getLogger("airbyte") diff --git a/airbyte_cdk/sources/declarative/decoders/xml_decoder.py b/airbyte_cdk/sources/declarative/decoders/xml_decoder.py index 6fb0477ec..0786c3202 100644 --- a/airbyte_cdk/sources/declarative/decoders/xml_decoder.py +++ b/airbyte_cdk/sources/declarative/decoders/xml_decoder.py @@ -9,6 +9,7 @@ import requests import xmltodict + from airbyte_cdk.sources.declarative.decoders.decoder import Decoder logger = logging.getLogger("airbyte") diff --git a/airbyte_cdk/sources/declarative/extractors/dpath_extractor.py b/airbyte_cdk/sources/declarative/extractors/dpath_extractor.py index 0878c31af..9c97773e3 100644 --- a/airbyte_cdk/sources/declarative/extractors/dpath_extractor.py +++ b/airbyte_cdk/sources/declarative/extractors/dpath_extractor.py @@ -7,6 +7,7 @@ import dpath import requests + from airbyte_cdk.sources.declarative.decoders import Decoder, JsonDecoder from airbyte_cdk.sources.declarative.extractors.record_extractor import RecordExtractor from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString diff --git a/airbyte_cdk/sources/declarative/extractors/http_selector.py b/airbyte_cdk/sources/declarative/extractors/http_selector.py index 905477a6c..846071125 100644 --- a/airbyte_cdk/sources/declarative/extractors/http_selector.py +++ b/airbyte_cdk/sources/declarative/extractors/http_selector.py @@ -6,6 +6,7 @@ from typing import Any, Iterable, Mapping, Optional import requests + from airbyte_cdk.sources.types import Record, StreamSlice, StreamState diff --git a/airbyte_cdk/sources/declarative/extractors/record_selector.py b/airbyte_cdk/sources/declarative/extractors/record_selector.py index caaa4be23..7d4fee671 100644 --- a/airbyte_cdk/sources/declarative/extractors/record_selector.py +++ b/airbyte_cdk/sources/declarative/extractors/record_selector.py @@ -6,6 +6,7 @@ from typing import Any, Iterable, List, Mapping, Optional import requests + from airbyte_cdk.sources.declarative.extractors.http_selector import HttpSelector from airbyte_cdk.sources.declarative.extractors.record_extractor import RecordExtractor from airbyte_cdk.sources.declarative.extractors.record_filter import RecordFilter diff --git a/airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py b/airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py index 8be2f6b65..44bf45d6a 100644 --- a/airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py +++ b/airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py @@ -10,9 +10,10 @@ import pandas as pd import requests -from airbyte_cdk.sources.declarative.extractors.record_extractor import RecordExtractor from numpy import nan +from airbyte_cdk.sources.declarative.extractors.record_extractor import RecordExtractor + EMPTY_STR: str = "" DEFAULT_ENCODING: str = "utf-8" DOWNLOAD_CHUNK_SIZE: int = 1024 * 10 diff --git a/airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py b/airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py index 3977623db..03998c479 100644 --- a/airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py +++ b/airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py @@ -7,6 +7,8 @@ from datetime import timedelta from typing import Any, Callable, Iterable, List, Mapping, MutableMapping, Optional, Union +from isodate import Duration, duration_isoformat, parse_duration + from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Level, Type from airbyte_cdk.sources.declarative.datetime.datetime_parser import DatetimeParser from airbyte_cdk.sources.declarative.datetime.min_max_datetime import MinMaxDatetime @@ -19,7 +21,6 @@ ) from airbyte_cdk.sources.message import MessageRepository from airbyte_cdk.sources.types import Config, Record, StreamSlice, StreamState -from isodate import Duration, duration_isoformat, parse_duration @dataclass diff --git a/airbyte_cdk/sources/declarative/interpolation/jinja.py b/airbyte_cdk/sources/declarative/interpolation/jinja.py index 553ef0244..ecbe9a349 100644 --- a/airbyte_cdk/sources/declarative/interpolation/jinja.py +++ b/airbyte_cdk/sources/declarative/interpolation/jinja.py @@ -6,15 +6,16 @@ from functools import cache from typing import Any, Mapping, Optional, Tuple, Type -from airbyte_cdk.sources.declarative.interpolation.filters import filters -from airbyte_cdk.sources.declarative.interpolation.interpolation import Interpolation -from airbyte_cdk.sources.declarative.interpolation.macros import macros -from airbyte_cdk.sources.types import Config from jinja2 import meta from jinja2.environment import Template from jinja2.exceptions import UndefinedError from jinja2.sandbox import SandboxedEnvironment +from airbyte_cdk.sources.declarative.interpolation.filters import filters +from airbyte_cdk.sources.declarative.interpolation.interpolation import Interpolation +from airbyte_cdk.sources.declarative.interpolation.macros import macros +from airbyte_cdk.sources.types import Config + class StreamPartitionAccessEnvironment(SandboxedEnvironment): """ diff --git a/airbyte_cdk/sources/declarative/manifest_declarative_source.py b/airbyte_cdk/sources/declarative/manifest_declarative_source.py index 223cbc0b6..5346c2bcb 100644 --- a/airbyte_cdk/sources/declarative/manifest_declarative_source.py +++ b/airbyte_cdk/sources/declarative/manifest_declarative_source.py @@ -8,9 +8,12 @@ from copy import deepcopy from importlib import metadata from typing import Any, Dict, Iterator, List, Mapping, Optional -from packaging.version import Version, InvalidVersion import yaml +from jsonschema.exceptions import ValidationError +from jsonschema.validators import validate +from packaging.version import InvalidVersion, Version + from airbyte_cdk.models import ( AirbyteConnectionStatus, AirbyteMessage, @@ -44,8 +47,6 @@ DebugSliceLogger, SliceLogger, ) -from jsonschema.exceptions import ValidationError -from jsonschema.validators import validate class ManifestDeclarativeSource(DeclarativeSource): diff --git a/airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py b/airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py index 8000b1876..830646fe9 100644 --- a/airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py +++ b/airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py @@ -5,9 +5,9 @@ from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString from airbyte_cdk.sources.declarative.migrations.state_migration import StateMigration from airbyte_cdk.sources.declarative.models import ( + CustomIncrementalSync, DatetimeBasedCursor, SubstreamPartitionRouter, - CustomIncrementalSync, ) from airbyte_cdk.sources.declarative.models.declarative_component_schema import ParentStreamConfig diff --git a/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py b/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py index d2dd9d9dc..854515c28 100644 --- a/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +++ b/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py @@ -25,6 +25,9 @@ get_type_hints, ) +from isodate import parse_duration +from pydantic.v1 import BaseModel + from airbyte_cdk.models import FailureType, Level from airbyte_cdk.sources.connector_state_manager import ConnectorStateManager from airbyte_cdk.sources.declarative.async_job.job_orchestrator import AsyncJobOrchestrator @@ -367,8 +370,6 @@ from airbyte_cdk.sources.streams.http.error_handlers.response_models import ResponseAction from airbyte_cdk.sources.types import Config from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer -from isodate import parse_duration -from pydantic.v1 import BaseModel ComponentDefinition = Mapping[str, Any] diff --git a/airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py b/airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py index 4c761d089..28925ae6a 100644 --- a/airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py +++ b/airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py @@ -7,6 +7,7 @@ from typing import TYPE_CHECKING, Any, Iterable, List, Mapping, Optional, Union import dpath + from airbyte_cdk.models import AirbyteMessage from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString diff --git a/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/constant_backoff_strategy.py b/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/constant_backoff_strategy.py index d9213eb97..26c7c7673 100644 --- a/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/constant_backoff_strategy.py +++ b/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/constant_backoff_strategy.py @@ -6,6 +6,7 @@ from typing import Any, Mapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString from airbyte_cdk.sources.streams.http.error_handlers import BackoffStrategy from airbyte_cdk.sources.types import Config diff --git a/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/exponential_backoff_strategy.py b/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/exponential_backoff_strategy.py index b3a57675b..cdd1fe650 100644 --- a/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/exponential_backoff_strategy.py +++ b/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/exponential_backoff_strategy.py @@ -6,6 +6,7 @@ from typing import Any, Mapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString from airbyte_cdk.sources.streams.http.error_handlers import BackoffStrategy from airbyte_cdk.sources.types import Config diff --git a/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_time_from_header_backoff_strategy.py b/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_time_from_header_backoff_strategy.py index 7672bd82c..5cda96a4d 100644 --- a/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_time_from_header_backoff_strategy.py +++ b/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_time_from_header_backoff_strategy.py @@ -7,6 +7,7 @@ from typing import Any, Mapping, Optional, Union import requests + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies.header_helper import ( diff --git a/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_until_time_from_header_backoff_strategy.py b/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_until_time_from_header_backoff_strategy.py index 4aed73383..1220e198f 100644 --- a/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_until_time_from_header_backoff_strategy.py +++ b/airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_until_time_from_header_backoff_strategy.py @@ -9,6 +9,7 @@ from typing import Any, Mapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies.header_helper import ( get_numeric_value_from_header, diff --git a/airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py b/airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py index 717fcba69..fc4219134 100644 --- a/airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py +++ b/airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py @@ -6,6 +6,7 @@ from typing import Any, List, Mapping, Optional, Union import requests + from airbyte_cdk.sources.streams.http.error_handlers import ErrorHandler from airbyte_cdk.sources.streams.http.error_handlers.response_models import ( ErrorResolution, diff --git a/airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py b/airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py index ad4a6261f..1340e8595 100644 --- a/airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py +++ b/airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py @@ -6,6 +6,7 @@ from typing import Any, List, Mapping, MutableMapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.requesters.error_handlers.default_http_response_filter import ( DefaultHttpResponseFilter, ) diff --git a/airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py b/airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py index 395df5c9b..9943a0d6a 100644 --- a/airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py +++ b/airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py @@ -5,6 +5,7 @@ from typing import Optional, Union import requests + from airbyte_cdk.sources.declarative.requesters.error_handlers.http_response_filter import ( HttpResponseFilter, ) diff --git a/airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py b/airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py index 366ad6877..82dfb661b 100644 --- a/airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py +++ b/airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py @@ -6,6 +6,7 @@ from typing import Any, Mapping, Optional, Set, Union import requests + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.declarative.interpolation import InterpolatedString from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean diff --git a/airbyte_cdk/sources/declarative/requesters/http_job_repository.py b/airbyte_cdk/sources/declarative/requesters/http_job_repository.py index ff2130680..034be3771 100644 --- a/airbyte_cdk/sources/declarative/requesters/http_job_repository.py +++ b/airbyte_cdk/sources/declarative/requesters/http_job_repository.py @@ -6,6 +6,8 @@ from typing import Any, Dict, Iterable, Mapping, Optional import requests +from requests import Response + from airbyte_cdk import AirbyteMessage from airbyte_cdk.logger import lazy_log from airbyte_cdk.models import FailureType, Type @@ -23,7 +25,6 @@ from airbyte_cdk.sources.declarative.retrievers.simple_retriever import SimpleRetriever from airbyte_cdk.sources.types import Record, StreamSlice from airbyte_cdk.utils import AirbyteTracedException -from requests import Response LOGGER = logging.getLogger("airbyte") diff --git a/airbyte_cdk/sources/declarative/requesters/http_requester.py b/airbyte_cdk/sources/declarative/requesters/http_requester.py index 51ece9f9a..35d4b0f11 100644 --- a/airbyte_cdk/sources/declarative/requesters/http_requester.py +++ b/airbyte_cdk/sources/declarative/requesters/http_requester.py @@ -9,6 +9,7 @@ from urllib.parse import urljoin import requests + from airbyte_cdk.sources.declarative.auth.declarative_authenticator import ( DeclarativeAuthenticator, NoAuth, diff --git a/airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py b/airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py index e26f32de3..c660f0327 100644 --- a/airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py +++ b/airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py @@ -6,6 +6,7 @@ from typing import Any, Mapping, MutableMapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.decoders import ( Decoder, JsonDecoder, diff --git a/airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py b/airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py index db4eb0ede..cb0592793 100644 --- a/airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py +++ b/airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py @@ -6,6 +6,7 @@ from typing import Any, Mapping, MutableMapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.requesters.paginators.paginator import Paginator from airbyte_cdk.sources.types import Record, StreamSlice, StreamState diff --git a/airbyte_cdk/sources/declarative/requesters/paginators/paginator.py b/airbyte_cdk/sources/declarative/requesters/paginators/paginator.py index 1bf17d1d0..d47124628 100644 --- a/airbyte_cdk/sources/declarative/requesters/paginators/paginator.py +++ b/airbyte_cdk/sources/declarative/requesters/paginators/paginator.py @@ -7,6 +7,7 @@ from typing import Any, Mapping, Optional import requests + from airbyte_cdk.sources.declarative.requesters.request_options.request_options_provider import ( RequestOptionsProvider, ) diff --git a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py index a53a044bb..beebf9e83 100644 --- a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py +++ b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py @@ -6,6 +6,7 @@ from typing import Any, Dict, Mapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.decoders import ( Decoder, JsonDecoder, diff --git a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py index 9f24b961b..37ba3bbfa 100644 --- a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py +++ b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py @@ -6,6 +6,7 @@ from typing import Any, Mapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.decoders import ( Decoder, JsonDecoder, diff --git a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py index 1ce0a1c8a..2227fffec 100644 --- a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py +++ b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py @@ -6,6 +6,7 @@ from typing import Any, Mapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.interpolation import InterpolatedString from airbyte_cdk.sources.declarative.requesters.paginators.strategies.pagination_strategy import ( PaginationStrategy, diff --git a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py index 0b350d332..a55dcb131 100644 --- a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py +++ b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py @@ -7,6 +7,7 @@ from typing import Any, Optional import requests + from airbyte_cdk.sources.types import Record diff --git a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py index 3f322aa93..f6fb14788 100644 --- a/airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py +++ b/airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py @@ -6,6 +6,7 @@ from typing import Any, Optional import requests + from airbyte_cdk.sources.declarative.incremental.declarative_cursor import DeclarativeCursor from airbyte_cdk.sources.declarative.requesters.paginators.strategies.pagination_strategy import ( PaginationStrategy, diff --git a/airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py b/airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py index bd8cfc17c..e8e4ee643 100644 --- a/airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py +++ b/airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py @@ -5,6 +5,8 @@ from dataclasses import InitVar, dataclass, field from typing import Any, Mapping, MutableMapping, Optional, Union +from deprecated import deprecated + from airbyte_cdk.sources.declarative.interpolation.interpolated_nested_mapping import NestedMapping from airbyte_cdk.sources.declarative.requesters.request_options.interpolated_nested_request_input_provider import ( InterpolatedNestedRequestInputProvider, @@ -17,7 +19,6 @@ ) from airbyte_cdk.sources.source import ExperimentalClassWarning from airbyte_cdk.sources.types import Config, StreamSlice, StreamState -from deprecated import deprecated RequestInput = Union[str, Mapping[str, str]] ValidRequestTypes = (str, list) diff --git a/airbyte_cdk/sources/declarative/requesters/requester.py b/airbyte_cdk/sources/declarative/requesters/requester.py index 19003a835..604b2faba 100644 --- a/airbyte_cdk/sources/declarative/requesters/requester.py +++ b/airbyte_cdk/sources/declarative/requesters/requester.py @@ -7,6 +7,7 @@ from typing import Any, Callable, Mapping, MutableMapping, Optional, Union import requests + from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator from airbyte_cdk.sources.declarative.requesters.request_options.request_options_provider import ( RequestOptionsProvider, diff --git a/airbyte_cdk/sources/declarative/retrievers/async_retriever.py b/airbyte_cdk/sources/declarative/retrievers/async_retriever.py index f3902dfcd..5cea85bcb 100644 --- a/airbyte_cdk/sources/declarative/retrievers/async_retriever.py +++ b/airbyte_cdk/sources/declarative/retrievers/async_retriever.py @@ -4,6 +4,8 @@ from dataclasses import InitVar, dataclass, field from typing import Any, Callable, Iterable, Mapping, Optional +from deprecated.classic import deprecated + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.declarative.async_job.job_orchestrator import ( AsyncJobOrchestrator, @@ -17,7 +19,6 @@ from airbyte_cdk.sources.streams.core import StreamData from airbyte_cdk.sources.types import Config, StreamSlice, StreamState from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from deprecated.classic import deprecated @deprecated("This class is experimental. Use at your own risk.", category=ExperimentalClassWarning) diff --git a/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py b/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py index 530cf5f56..23486b88d 100644 --- a/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py +++ b/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py @@ -20,6 +20,7 @@ ) import requests + from airbyte_cdk.models import AirbyteMessage from airbyte_cdk.sources.declarative.extractors.http_selector import HttpSelector from airbyte_cdk.sources.declarative.incremental import ResumableFullRefreshCursor diff --git a/airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py b/airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py index 1c2ad06cf..76df90343 100644 --- a/airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py +++ b/airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py @@ -1,6 +1,6 @@ # Copyright (c) 2024 Airbyte, Inc., all rights reserved. -from typing import Iterable, Optional, Mapping, Any, Callable +from typing import Any, Callable, Iterable, Mapping, Optional from airbyte_cdk.sources.declarative.retrievers import Retriever from airbyte_cdk.sources.message import MessageRepository diff --git a/airbyte_cdk/sources/declarative/transformations/add_fields.py b/airbyte_cdk/sources/declarative/transformations/add_fields.py index fa9209932..4c9d5366c 100644 --- a/airbyte_cdk/sources/declarative/transformations/add_fields.py +++ b/airbyte_cdk/sources/declarative/transformations/add_fields.py @@ -6,6 +6,7 @@ from typing import Any, Dict, List, Mapping, Optional, Type, Union import dpath + from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString from airbyte_cdk.sources.declarative.transformations import RecordTransformation from airbyte_cdk.sources.types import Config, FieldPointer, StreamSlice, StreamState diff --git a/airbyte_cdk/sources/declarative/transformations/remove_fields.py b/airbyte_cdk/sources/declarative/transformations/remove_fields.py index 8ac20a0d4..f5d8164df 100644 --- a/airbyte_cdk/sources/declarative/transformations/remove_fields.py +++ b/airbyte_cdk/sources/declarative/transformations/remove_fields.py @@ -7,6 +7,7 @@ import dpath import dpath.exceptions + from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean from airbyte_cdk.sources.declarative.transformations import RecordTransformation from airbyte_cdk.sources.types import Config, FieldPointer, StreamSlice, StreamState diff --git a/airbyte_cdk/sources/declarative/yaml_declarative_source.py b/airbyte_cdk/sources/declarative/yaml_declarative_source.py index cecb91a69..04ccda4cf 100644 --- a/airbyte_cdk/sources/declarative/yaml_declarative_source.py +++ b/airbyte_cdk/sources/declarative/yaml_declarative_source.py @@ -6,6 +6,7 @@ from typing import Any, List, Mapping, Optional import yaml + from airbyte_cdk.models import AirbyteStateMessage, ConfiguredAirbyteCatalog from airbyte_cdk.sources.declarative.concurrent_declarative_source import ( ConcurrentDeclarativeSource, diff --git a/airbyte_cdk/sources/embedded/tools.py b/airbyte_cdk/sources/embedded/tools.py index 6bffa1a08..1ddb29b3a 100644 --- a/airbyte_cdk/sources/embedded/tools.py +++ b/airbyte_cdk/sources/embedded/tools.py @@ -5,6 +5,7 @@ from typing import Any, Callable, Dict, Iterable, Optional import dpath + from airbyte_cdk.models import AirbyteStream diff --git a/airbyte_cdk/sources/file_based/config/abstract_file_based_spec.py b/airbyte_cdk/sources/file_based/config/abstract_file_based_spec.py index ee220388d..ffa7d743d 100644 --- a/airbyte_cdk/sources/file_based/config/abstract_file_based_spec.py +++ b/airbyte_cdk/sources/file_based/config/abstract_file_based_spec.py @@ -7,10 +7,11 @@ from typing import Any, Dict, List, Literal, Optional, Union import dpath +from pydantic.v1 import AnyUrl, BaseModel, Field + from airbyte_cdk import OneOfOptionConfig from airbyte_cdk.sources.file_based.config.file_based_stream_config import FileBasedStreamConfig from airbyte_cdk.sources.utils import schema_helpers -from pydantic.v1 import AnyUrl, BaseModel, Field class DeliverRecords(BaseModel): diff --git a/airbyte_cdk/sources/file_based/config/avro_format.py b/airbyte_cdk/sources/file_based/config/avro_format.py index ac8fafef5..fd54349cb 100644 --- a/airbyte_cdk/sources/file_based/config/avro_format.py +++ b/airbyte_cdk/sources/file_based/config/avro_format.py @@ -3,9 +3,10 @@ # -from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig from pydantic.v1 import BaseModel, Field +from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig + class AvroFormat(BaseModel): class Config(OneOfOptionConfig): diff --git a/airbyte_cdk/sources/file_based/config/csv_format.py b/airbyte_cdk/sources/file_based/config/csv_format.py index 83789c45a..1441d8411 100644 --- a/airbyte_cdk/sources/file_based/config/csv_format.py +++ b/airbyte_cdk/sources/file_based/config/csv_format.py @@ -6,10 +6,11 @@ from enum import Enum from typing import Any, Dict, List, Optional, Set, Union -from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig from pydantic.v1 import BaseModel, Field, root_validator, validator from pydantic.v1.error_wrappers import ValidationError +from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig + class InferenceType(Enum): NONE = "None" diff --git a/airbyte_cdk/sources/file_based/config/excel_format.py b/airbyte_cdk/sources/file_based/config/excel_format.py index 02a4f52d2..632a0bc38 100644 --- a/airbyte_cdk/sources/file_based/config/excel_format.py +++ b/airbyte_cdk/sources/file_based/config/excel_format.py @@ -2,9 +2,10 @@ # Copyright (c) 2024 Airbyte, Inc., all rights reserved. # -from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig from pydantic.v1 import BaseModel, Field +from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig + class ExcelFormat(BaseModel): class Config(OneOfOptionConfig): diff --git a/airbyte_cdk/sources/file_based/config/file_based_stream_config.py b/airbyte_cdk/sources/file_based/config/file_based_stream_config.py index 5d92f6f06..eb592a4aa 100644 --- a/airbyte_cdk/sources/file_based/config/file_based_stream_config.py +++ b/airbyte_cdk/sources/file_based/config/file_based_stream_config.py @@ -5,6 +5,8 @@ from enum import Enum from typing import Any, List, Mapping, Optional, Union +from pydantic.v1 import BaseModel, Field, validator + from airbyte_cdk.sources.file_based.config.avro_format import AvroFormat from airbyte_cdk.sources.file_based.config.csv_format import CsvFormat from airbyte_cdk.sources.file_based.config.excel_format import ExcelFormat @@ -13,7 +15,6 @@ from airbyte_cdk.sources.file_based.config.unstructured_format import UnstructuredFormat from airbyte_cdk.sources.file_based.exceptions import ConfigValidationError, FileBasedSourceError from airbyte_cdk.sources.file_based.schema_helpers import type_mapping_to_jsonschema -from pydantic.v1 import BaseModel, Field, validator PrimaryKeyType = Optional[Union[str, List[str]]] diff --git a/airbyte_cdk/sources/file_based/config/jsonl_format.py b/airbyte_cdk/sources/file_based/config/jsonl_format.py index 1d9ed54fe..a913e06ad 100644 --- a/airbyte_cdk/sources/file_based/config/jsonl_format.py +++ b/airbyte_cdk/sources/file_based/config/jsonl_format.py @@ -2,9 +2,10 @@ # Copyright (c) 2023 Airbyte, Inc., all rights reserved. # -from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig from pydantic.v1 import BaseModel, Field +from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig + class JsonlFormat(BaseModel): class Config(OneOfOptionConfig): diff --git a/airbyte_cdk/sources/file_based/config/parquet_format.py b/airbyte_cdk/sources/file_based/config/parquet_format.py index 7c40f8e3d..4aba47a30 100644 --- a/airbyte_cdk/sources/file_based/config/parquet_format.py +++ b/airbyte_cdk/sources/file_based/config/parquet_format.py @@ -3,9 +3,10 @@ # -from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig from pydantic.v1 import BaseModel, Field +from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig + class ParquetFormat(BaseModel): class Config(OneOfOptionConfig): diff --git a/airbyte_cdk/sources/file_based/config/unstructured_format.py b/airbyte_cdk/sources/file_based/config/unstructured_format.py index dcebd9517..c03540ce6 100644 --- a/airbyte_cdk/sources/file_based/config/unstructured_format.py +++ b/airbyte_cdk/sources/file_based/config/unstructured_format.py @@ -4,9 +4,10 @@ from typing import List, Literal, Optional, Union -from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig from pydantic.v1 import BaseModel, Field +from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig + class LocalProcessingConfigModel(BaseModel): mode: Literal["local"] = Field("local", const=True) diff --git a/airbyte_cdk/sources/file_based/file_based_source.py b/airbyte_cdk/sources/file_based/file_based_source.py index 2c5758b2c..900e6a4da 100644 --- a/airbyte_cdk/sources/file_based/file_based_source.py +++ b/airbyte_cdk/sources/file_based/file_based_source.py @@ -8,6 +8,8 @@ from collections import Counter from typing import Any, Iterator, List, Mapping, Optional, Tuple, Type, Union +from pydantic.v1.error_wrappers import ValidationError + from airbyte_cdk.logger import AirbyteLogFormatter, init_logger from airbyte_cdk.models import ( AirbyteMessage, @@ -60,7 +62,6 @@ from airbyte_cdk.sources.streams.concurrent.cursor import CursorField from airbyte_cdk.utils.analytics_message import create_analytics_message from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from pydantic.v1.error_wrappers import ValidationError DEFAULT_CONCURRENCY = 100 MAX_CONCURRENCY = 100 diff --git a/airbyte_cdk/sources/file_based/file_based_stream_reader.py b/airbyte_cdk/sources/file_based/file_based_stream_reader.py index f8a9f89fb..ab1c428ce 100644 --- a/airbyte_cdk/sources/file_based/file_based_stream_reader.py +++ b/airbyte_cdk/sources/file_based/file_based_stream_reader.py @@ -10,9 +10,10 @@ from os import makedirs, path from typing import Any, Dict, Iterable, List, Optional, Set +from wcmatch.glob import GLOBSTAR, globmatch + from airbyte_cdk.sources.file_based.config.abstract_file_based_spec import AbstractFileBasedSpec from airbyte_cdk.sources.file_based.remote_file import RemoteFile -from wcmatch.glob import GLOBSTAR, globmatch class FileReadMode(Enum): diff --git a/airbyte_cdk/sources/file_based/file_types/avro_parser.py b/airbyte_cdk/sources/file_based/file_types/avro_parser.py index a1535eaa9..61e3a2c82 100644 --- a/airbyte_cdk/sources/file_based/file_types/avro_parser.py +++ b/airbyte_cdk/sources/file_based/file_types/avro_parser.py @@ -6,6 +6,7 @@ from typing import Any, Dict, Iterable, Mapping, Optional, Tuple import fastavro + from airbyte_cdk.sources.file_based.config.avro_format import AvroFormat from airbyte_cdk.sources.file_based.config.file_based_stream_config import FileBasedStreamConfig from airbyte_cdk.sources.file_based.exceptions import FileBasedSourceError, RecordParseError diff --git a/airbyte_cdk/sources/file_based/file_types/csv_parser.py b/airbyte_cdk/sources/file_based/file_types/csv_parser.py index 951be6fe2..1b7fcfed5 100644 --- a/airbyte_cdk/sources/file_based/file_types/csv_parser.py +++ b/airbyte_cdk/sources/file_based/file_types/csv_parser.py @@ -12,6 +12,8 @@ from typing import Any, Callable, Dict, Generator, Iterable, List, Mapping, Optional, Set, Tuple from uuid import uuid4 +from orjson import orjson + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.file_based.config.csv_format import ( CsvFormat, @@ -29,7 +31,6 @@ from airbyte_cdk.sources.file_based.remote_file import RemoteFile from airbyte_cdk.sources.file_based.schema_helpers import TYPE_PYTHON_MAPPING, SchemaType from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from orjson import orjson DIALECT_NAME = "_config_dialect" diff --git a/airbyte_cdk/sources/file_based/file_types/excel_parser.py b/airbyte_cdk/sources/file_based/file_types/excel_parser.py index 0c0da8b3f..a95df6033 100644 --- a/airbyte_cdk/sources/file_based/file_types/excel_parser.py +++ b/airbyte_cdk/sources/file_based/file_types/excel_parser.py @@ -8,6 +8,11 @@ from typing import Any, Dict, Iterable, Mapping, Optional, Tuple, Union import pandas as pd +from numpy import datetime64, issubdtype +from numpy import dtype as dtype_ +from orjson import orjson +from pydantic.v1 import BaseModel + from airbyte_cdk.sources.file_based.config.file_based_stream_config import ( ExcelFormat, FileBasedStreamConfig, @@ -24,11 +29,6 @@ from airbyte_cdk.sources.file_based.file_types.file_type_parser import FileTypeParser from airbyte_cdk.sources.file_based.remote_file import RemoteFile from airbyte_cdk.sources.file_based.schema_helpers import SchemaType -from numpy import datetime64 -from numpy import dtype as dtype_ -from numpy import issubdtype -from orjson import orjson -from pydantic.v1 import BaseModel class ExcelParser(FileTypeParser): diff --git a/airbyte_cdk/sources/file_based/file_types/jsonl_parser.py b/airbyte_cdk/sources/file_based/file_types/jsonl_parser.py index 6cd590750..67132dd87 100644 --- a/airbyte_cdk/sources/file_based/file_types/jsonl_parser.py +++ b/airbyte_cdk/sources/file_based/file_types/jsonl_parser.py @@ -6,6 +6,8 @@ import logging from typing import Any, Dict, Iterable, Mapping, Optional, Tuple, Union +from orjson import orjson + from airbyte_cdk.sources.file_based.config.file_based_stream_config import FileBasedStreamConfig from airbyte_cdk.sources.file_based.exceptions import FileBasedSourceError, RecordParseError from airbyte_cdk.sources.file_based.file_based_stream_reader import ( @@ -19,7 +21,6 @@ SchemaType, merge_schemas, ) -from orjson import orjson class JsonlParser(FileTypeParser): diff --git a/airbyte_cdk/sources/file_based/file_types/parquet_parser.py b/airbyte_cdk/sources/file_based/file_types/parquet_parser.py index 99b6373d3..28cfb14c9 100644 --- a/airbyte_cdk/sources/file_based/file_types/parquet_parser.py +++ b/airbyte_cdk/sources/file_based/file_types/parquet_parser.py @@ -10,6 +10,8 @@ import pyarrow as pa import pyarrow.parquet as pq +from pyarrow import DictionaryArray, Scalar + from airbyte_cdk.sources.file_based.config.file_based_stream_config import ( FileBasedStreamConfig, ParquetFormat, @@ -26,7 +28,6 @@ from airbyte_cdk.sources.file_based.file_types.file_type_parser import FileTypeParser from airbyte_cdk.sources.file_based.remote_file import RemoteFile from airbyte_cdk.sources.file_based.schema_helpers import SchemaType -from pyarrow import DictionaryArray, Scalar class ParquetParser(FileTypeParser): diff --git a/airbyte_cdk/sources/file_based/file_types/unstructured_parser.py b/airbyte_cdk/sources/file_based/file_types/unstructured_parser.py index 972240dc6..9dfde9ca0 100644 --- a/airbyte_cdk/sources/file_based/file_types/unstructured_parser.py +++ b/airbyte_cdk/sources/file_based/file_types/unstructured_parser.py @@ -9,7 +9,16 @@ import backoff import dpath +import nltk import requests +from unstructured.file_utils.filetype import ( + EXT_TO_FILETYPE, + FILETYPE_TO_MIMETYPE, + STR_TO_FILETYPE, + FileType, + detect_filetype, +) + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.file_based.config.file_based_stream_config import FileBasedStreamConfig from airbyte_cdk.sources.file_based.config.unstructured_format import ( @@ -28,14 +37,6 @@ from airbyte_cdk.sources.file_based.schema_helpers import SchemaType from airbyte_cdk.utils import is_cloud_environment from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from unstructured.file_utils.filetype import ( - EXT_TO_FILETYPE, - FILETYPE_TO_MIMETYPE, - STR_TO_FILETYPE, - FileType, - detect_filetype, -) -import nltk unstructured_partition_pdf = None unstructured_partition_docx = None diff --git a/airbyte_cdk/sources/file_based/stream/abstract_file_based_stream.py b/airbyte_cdk/sources/file_based/stream/abstract_file_based_stream.py index 8c0e1ebf0..5423ffa9f 100644 --- a/airbyte_cdk/sources/file_based/stream/abstract_file_based_stream.py +++ b/airbyte_cdk/sources/file_based/stream/abstract_file_based_stream.py @@ -6,6 +6,8 @@ from functools import cache, cached_property, lru_cache from typing import Any, Dict, Iterable, List, Mapping, Optional, Type +from deprecated import deprecated + from airbyte_cdk import AirbyteMessage from airbyte_cdk.models import SyncMode from airbyte_cdk.sources.file_based.availability_strategy import ( @@ -30,7 +32,6 @@ from airbyte_cdk.sources.file_based.types import StreamSlice from airbyte_cdk.sources.streams import Stream from airbyte_cdk.sources.streams.checkpoint import Cursor -from deprecated import deprecated class AbstractFileBasedStream(Stream): diff --git a/airbyte_cdk/sources/file_based/stream/concurrent/adapters.py b/airbyte_cdk/sources/file_based/stream/concurrent/adapters.py index 0c5daf06e..c71493634 100644 --- a/airbyte_cdk/sources/file_based/stream/concurrent/adapters.py +++ b/airbyte_cdk/sources/file_based/stream/concurrent/adapters.py @@ -7,6 +7,8 @@ from functools import cache, lru_cache from typing import TYPE_CHECKING, Any, Iterable, List, Mapping, MutableMapping, Optional, Union +from deprecated.classic import deprecated + from airbyte_cdk.models import ( AirbyteLogMessage, AirbyteMessage, @@ -43,7 +45,6 @@ from airbyte_cdk.sources.streams.core import StreamData from airbyte_cdk.sources.utils.schema_helpers import InternalConfig from airbyte_cdk.sources.utils.slice_logger import SliceLogger -from deprecated.classic import deprecated if TYPE_CHECKING: from airbyte_cdk.sources.file_based.stream.concurrent.cursor import ( diff --git a/airbyte_cdk/sources/http_logger.py b/airbyte_cdk/sources/http_logger.py index cbdc3c684..58d6aed30 100644 --- a/airbyte_cdk/sources/http_logger.py +++ b/airbyte_cdk/sources/http_logger.py @@ -5,6 +5,7 @@ from typing import Optional, Union import requests + from airbyte_cdk.sources.message import LogMessage diff --git a/airbyte_cdk/sources/streams/call_rate.py b/airbyte_cdk/sources/streams/call_rate.py index 19ae603c4..81ebac78e 100644 --- a/airbyte_cdk/sources/streams/call_rate.py +++ b/airbyte_cdk/sources/streams/call_rate.py @@ -14,9 +14,8 @@ import requests import requests_cache -from pyrate_limiter import InMemoryBucket, Limiter +from pyrate_limiter import InMemoryBucket, Limiter, RateItem, TimeClock from pyrate_limiter import Rate as PyRateRate -from pyrate_limiter import RateItem, TimeClock from pyrate_limiter.exceptions import BucketFullException # prevents mypy from complaining about missing session attributes in LimiterMixin diff --git a/airbyte_cdk/sources/streams/concurrent/abstract_stream.py b/airbyte_cdk/sources/streams/concurrent/abstract_stream.py index da99ae10b..decf645b7 100644 --- a/airbyte_cdk/sources/streams/concurrent/abstract_stream.py +++ b/airbyte_cdk/sources/streams/concurrent/abstract_stream.py @@ -5,12 +5,13 @@ from abc import ABC, abstractmethod from typing import Any, Iterable, Mapping, Optional +from deprecated.classic import deprecated + from airbyte_cdk.models import AirbyteStream from airbyte_cdk.sources.source import ExperimentalClassWarning from airbyte_cdk.sources.streams.concurrent.availability_strategy import StreamAvailability from airbyte_cdk.sources.streams.concurrent.cursor import Cursor from airbyte_cdk.sources.streams.concurrent.partitions.partition import Partition -from deprecated.classic import deprecated @deprecated("This class is experimental. Use at your own risk.", category=ExperimentalClassWarning) diff --git a/airbyte_cdk/sources/streams/concurrent/adapters.py b/airbyte_cdk/sources/streams/concurrent/adapters.py index 679f2d865..a9cc4a5f9 100644 --- a/airbyte_cdk/sources/streams/concurrent/adapters.py +++ b/airbyte_cdk/sources/streams/concurrent/adapters.py @@ -8,6 +8,8 @@ from functools import lru_cache from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple, Union +from deprecated.classic import deprecated + from airbyte_cdk.models import ( AirbyteLogMessage, AirbyteMessage, @@ -41,8 +43,6 @@ from airbyte_cdk.sources.streams.core import StreamData from airbyte_cdk.sources.utils.schema_helpers import InternalConfig from airbyte_cdk.sources.utils.slice_logger import SliceLogger -from deprecated.classic import deprecated - from airbyte_cdk.utils.slice_hasher import SliceHasher """ diff --git a/airbyte_cdk/sources/streams/concurrent/availability_strategy.py b/airbyte_cdk/sources/streams/concurrent/availability_strategy.py index 098b24cef..c69a9f3e5 100644 --- a/airbyte_cdk/sources/streams/concurrent/availability_strategy.py +++ b/airbyte_cdk/sources/streams/concurrent/availability_strategy.py @@ -6,9 +6,10 @@ from abc import ABC, abstractmethod from typing import Optional -from airbyte_cdk.sources.source import ExperimentalClassWarning from deprecated.classic import deprecated +from airbyte_cdk.sources.source import ExperimentalClassWarning + class StreamAvailability(ABC): @abstractmethod diff --git a/airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py b/airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py index 482aa897d..714789af3 100644 --- a/airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py +++ b/airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py @@ -7,6 +7,7 @@ from typing import Any, Callable, List, MutableMapping, Optional, Tuple import pendulum +from pendulum.datetime import DateTime # FIXME We would eventually like the Concurrent package do be agnostic of the declarative package. However, this is a breaking change and # the goal in the short term is only to fix the issue we are seeing for source-declarative-manifest. @@ -16,7 +17,6 @@ AbstractStreamStateConverter, ConcurrencyCompatibleStateType, ) -from pendulum.datetime import DateTime class DateTimeStreamStateConverter(AbstractStreamStateConverter): diff --git a/airbyte_cdk/sources/streams/core.py b/airbyte_cdk/sources/streams/core.py index 90925c4cf..51c3682d6 100644 --- a/airbyte_cdk/sources/streams/core.py +++ b/airbyte_cdk/sources/streams/core.py @@ -10,6 +10,8 @@ from functools import cached_property, lru_cache from typing import Any, Dict, Iterable, Iterator, List, Mapping, MutableMapping, Optional, Union +from deprecated import deprecated + import airbyte_cdk.sources.utils.casing as casing from airbyte_cdk.models import ( AirbyteMessage, @@ -35,7 +37,6 @@ from airbyte_cdk.sources.utils.schema_helpers import InternalConfig, ResourceSchemaLoader from airbyte_cdk.sources.utils.slice_logger import DebugSliceLogger, SliceLogger from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer -from deprecated import deprecated # A stream's read method can return one of the following types: # Mapping[str, Any]: The content of an AirbyteRecordMessage diff --git a/airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py b/airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py index fa8864dbf..74840e2d2 100644 --- a/airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py +++ b/airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py @@ -4,12 +4,13 @@ from typing import Mapping, Type, Union +from requests.exceptions import InvalidSchema, InvalidURL, RequestException + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.streams.http.error_handlers.response_models import ( ErrorResolution, ResponseAction, ) -from requests.exceptions import InvalidSchema, InvalidURL, RequestException DEFAULT_ERROR_MAPPING: Mapping[Union[int, str, Type[Exception]], ErrorResolution] = { InvalidSchema: ErrorResolution( diff --git a/airbyte_cdk/sources/streams/http/error_handlers/http_status_error_handler.py b/airbyte_cdk/sources/streams/http/error_handlers/http_status_error_handler.py index f18e3db26..18daca3de 100644 --- a/airbyte_cdk/sources/streams/http/error_handlers/http_status_error_handler.py +++ b/airbyte_cdk/sources/streams/http/error_handlers/http_status_error_handler.py @@ -7,6 +7,7 @@ from typing import Mapping, Optional, Union import requests + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.streams.http.error_handlers.default_error_mapping import ( DEFAULT_ERROR_MAPPING, diff --git a/airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py b/airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py index 3ca31ec57..7c58280c7 100644 --- a/airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py +++ b/airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py @@ -5,6 +5,7 @@ from typing import Optional import requests + from airbyte_cdk.sources.streams.http.error_handlers import ErrorMessageParser from airbyte_cdk.sources.utils.types import JsonType diff --git a/airbyte_cdk/sources/streams/http/error_handlers/response_models.py b/airbyte_cdk/sources/streams/http/error_handlers/response_models.py index aca13a8ca..e882b89bd 100644 --- a/airbyte_cdk/sources/streams/http/error_handlers/response_models.py +++ b/airbyte_cdk/sources/streams/http/error_handlers/response_models.py @@ -5,9 +5,10 @@ from typing import Optional, Union import requests +from requests import HTTPError + from airbyte_cdk.models import FailureType from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets -from requests import HTTPError class ResponseAction(Enum): diff --git a/airbyte_cdk/sources/streams/http/http.py b/airbyte_cdk/sources/streams/http/http.py index f9731517d..f465671be 100644 --- a/airbyte_cdk/sources/streams/http/http.py +++ b/airbyte_cdk/sources/streams/http/http.py @@ -9,6 +9,9 @@ from urllib.parse import urljoin import requests +from deprecated import deprecated +from requests.auth import AuthBase + from airbyte_cdk.models import AirbyteMessage, FailureType, SyncMode from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources.message.repository import InMemoryMessageRepository @@ -33,8 +36,6 @@ from airbyte_cdk.sources.streams.http.http_client import HttpClient from airbyte_cdk.sources.types import Record, StreamSlice from airbyte_cdk.sources.utils.types import JsonType -from deprecated import deprecated -from requests.auth import AuthBase # list of all possible HTTP methods which can be used for sending of request bodies BODY_REQUEST_METHODS = ("GET", "POST", "PUT", "PATCH") diff --git a/airbyte_cdk/sources/streams/http/http_client.py b/airbyte_cdk/sources/streams/http/http_client.py index 704b715c0..ef9adbc96 100644 --- a/airbyte_cdk/sources/streams/http/http_client.py +++ b/airbyte_cdk/sources/streams/http/http_client.py @@ -11,6 +11,8 @@ import orjson import requests import requests_cache +from requests.auth import AuthBase + from airbyte_cdk.models import ( AirbyteMessageSerializer, AirbyteStreamStatus, @@ -48,7 +50,6 @@ as_airbyte_message as stream_status_as_airbyte_message, ) from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from requests.auth import AuthBase BODY_REQUEST_METHODS = ("GET", "POST", "PUT", "PATCH") diff --git a/airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py b/airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py index 7942aa361..01c9d60d0 100644 --- a/airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py +++ b/airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py @@ -10,12 +10,13 @@ import backoff import pendulum import requests +from requests.auth import AuthBase + from airbyte_cdk.models import FailureType, Level from airbyte_cdk.sources.http_logger import format_http_message from airbyte_cdk.sources.message import MessageRepository, NoopMessageRepository from airbyte_cdk.utils import AirbyteTracedException from airbyte_cdk.utils.airbyte_secrets_utils import add_to_secrets -from requests.auth import AuthBase from ..exceptions import DefaultBackoffException diff --git a/airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py b/airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py index 4ae840484..bdc5eddcd 100644 --- a/airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py +++ b/airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py @@ -6,6 +6,7 @@ import dpath import pendulum + from airbyte_cdk.config_observation import ( create_connector_config_control_message, emit_configuration_as_airbyte_control_message, diff --git a/airbyte_cdk/sources/utils/schema_helpers.py b/airbyte_cdk/sources/utils/schema_helpers.py index 5b1287ac8..b8d2507c6 100644 --- a/airbyte_cdk/sources/utils/schema_helpers.py +++ b/airbyte_cdk/sources/utils/schema_helpers.py @@ -10,12 +10,13 @@ from typing import Any, ClassVar, Dict, List, Mapping, MutableMapping, Optional, Tuple import jsonref -from airbyte_cdk.models import ConnectorSpecification, FailureType -from airbyte_cdk.utils.traced_exception import AirbyteTracedException from jsonschema import RefResolver, validate from jsonschema.exceptions import ValidationError from pydantic.v1 import BaseModel, Field +from airbyte_cdk.models import ConnectorSpecification, FailureType +from airbyte_cdk.utils.traced_exception import AirbyteTracedException + class JsonFileLoader: """ diff --git a/airbyte_cdk/sql/secrets.py b/airbyte_cdk/sql/secrets.py index bff9e8100..c2508682d 100644 --- a/airbyte_cdk/sql/secrets.py +++ b/airbyte_cdk/sql/secrets.py @@ -6,9 +6,10 @@ import json from typing import TYPE_CHECKING, Any -from airbyte_cdk.sql import exceptions as exc from pydantic_core import CoreSchema, core_schema +from airbyte_cdk.sql import exceptions as exc + if TYPE_CHECKING: from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler, ValidationInfo from pydantic.json_schema import JsonSchemaValue diff --git a/airbyte_cdk/sql/shared/sql_processor.py b/airbyte_cdk/sql/shared/sql_processor.py index dd8cb3e5c..5fd0a5e46 100644 --- a/airbyte_cdk/sql/shared/sql_processor.py +++ b/airbyte_cdk/sql/shared/sql_processor.py @@ -13,6 +13,12 @@ import pandas as pd import sqlalchemy import ulid +from airbyte_protocol_dataclasses.models import AirbyteStateMessage +from pandas import Index +from pydantic import BaseModel, Field +from sqlalchemy import Column, Table, and_, create_engine, insert, null, select, text, update +from sqlalchemy.exc import ProgrammingError, SQLAlchemyError + from airbyte_cdk.sql import exceptions as exc from airbyte_cdk.sql._util.hashing import one_way_hash from airbyte_cdk.sql._util.name_normalizers import LowerCaseNormalizer @@ -24,16 +30,10 @@ ) from airbyte_cdk.sql.secrets import SecretString from airbyte_cdk.sql.types import SQLTypeConverter -from airbyte_protocol_dataclasses.models import AirbyteStateMessage -from pandas import Index -from pydantic import BaseModel, Field -from sqlalchemy import Column, Table, and_, create_engine, insert, null, select, text, update -from sqlalchemy.exc import ProgrammingError, SQLAlchemyError if TYPE_CHECKING: from collections.abc import Generator - from airbyte_cdk.sql.shared.catalog_providers import CatalogProvider from sqlalchemy.engine import Connection, Engine from sqlalchemy.engine.cursor import CursorResult from sqlalchemy.engine.reflection import Inspector @@ -41,6 +41,8 @@ from sqlalchemy.sql.elements import TextClause from sqlalchemy.sql.type_api import TypeEngine + from airbyte_cdk.sql.shared.catalog_providers import CatalogProvider + class SQLRuntimeError(Exception): """Raised when an SQL operation fails.""" diff --git a/airbyte_cdk/test/entrypoint_wrapper.py b/airbyte_cdk/test/entrypoint_wrapper.py index 5e7a80da5..847570cd6 100644 --- a/airbyte_cdk/test/entrypoint_wrapper.py +++ b/airbyte_cdk/test/entrypoint_wrapper.py @@ -23,6 +23,10 @@ from pathlib import Path from typing import Any, List, Mapping, Optional, Union +from orjson import orjson +from pydantic import ValidationError as V2ValidationError +from serpyco_rs import SchemaValidationError + from airbyte_cdk.entrypoint import AirbyteEntrypoint from airbyte_cdk.exception_handler import assemble_uncaught_exception from airbyte_cdk.logger import AirbyteLogFormatter @@ -40,9 +44,6 @@ Type, ) from airbyte_cdk.sources import Source -from orjson import orjson -from pydantic import ValidationError as V2ValidationError -from serpyco_rs import SchemaValidationError class EntrypointOutput: diff --git a/airbyte_cdk/test/mock_http/mocker.py b/airbyte_cdk/test/mock_http/mocker.py index a62c46a56..a8ab95afc 100644 --- a/airbyte_cdk/test/mock_http/mocker.py +++ b/airbyte_cdk/test/mock_http/mocker.py @@ -7,6 +7,7 @@ from typing import Callable, List, Optional, Union import requests_mock + from airbyte_cdk.test.mock_http import HttpRequest, HttpRequestMatcher, HttpResponse diff --git a/airbyte_cdk/utils/schema_inferrer.py b/airbyte_cdk/utils/schema_inferrer.py index 65d44369c..f3c6b2fae 100644 --- a/airbyte_cdk/utils/schema_inferrer.py +++ b/airbyte_cdk/utils/schema_inferrer.py @@ -5,11 +5,12 @@ from collections import defaultdict from typing import Any, Dict, List, Mapping, Optional -from airbyte_cdk.models import AirbyteRecordMessage from genson import SchemaBuilder, SchemaNode from genson.schema.strategies.object import Object from genson.schema.strategies.scalar import Number +from airbyte_cdk.models import AirbyteRecordMessage + # schema keywords _TYPE = "type" _NULL_TYPE = "null" diff --git a/airbyte_cdk/utils/slice_hasher.py b/airbyte_cdk/utils/slice_hasher.py index d86147da0..7f46dd768 100644 --- a/airbyte_cdk/utils/slice_hasher.py +++ b/airbyte_cdk/utils/slice_hasher.py @@ -1,6 +1,6 @@ import hashlib import json -from typing import Any, Mapping, Optional, Final +from typing import Any, Final, Mapping, Optional class SliceEncoder(json.JSONEncoder): diff --git a/airbyte_cdk/utils/traced_exception.py b/airbyte_cdk/utils/traced_exception.py index 11f600324..75b6eab16 100644 --- a/airbyte_cdk/utils/traced_exception.py +++ b/airbyte_cdk/utils/traced_exception.py @@ -5,6 +5,8 @@ import traceback from typing import Optional +from orjson import orjson + from airbyte_cdk.models import ( AirbyteConnectionStatus, AirbyteErrorTraceMessage, @@ -18,7 +20,6 @@ ) from airbyte_cdk.models import Type as MessageType from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets -from orjson import orjson class AirbyteTracedException(Exception): diff --git a/pyproject.toml b/pyproject.toml index 268b1a427..017992b1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,6 +118,9 @@ exclude = ["__init__.py"] # TODO: Remove after this is fixed: https://github.co target-version = "py310" line-length = 100 +[tool.ruff.lint] +select = ["I"] + [tool.poe.tasks] # Build tasks assemble = {cmd = "bin/generate-component-manifest-dagger.sh", help = "Generate component manifest files."} diff --git a/unit_tests/connector_builder/test_connector_builder_handler.py b/unit_tests/connector_builder/test_connector_builder_handler.py index 37b6dc6e6..234a6e9cd 100644 --- a/unit_tests/connector_builder/test_connector_builder_handler.py +++ b/unit_tests/connector_builder/test_connector_builder_handler.py @@ -13,6 +13,8 @@ import pytest import requests +from orjson import orjson + from airbyte_cdk import connector_builder from airbyte_cdk.connector_builder.connector_builder_handler import ( DEFAULT_MAXIMUM_NUMBER_OF_PAGES_PER_SLICE, @@ -51,15 +53,14 @@ Level, StreamDescriptor, SyncMode, + Type, ) -from airbyte_cdk.models import Type from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources.declarative.declarative_stream import DeclarativeStream from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource from airbyte_cdk.sources.declarative.retrievers import SimpleRetrieverTestReadDecorator from airbyte_cdk.sources.declarative.retrievers.simple_retriever import SimpleRetriever from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets, update_secrets -from orjson import orjson from unit_tests.connector_builder.utils import create_configured_catalog _stream_name = "stream_with_custom_requester" diff --git a/unit_tests/connector_builder/test_message_grouper.py b/unit_tests/connector_builder/test_message_grouper.py index e95f7fcc6..bf63f0555 100644 --- a/unit_tests/connector_builder/test_message_grouper.py +++ b/unit_tests/connector_builder/test_message_grouper.py @@ -7,6 +7,8 @@ from unittest.mock import MagicMock, Mock, patch import pytest +from orjson import orjson + from airbyte_cdk.connector_builder.message_grouper import MessageGrouper from airbyte_cdk.connector_builder.models import ( HttpRequest, @@ -29,7 +31,6 @@ StreamDescriptor, ) from airbyte_cdk.models import Type as MessageType -from orjson import orjson from unit_tests.connector_builder.utils import create_configured_catalog _NO_PK = [[]] diff --git a/unit_tests/destinations/test_destination.py b/unit_tests/destinations/test_destination.py index ffe1fd37b..4294192e6 100644 --- a/unit_tests/destinations/test_destination.py +++ b/unit_tests/destinations/test_destination.py @@ -10,6 +10,8 @@ from unittest.mock import ANY import pytest +from orjson import orjson + from airbyte_cdk.destinations import Destination from airbyte_cdk.destinations import destination as destination_module from airbyte_cdk.models import ( @@ -29,7 +31,6 @@ SyncMode, Type, ) -from orjson import orjson @pytest.fixture(name="destination") diff --git a/unit_tests/destinations/vector_db_based/config_test.py b/unit_tests/destinations/vector_db_based/config_test.py index 0eeae37b7..ea6f446bc 100644 --- a/unit_tests/destinations/vector_db_based/config_test.py +++ b/unit_tests/destinations/vector_db_based/config_test.py @@ -5,6 +5,8 @@ from typing import Union import dpath +from pydantic.v1 import BaseModel, Field + from airbyte_cdk.destinations.vector_db_based.config import ( AzureOpenAIEmbeddingConfigModel, CohereEmbeddingConfigModel, @@ -14,7 +16,6 @@ ProcessingConfigModel, ) from airbyte_cdk.utils.spec_schema_transformations import resolve_refs -from pydantic.v1 import BaseModel, Field class IndexingModel(BaseModel): diff --git a/unit_tests/destinations/vector_db_based/document_processor_test.py b/unit_tests/destinations/vector_db_based/document_processor_test.py index f427f42d4..ede889216 100644 --- a/unit_tests/destinations/vector_db_based/document_processor_test.py +++ b/unit_tests/destinations/vector_db_based/document_processor_test.py @@ -6,6 +6,7 @@ from unittest.mock import MagicMock import pytest + from airbyte_cdk.destinations.vector_db_based.config import ( CodeSplitterConfigModel, FieldNameMappingConfigModel, diff --git a/unit_tests/destinations/vector_db_based/embedder_test.py b/unit_tests/destinations/vector_db_based/embedder_test.py index dc0f5378e..f772ab7db 100644 --- a/unit_tests/destinations/vector_db_based/embedder_test.py +++ b/unit_tests/destinations/vector_db_based/embedder_test.py @@ -5,6 +5,7 @@ from unittest.mock import MagicMock, call import pytest + from airbyte_cdk.destinations.vector_db_based.config import ( AzureOpenAIEmbeddingConfigModel, CohereEmbeddingConfigModel, diff --git a/unit_tests/destinations/vector_db_based/writer_test.py b/unit_tests/destinations/vector_db_based/writer_test.py index b39ce8d39..6475f619d 100644 --- a/unit_tests/destinations/vector_db_based/writer_test.py +++ b/unit_tests/destinations/vector_db_based/writer_test.py @@ -6,6 +6,7 @@ from unittest.mock import ANY, MagicMock, call import pytest + from airbyte_cdk.destinations.vector_db_based import ProcessingConfigModel, Writer from airbyte_cdk.models import ( AirbyteLogMessage, diff --git a/unit_tests/source_declarative_manifest/conftest.py b/unit_tests/source_declarative_manifest/conftest.py index 4d4a16aa0..3d61e65e8 100644 --- a/unit_tests/source_declarative_manifest/conftest.py +++ b/unit_tests/source_declarative_manifest/conftest.py @@ -2,8 +2,9 @@ # Copyright (c) 2024 Airbyte, Inc., all rights reserved. # -import pytest import os + +import pytest import yaml diff --git a/unit_tests/source_declarative_manifest/test_source_declarative_local_manifest.py b/unit_tests/source_declarative_manifest/test_source_declarative_local_manifest.py index 871950b16..93e4cd38b 100644 --- a/unit_tests/source_declarative_manifest/test_source_declarative_local_manifest.py +++ b/unit_tests/source_declarative_manifest/test_source_declarative_local_manifest.py @@ -7,6 +7,7 @@ import pytest from jsonschema import ValidationError + from airbyte_cdk.cli.source_declarative_manifest import _run POKEAPI_JSON_SPEC_SUBSTRING = '"required":["pokemon_name"]' diff --git a/unit_tests/source_declarative_manifest/test_source_declarative_remote_manifest.py b/unit_tests/source_declarative_manifest/test_source_declarative_remote_manifest.py index 093f634a4..8d1f558d0 100644 --- a/unit_tests/source_declarative_manifest/test_source_declarative_remote_manifest.py +++ b/unit_tests/source_declarative_manifest/test_source_declarative_remote_manifest.py @@ -3,11 +3,12 @@ # import pytest -from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource + from airbyte_cdk.cli.source_declarative_manifest._run import ( create_declarative_source, handle_command, ) +from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource REMOTE_MANIFEST_SPEC_SUBSTRING = '"required":["__injected_declarative_manifest"]' diff --git a/unit_tests/sources/concurrent_source/test_concurrent_source_adapter.py b/unit_tests/sources/concurrent_source/test_concurrent_source_adapter.py index 6593416aa..8f41253fa 100644 --- a/unit_tests/sources/concurrent_source/test_concurrent_source_adapter.py +++ b/unit_tests/sources/concurrent_source/test_concurrent_source_adapter.py @@ -8,6 +8,7 @@ import freezegun import pytest + from airbyte_cdk.models import ( AirbyteMessage, AirbyteRecordMessage, diff --git a/unit_tests/sources/conftest.py b/unit_tests/sources/conftest.py index d20d763bb..1410ddc9e 100644 --- a/unit_tests/sources/conftest.py +++ b/unit_tests/sources/conftest.py @@ -5,6 +5,7 @@ import datetime import pytest + from airbyte_cdk.models import ( AirbyteMessage, AirbyteStreamStatus, diff --git a/unit_tests/sources/declarative/async_job/test_job_orchestrator.py b/unit_tests/sources/declarative/async_job/test_job_orchestrator.py index af8e84e77..d2fb9018f 100644 --- a/unit_tests/sources/declarative/async_job/test_job_orchestrator.py +++ b/unit_tests/sources/declarative/async_job/test_job_orchestrator.py @@ -9,6 +9,7 @@ from unittest.mock import MagicMock, Mock, call import pytest + from airbyte_cdk import AirbyteTracedException, StreamSlice from airbyte_cdk.models import FailureType from airbyte_cdk.sources.declarative.async_job.job import AsyncJob, AsyncJobStatus diff --git a/unit_tests/sources/declarative/async_job/test_job_tracker.py b/unit_tests/sources/declarative/async_job/test_job_tracker.py index 6d09df169..1202c663d 100644 --- a/unit_tests/sources/declarative/async_job/test_job_tracker.py +++ b/unit_tests/sources/declarative/async_job/test_job_tracker.py @@ -4,6 +4,7 @@ from unittest import TestCase import pytest + from airbyte_cdk.sources.declarative.async_job.job_tracker import ( ConcurrentJobLimitReached, JobTracker, diff --git a/unit_tests/sources/declarative/auth/test_jwt.py b/unit_tests/sources/declarative/auth/test_jwt.py index a26042f70..fe727b980 100644 --- a/unit_tests/sources/declarative/auth/test_jwt.py +++ b/unit_tests/sources/declarative/auth/test_jwt.py @@ -8,6 +8,7 @@ import freezegun import jwt import pytest + from airbyte_cdk.sources.declarative.auth.jwt import JwtAuthenticator LOGGER = logging.getLogger(__name__) diff --git a/unit_tests/sources/declarative/auth/test_oauth.py b/unit_tests/sources/declarative/auth/test_oauth.py index 4cdfad2fd..bce87bab2 100644 --- a/unit_tests/sources/declarative/auth/test_oauth.py +++ b/unit_tests/sources/declarative/auth/test_oauth.py @@ -9,9 +9,10 @@ import pendulum import pytest import requests +from requests import Response + from airbyte_cdk.sources.declarative.auth import DeclarativeOauth2Authenticator from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets -from requests import Response LOGGER = logging.getLogger(__name__) diff --git a/unit_tests/sources/declarative/auth/test_selective_authenticator.py b/unit_tests/sources/declarative/auth/test_selective_authenticator.py index 55b0a1ed5..1e43f1e66 100644 --- a/unit_tests/sources/declarative/auth/test_selective_authenticator.py +++ b/unit_tests/sources/declarative/auth/test_selective_authenticator.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.auth.selective_authenticator import SelectiveAuthenticator diff --git a/unit_tests/sources/declarative/auth/test_session_token_auth.py b/unit_tests/sources/declarative/auth/test_session_token_auth.py index eda2f36b7..02de5b5b4 100644 --- a/unit_tests/sources/declarative/auth/test_session_token_auth.py +++ b/unit_tests/sources/declarative/auth/test_session_token_auth.py @@ -3,11 +3,12 @@ # import pytest +from requests.exceptions import HTTPError + from airbyte_cdk.sources.declarative.auth.token import ( LegacySessionTokenAuthenticator, get_new_session_token, ) -from requests.exceptions import HTTPError parameters = {"hello": "world"} instance_api_url = "https://airbyte.metabaseapp.com/api/" diff --git a/unit_tests/sources/declarative/auth/test_token_auth.py b/unit_tests/sources/declarative/auth/test_token_auth.py index 64b181c45..2a23d4e19 100644 --- a/unit_tests/sources/declarative/auth/test_token_auth.py +++ b/unit_tests/sources/declarative/auth/test_token_auth.py @@ -6,6 +6,8 @@ import pytest import requests +from requests import Response + from airbyte_cdk.sources.declarative.auth.token import ( ApiKeyAuthenticator, BasicHttpAuthenticator, @@ -16,7 +18,6 @@ RequestOption, RequestOptionType, ) -from requests import Response LOGGER = logging.getLogger(__name__) diff --git a/unit_tests/sources/declarative/auth/test_token_provider.py b/unit_tests/sources/declarative/auth/test_token_provider.py index 684dfbf7c..217c57808 100644 --- a/unit_tests/sources/declarative/auth/test_token_provider.py +++ b/unit_tests/sources/declarative/auth/test_token_provider.py @@ -6,12 +6,13 @@ import pendulum import pytest +from isodate import parse_duration + from airbyte_cdk.sources.declarative.auth.token_provider import ( InterpolatedStringTokenProvider, SessionTokenProvider, ) from airbyte_cdk.sources.declarative.exceptions import ReadException -from isodate import parse_duration def create_session_token_provider(): diff --git a/unit_tests/sources/declarative/checks/test_check_stream.py b/unit_tests/sources/declarative/checks/test_check_stream.py index aee429c8b..b5367b2b0 100644 --- a/unit_tests/sources/declarative/checks/test_check_stream.py +++ b/unit_tests/sources/declarative/checks/test_check_stream.py @@ -8,6 +8,7 @@ import pytest import requests + from airbyte_cdk.sources.declarative.checks.check_stream import CheckStream from airbyte_cdk.sources.streams.http import HttpStream diff --git a/unit_tests/sources/declarative/concurrency_level/test_concurrency_level.py b/unit_tests/sources/declarative/concurrency_level/test_concurrency_level.py index 5858b6801..3f3e04e57 100644 --- a/unit_tests/sources/declarative/concurrency_level/test_concurrency_level.py +++ b/unit_tests/sources/declarative/concurrency_level/test_concurrency_level.py @@ -3,6 +3,7 @@ from typing import Any, Mapping, Optional, Type, Union import pytest + from airbyte_cdk.sources.declarative.concurrency_level import ConcurrencyLevel diff --git a/unit_tests/sources/declarative/datetime/test_datetime_parser.py b/unit_tests/sources/declarative/datetime/test_datetime_parser.py index 6cbe59c73..7a1ba951b 100644 --- a/unit_tests/sources/declarative/datetime/test_datetime_parser.py +++ b/unit_tests/sources/declarative/datetime/test_datetime_parser.py @@ -5,6 +5,7 @@ import datetime import pytest + from airbyte_cdk.sources.declarative.datetime.datetime_parser import DatetimeParser diff --git a/unit_tests/sources/declarative/datetime/test_min_max_datetime.py b/unit_tests/sources/declarative/datetime/test_min_max_datetime.py index 848d673ba..1cc0e6014 100644 --- a/unit_tests/sources/declarative/datetime/test_min_max_datetime.py +++ b/unit_tests/sources/declarative/datetime/test_min_max_datetime.py @@ -5,6 +5,7 @@ import datetime import pytest + from airbyte_cdk.sources.declarative.datetime.min_max_datetime import MinMaxDatetime from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString diff --git a/unit_tests/sources/declarative/decoders/test_json_decoder.py b/unit_tests/sources/declarative/decoders/test_json_decoder.py index 8d4d22f7e..bb2dd0c9b 100644 --- a/unit_tests/sources/declarative/decoders/test_json_decoder.py +++ b/unit_tests/sources/declarative/decoders/test_json_decoder.py @@ -7,14 +7,15 @@ import pytest import requests + from airbyte_cdk import YamlDeclarativeSource from airbyte_cdk.models import SyncMode +from airbyte_cdk.sources.declarative.decoders import GzipJsonDecoder from airbyte_cdk.sources.declarative.decoders.json_decoder import JsonDecoder, JsonlDecoder from airbyte_cdk.sources.declarative.models import DeclarativeStream as DeclarativeStreamModel from airbyte_cdk.sources.declarative.parsers.model_to_component_factory import ( ModelToComponentFactory, ) -from airbyte_cdk.sources.declarative.decoders import GzipJsonDecoder @pytest.mark.parametrize( diff --git a/unit_tests/sources/declarative/decoders/test_pagination_decoder_decorator.py b/unit_tests/sources/declarative/decoders/test_pagination_decoder_decorator.py index 022482e75..728d7f38b 100644 --- a/unit_tests/sources/declarative/decoders/test_pagination_decoder_decorator.py +++ b/unit_tests/sources/declarative/decoders/test_pagination_decoder_decorator.py @@ -3,6 +3,7 @@ # import pytest import requests + from airbyte_cdk.sources.declarative.decoders import JsonDecoder, PaginationDecoderDecorator diff --git a/unit_tests/sources/declarative/decoders/test_xml_decoder.py b/unit_tests/sources/declarative/decoders/test_xml_decoder.py index c6295cffc..34db5f716 100644 --- a/unit_tests/sources/declarative/decoders/test_xml_decoder.py +++ b/unit_tests/sources/declarative/decoders/test_xml_decoder.py @@ -3,6 +3,7 @@ # import pytest import requests + from airbyte_cdk.sources.declarative.decoders import XmlDecoder diff --git a/unit_tests/sources/declarative/extractors/test_dpath_extractor.py b/unit_tests/sources/declarative/extractors/test_dpath_extractor.py index c5c40dd23..0d4d8a529 100644 --- a/unit_tests/sources/declarative/extractors/test_dpath_extractor.py +++ b/unit_tests/sources/declarative/extractors/test_dpath_extractor.py @@ -7,6 +7,7 @@ import pytest import requests + from airbyte_cdk import Decoder from airbyte_cdk.sources.declarative.decoders.json_decoder import ( IterableDecoder, diff --git a/unit_tests/sources/declarative/extractors/test_record_filter.py b/unit_tests/sources/declarative/extractors/test_record_filter.py index c4824c64c..4e97715ba 100644 --- a/unit_tests/sources/declarative/extractors/test_record_filter.py +++ b/unit_tests/sources/declarative/extractors/test_record_filter.py @@ -4,6 +4,7 @@ from typing import List, Mapping, Optional import pytest + from airbyte_cdk.sources.declarative.datetime import MinMaxDatetime from airbyte_cdk.sources.declarative.extractors.record_filter import ( ClientSideIncrementalRecordFilterDecorator, diff --git a/unit_tests/sources/declarative/extractors/test_record_selector.py b/unit_tests/sources/declarative/extractors/test_record_selector.py index a83586f7c..b7e9a3546 100644 --- a/unit_tests/sources/declarative/extractors/test_record_selector.py +++ b/unit_tests/sources/declarative/extractors/test_record_selector.py @@ -7,6 +7,7 @@ import pytest import requests + from airbyte_cdk.sources.declarative.decoders.json_decoder import JsonDecoder from airbyte_cdk.sources.declarative.extractors.dpath_extractor import DpathExtractor from airbyte_cdk.sources.declarative.extractors.record_filter import RecordFilter diff --git a/unit_tests/sources/declarative/extractors/test_response_to_file_extractor.py b/unit_tests/sources/declarative/extractors/test_response_to_file_extractor.py index 98251df61..3c1d5a0f4 100644 --- a/unit_tests/sources/declarative/extractors/test_response_to_file_extractor.py +++ b/unit_tests/sources/declarative/extractors/test_response_to_file_extractor.py @@ -8,6 +8,7 @@ import pytest import requests import requests_mock + from airbyte_cdk.sources.declarative.extractors import ResponseToFileExtractor diff --git a/unit_tests/sources/declarative/incremental/test_datetime_based_cursor.py b/unit_tests/sources/declarative/incremental/test_datetime_based_cursor.py index 7b651e253..880a582e3 100644 --- a/unit_tests/sources/declarative/incremental/test_datetime_based_cursor.py +++ b/unit_tests/sources/declarative/incremental/test_datetime_based_cursor.py @@ -6,6 +6,7 @@ import unittest import pytest + from airbyte_cdk.sources.declarative.datetime.min_max_datetime import MinMaxDatetime from airbyte_cdk.sources.declarative.incremental import DatetimeBasedCursor from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString diff --git a/unit_tests/sources/declarative/incremental/test_per_partition_cursor.py b/unit_tests/sources/declarative/incremental/test_per_partition_cursor.py index e1cd6d197..baf547493 100644 --- a/unit_tests/sources/declarative/incremental/test_per_partition_cursor.py +++ b/unit_tests/sources/declarative/incremental/test_per_partition_cursor.py @@ -6,6 +6,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.sources.declarative.incremental.declarative_cursor import DeclarativeCursor from airbyte_cdk.sources.declarative.incremental.per_partition_cursor import ( PerPartitionCursor, diff --git a/unit_tests/sources/declarative/incremental/test_per_partition_cursor_integration.py b/unit_tests/sources/declarative/incremental/test_per_partition_cursor_integration.py index 9d0216ffa..174d78ae9 100644 --- a/unit_tests/sources/declarative/incremental/test_per_partition_cursor_integration.py +++ b/unit_tests/sources/declarative/incremental/test_per_partition_cursor_integration.py @@ -5,6 +5,8 @@ import logging from unittest.mock import MagicMock, patch +from orjson import orjson + from airbyte_cdk.models import ( AirbyteStateBlob, AirbyteStateMessage, @@ -24,7 +26,6 @@ from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource from airbyte_cdk.sources.declarative.retrievers.simple_retriever import SimpleRetriever from airbyte_cdk.sources.types import Record -from orjson import orjson CURSOR_FIELD = "cursor_field" SYNC_MODE = SyncMode.incremental diff --git a/unit_tests/sources/declarative/incremental/test_resumable_full_refresh_cursor.py b/unit_tests/sources/declarative/incremental/test_resumable_full_refresh_cursor.py index 903214493..8d7bbc669 100644 --- a/unit_tests/sources/declarative/incremental/test_resumable_full_refresh_cursor.py +++ b/unit_tests/sources/declarative/incremental/test_resumable_full_refresh_cursor.py @@ -1,6 +1,7 @@ # Copyright (c) 2024 Airbyte, Inc., all rights reserved. import pytest + from airbyte_cdk.sources.declarative.incremental import ( ChildPartitionResumableFullRefreshCursor, ResumableFullRefreshCursor, diff --git a/unit_tests/sources/declarative/interpolation/test_filters.py b/unit_tests/sources/declarative/interpolation/test_filters.py index 82dd2bf15..02a61f5f6 100644 --- a/unit_tests/sources/declarative/interpolation/test_filters.py +++ b/unit_tests/sources/declarative/interpolation/test_filters.py @@ -5,6 +5,7 @@ import hashlib import pytest + from airbyte_cdk.sources.declarative.interpolation.jinja import JinjaInterpolation interpolation = JinjaInterpolation() diff --git a/unit_tests/sources/declarative/interpolation/test_interpolated_boolean.py b/unit_tests/sources/declarative/interpolation/test_interpolated_boolean.py index 015d45aa3..3cdb74933 100644 --- a/unit_tests/sources/declarative/interpolation/test_interpolated_boolean.py +++ b/unit_tests/sources/declarative/interpolation/test_interpolated_boolean.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean config = { diff --git a/unit_tests/sources/declarative/interpolation/test_interpolated_mapping.py b/unit_tests/sources/declarative/interpolation/test_interpolated_mapping.py index 87843915a..198e48947 100644 --- a/unit_tests/sources/declarative/interpolation/test_interpolated_mapping.py +++ b/unit_tests/sources/declarative/interpolation/test_interpolated_mapping.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import InterpolatedMapping diff --git a/unit_tests/sources/declarative/interpolation/test_interpolated_nested_mapping.py b/unit_tests/sources/declarative/interpolation/test_interpolated_nested_mapping.py index 809f368c9..1d5b4b92b 100644 --- a/unit_tests/sources/declarative/interpolation/test_interpolated_nested_mapping.py +++ b/unit_tests/sources/declarative/interpolation/test_interpolated_nested_mapping.py @@ -4,6 +4,7 @@ import dpath import pytest + from airbyte_cdk.sources.declarative.interpolation.interpolated_nested_mapping import ( InterpolatedNestedMapping, ) diff --git a/unit_tests/sources/declarative/interpolation/test_interpolated_string.py b/unit_tests/sources/declarative/interpolation/test_interpolated_string.py index f0f1a9952..8819aee5c 100644 --- a/unit_tests/sources/declarative/interpolation/test_interpolated_string.py +++ b/unit_tests/sources/declarative/interpolation/test_interpolated_string.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString config = {"field": "value"} diff --git a/unit_tests/sources/declarative/interpolation/test_jinja.py b/unit_tests/sources/declarative/interpolation/test_jinja.py index 7534e9294..1126520f9 100644 --- a/unit_tests/sources/declarative/interpolation/test_jinja.py +++ b/unit_tests/sources/declarative/interpolation/test_jinja.py @@ -5,11 +5,12 @@ import datetime import pytest -from airbyte_cdk import StreamSlice -from airbyte_cdk.sources.declarative.interpolation.jinja import JinjaInterpolation from freezegun import freeze_time from jinja2.exceptions import TemplateSyntaxError +from airbyte_cdk import StreamSlice +from airbyte_cdk.sources.declarative.interpolation.jinja import JinjaInterpolation + interpolation = JinjaInterpolation() diff --git a/unit_tests/sources/declarative/interpolation/test_macros.py b/unit_tests/sources/declarative/interpolation/test_macros.py index cd16bd9f6..4aa2a0c08 100644 --- a/unit_tests/sources/declarative/interpolation/test_macros.py +++ b/unit_tests/sources/declarative/interpolation/test_macros.py @@ -5,6 +5,7 @@ import datetime import pytest + from airbyte_cdk.sources.declarative.interpolation.macros import macros diff --git a/unit_tests/sources/declarative/migrations/test_legacy_to_per_partition_migration.py b/unit_tests/sources/declarative/migrations/test_legacy_to_per_partition_migration.py index 442e444a8..8e03d2268 100644 --- a/unit_tests/sources/declarative/migrations/test_legacy_to_per_partition_migration.py +++ b/unit_tests/sources/declarative/migrations/test_legacy_to_per_partition_migration.py @@ -5,6 +5,7 @@ from unittest.mock import MagicMock import pytest + from airbyte_cdk.sources.declarative.migrations.legacy_to_per_partition_state_migration import ( LegacyToPerPartitionStateMigration, ) @@ -13,15 +14,13 @@ CustomRetriever, DatetimeBasedCursor, DeclarativeStream, -) -from airbyte_cdk.sources.declarative.models import ( - LegacyToPerPartitionStateMigration as LegacyToPerPartitionStateMigrationModel, -) -from airbyte_cdk.sources.declarative.models import ( ParentStreamConfig, SimpleRetriever, SubstreamPartitionRouter, ) +from airbyte_cdk.sources.declarative.models import ( + LegacyToPerPartitionStateMigration as LegacyToPerPartitionStateMigrationModel, +) from airbyte_cdk.sources.declarative.parsers.manifest_component_transformer import ( ManifestComponentTransformer, ) diff --git a/unit_tests/sources/declarative/parsers/test_manifest_component_transformer.py b/unit_tests/sources/declarative/parsers/test_manifest_component_transformer.py index 3cd062732..67bf6b397 100644 --- a/unit_tests/sources/declarative/parsers/test_manifest_component_transformer.py +++ b/unit_tests/sources/declarative/parsers/test_manifest_component_transformer.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.parsers.manifest_component_transformer import ( ManifestComponentTransformer, ) diff --git a/unit_tests/sources/declarative/parsers/test_manifest_reference_resolver.py b/unit_tests/sources/declarative/parsers/test_manifest_reference_resolver.py index 36ae03cce..1fdbf2d55 100644 --- a/unit_tests/sources/declarative/parsers/test_manifest_reference_resolver.py +++ b/unit_tests/sources/declarative/parsers/test_manifest_reference_resolver.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.parsers.custom_exceptions import ( CircularReferenceException, UndefinedReferenceException, diff --git a/unit_tests/sources/declarative/parsers/test_model_to_component_factory.py b/unit_tests/sources/declarative/parsers/test_model_to_component_factory.py index d740ccdb9..3f8801e80 100644 --- a/unit_tests/sources/declarative/parsers/test_model_to_component_factory.py +++ b/unit_tests/sources/declarative/parsers/test_model_to_component_factory.py @@ -9,6 +9,7 @@ import freezegun import pendulum import pytest + from airbyte_cdk import AirbyteTracedException from airbyte_cdk.models import FailureType, Level from airbyte_cdk.sources.connector_state_manager import ConnectorStateManager diff --git a/unit_tests/sources/declarative/partition_routers/test_cartesian_product_partition_router.py b/unit_tests/sources/declarative/partition_routers/test_cartesian_product_partition_router.py index 697a06052..1d5981f7b 100644 --- a/unit_tests/sources/declarative/partition_routers/test_cartesian_product_partition_router.py +++ b/unit_tests/sources/declarative/partition_routers/test_cartesian_product_partition_router.py @@ -3,6 +3,7 @@ # import pytest as pytest + from airbyte_cdk.sources.declarative.datetime.min_max_datetime import MinMaxDatetime from airbyte_cdk.sources.declarative.incremental.datetime_based_cursor import DatetimeBasedCursor from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString diff --git a/unit_tests/sources/declarative/partition_routers/test_list_partition_router.py b/unit_tests/sources/declarative/partition_routers/test_list_partition_router.py index baa3ad8dd..0270422bd 100644 --- a/unit_tests/sources/declarative/partition_routers/test_list_partition_router.py +++ b/unit_tests/sources/declarative/partition_routers/test_list_partition_router.py @@ -3,6 +3,7 @@ # import pytest as pytest + from airbyte_cdk.sources.declarative.partition_routers.list_partition_router import ( ListPartitionRouter, ) diff --git a/unit_tests/sources/declarative/partition_routers/test_parent_state_stream.py b/unit_tests/sources/declarative/partition_routers/test_parent_state_stream.py index 81de362d4..495ef7345 100644 --- a/unit_tests/sources/declarative/partition_routers/test_parent_state_stream.py +++ b/unit_tests/sources/declarative/partition_routers/test_parent_state_stream.py @@ -6,6 +6,8 @@ import pytest import requests_mock +from orjson import orjson + from airbyte_cdk.models import ( AirbyteMessage, AirbyteStateBlob, @@ -20,7 +22,6 @@ SyncMode, ) from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource -from orjson import orjson SUBSTREAM_MANIFEST: MutableMapping[str, Any] = { "version": "0.51.42", diff --git a/unit_tests/sources/declarative/partition_routers/test_substream_partition_router.py b/unit_tests/sources/declarative/partition_routers/test_substream_partition_router.py index f42bd5548..8a5738780 100644 --- a/unit_tests/sources/declarative/partition_routers/test_substream_partition_router.py +++ b/unit_tests/sources/declarative/partition_routers/test_substream_partition_router.py @@ -7,6 +7,7 @@ from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Union import pytest as pytest + from airbyte_cdk.models import AirbyteMessage, AirbyteRecordMessage, SyncMode, Type from airbyte_cdk.sources.declarative.declarative_stream import DeclarativeStream from airbyte_cdk.sources.declarative.incremental import ( diff --git a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_constant_backoff.py b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_constant_backoff.py index eb2ecc1d4..04d54951e 100644 --- a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_constant_backoff.py +++ b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_constant_backoff.py @@ -5,6 +5,7 @@ from unittest.mock import MagicMock import pytest + from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies.constant_backoff_strategy import ( ConstantBackoffStrategy, ) diff --git a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_exponential_backoff.py b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_exponential_backoff.py index 3e5b4c908..166afeab6 100644 --- a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_exponential_backoff.py +++ b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_exponential_backoff.py @@ -5,6 +5,7 @@ from unittest.mock import MagicMock import pytest + from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies.exponential_backoff_strategy import ( ExponentialBackoffStrategy, ) diff --git a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_header_helper.py b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_header_helper.py index 105b6bf50..9f4205f10 100644 --- a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_header_helper.py +++ b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_header_helper.py @@ -6,6 +6,7 @@ from unittest.mock import MagicMock import pytest + from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies.header_helper import ( get_numeric_value_from_header, ) diff --git a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_time_from_header.py b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_time_from_header.py index d224718a4..ba670f507 100644 --- a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_time_from_header.py +++ b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_time_from_header.py @@ -5,12 +5,13 @@ from unittest.mock import MagicMock import pytest +from requests import Response + from airbyte_cdk import AirbyteTracedException from airbyte_cdk.models import FailureType from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies.wait_time_from_header_backoff_strategy import ( WaitTimeFromHeaderBackoffStrategy, ) -from requests import Response SOME_BACKOFF_TIME = 60 _A_RETRY_HEADER = "retry-header" diff --git a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_until_time_from_header.py b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_until_time_from_header.py index 20dba620e..4c4c5a6f7 100644 --- a/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_until_time_from_header.py +++ b/unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_until_time_from_header.py @@ -7,6 +7,7 @@ import pytest import requests + from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies.wait_until_time_from_header_backoff_strategy import ( WaitUntilTimeFromHeaderBackoffStrategy, ) diff --git a/unit_tests/sources/declarative/requesters/error_handlers/test_composite_error_handler.py b/unit_tests/sources/declarative/requesters/error_handlers/test_composite_error_handler.py index 3d2f551cf..7a4e46ed3 100644 --- a/unit_tests/sources/declarative/requesters/error_handlers/test_composite_error_handler.py +++ b/unit_tests/sources/declarative/requesters/error_handlers/test_composite_error_handler.py @@ -6,6 +6,7 @@ import pytest import requests + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.declarative.requesters.error_handlers import HttpResponseFilter from airbyte_cdk.sources.declarative.requesters.error_handlers.composite_error_handler import ( diff --git a/unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py b/unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py index f97fa05f5..3b13fe130 100644 --- a/unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py +++ b/unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py @@ -6,6 +6,7 @@ import pytest import requests + from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies.constant_backoff_strategy import ( ConstantBackoffStrategy, ) diff --git a/unit_tests/sources/declarative/requesters/error_handlers/test_default_http_response_filter.py b/unit_tests/sources/declarative/requesters/error_handlers/test_default_http_response_filter.py index dc0c004a1..cddec68e4 100644 --- a/unit_tests/sources/declarative/requesters/error_handlers/test_default_http_response_filter.py +++ b/unit_tests/sources/declarative/requesters/error_handlers/test_default_http_response_filter.py @@ -5,6 +5,8 @@ from unittest.mock import MagicMock import pytest +from requests import RequestException, Response + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.declarative.requesters.error_handlers.default_http_response_filter import ( DefaultHttpResponseFilter, @@ -13,7 +15,6 @@ DEFAULT_ERROR_MAPPING, ) from airbyte_cdk.sources.streams.http.error_handlers.response_models import ResponseAction -from requests import RequestException, Response @pytest.mark.parametrize( diff --git a/unit_tests/sources/declarative/requesters/error_handlers/test_http_response_filter.py b/unit_tests/sources/declarative/requesters/error_handlers/test_http_response_filter.py index 1acc95f25..ecb9c7032 100644 --- a/unit_tests/sources/declarative/requesters/error_handlers/test_http_response_filter.py +++ b/unit_tests/sources/declarative/requesters/error_handlers/test_http_response_filter.py @@ -6,6 +6,7 @@ import pytest import requests + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.declarative.requesters.error_handlers import HttpResponseFilter from airbyte_cdk.sources.streams.http.error_handlers.response_models import ( diff --git a/unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py b/unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py index 4d2920ea2..83d46918d 100644 --- a/unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py +++ b/unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py @@ -6,6 +6,7 @@ import pytest import requests + from airbyte_cdk.sources.declarative.decoders.json_decoder import JsonDecoder from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean from airbyte_cdk.sources.declarative.requesters.paginators.strategies.cursor_pagination_strategy import ( diff --git a/unit_tests/sources/declarative/requesters/paginators/test_default_paginator.py b/unit_tests/sources/declarative/requesters/paginators/test_default_paginator.py index d02562b0a..1cd34c42f 100644 --- a/unit_tests/sources/declarative/requesters/paginators/test_default_paginator.py +++ b/unit_tests/sources/declarative/requesters/paginators/test_default_paginator.py @@ -7,6 +7,7 @@ import pytest import requests + from airbyte_cdk.sources.declarative.decoders import JsonDecoder, XmlDecoder from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean from airbyte_cdk.sources.declarative.requesters.paginators.default_paginator import ( diff --git a/unit_tests/sources/declarative/requesters/paginators/test_no_paginator.py b/unit_tests/sources/declarative/requesters/paginators/test_no_paginator.py index 12b81010f..92bcc55a2 100644 --- a/unit_tests/sources/declarative/requesters/paginators/test_no_paginator.py +++ b/unit_tests/sources/declarative/requesters/paginators/test_no_paginator.py @@ -3,6 +3,7 @@ # import requests + from airbyte_cdk.sources.declarative.requesters.paginators.no_pagination import NoPagination diff --git a/unit_tests/sources/declarative/requesters/paginators/test_offset_increment.py b/unit_tests/sources/declarative/requesters/paginators/test_offset_increment.py index 8c357349f..d443132ed 100644 --- a/unit_tests/sources/declarative/requesters/paginators/test_offset_increment.py +++ b/unit_tests/sources/declarative/requesters/paginators/test_offset_increment.py @@ -7,6 +7,7 @@ import pytest import requests + from airbyte_cdk.sources.declarative.requesters.paginators.strategies.offset_increment import ( OffsetIncrement, ) diff --git a/unit_tests/sources/declarative/requesters/paginators/test_page_increment.py b/unit_tests/sources/declarative/requesters/paginators/test_page_increment.py index 9ec994e23..56564f925 100644 --- a/unit_tests/sources/declarative/requesters/paginators/test_page_increment.py +++ b/unit_tests/sources/declarative/requesters/paginators/test_page_increment.py @@ -7,6 +7,7 @@ import pytest import requests + from airbyte_cdk.sources.declarative.requesters.paginators.strategies.page_increment import ( PageIncrement, ) diff --git a/unit_tests/sources/declarative/requesters/paginators/test_request_option.py b/unit_tests/sources/declarative/requesters/paginators/test_request_option.py index cef4fe873..69866773c 100644 --- a/unit_tests/sources/declarative/requesters/paginators/test_request_option.py +++ b/unit_tests/sources/declarative/requesters/paginators/test_request_option.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.requesters.request_option import ( RequestOption, RequestOptionType, diff --git a/unit_tests/sources/declarative/requesters/paginators/test_stop_condition.py b/unit_tests/sources/declarative/requesters/paginators/test_stop_condition.py index 201636f1a..88da84589 100644 --- a/unit_tests/sources/declarative/requesters/paginators/test_stop_condition.py +++ b/unit_tests/sources/declarative/requesters/paginators/test_stop_condition.py @@ -4,6 +4,8 @@ from unittest.mock import Mock, call +from pytest import fixture + from airbyte_cdk.sources.declarative.incremental.declarative_cursor import DeclarativeCursor from airbyte_cdk.sources.declarative.requesters.paginators.strategies.pagination_strategy import ( PaginationStrategy, @@ -14,7 +16,6 @@ StopConditionPaginationStrategyDecorator, ) from airbyte_cdk.sources.types import Record -from pytest import fixture ANY_RECORD = Mock() NO_RECORD = None diff --git a/unit_tests/sources/declarative/requesters/request_options/test_datetime_based_request_options_provider.py b/unit_tests/sources/declarative/requesters/request_options/test_datetime_based_request_options_provider.py index 7cbfa78d7..ec023dd99 100644 --- a/unit_tests/sources/declarative/requesters/request_options/test_datetime_based_request_options_provider.py +++ b/unit_tests/sources/declarative/requesters/request_options/test_datetime_based_request_options_provider.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.requesters.request_option import ( RequestOption, RequestOptionType, diff --git a/unit_tests/sources/declarative/requesters/request_options/test_interpolated_request_options_provider.py b/unit_tests/sources/declarative/requesters/request_options/test_interpolated_request_options_provider.py index 3e11bfa50..d244cfc4c 100644 --- a/unit_tests/sources/declarative/requesters/request_options/test_interpolated_request_options_provider.py +++ b/unit_tests/sources/declarative/requesters/request_options/test_interpolated_request_options_provider.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.requesters.request_options.interpolated_request_options_provider import ( InterpolatedRequestOptionsProvider, ) diff --git a/unit_tests/sources/declarative/requesters/test_http_job_repository.py b/unit_tests/sources/declarative/requesters/test_http_job_repository.py index aa2a13f71..06d16b38f 100644 --- a/unit_tests/sources/declarative/requesters/test_http_job_repository.py +++ b/unit_tests/sources/declarative/requesters/test_http_job_repository.py @@ -6,6 +6,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.sources.declarative.async_job.status import AsyncJobStatus from airbyte_cdk.sources.declarative.decoders import NoopDecoder from airbyte_cdk.sources.declarative.decoders.json_decoder import JsonDecoder diff --git a/unit_tests/sources/declarative/requesters/test_http_requester.py b/unit_tests/sources/declarative/requesters/test_http_requester.py index 1428319f3..28ea0cb9b 100644 --- a/unit_tests/sources/declarative/requesters/test_http_requester.py +++ b/unit_tests/sources/declarative/requesters/test_http_requester.py @@ -9,6 +9,8 @@ import pytest as pytest import requests +from requests import PreparedRequest + from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies import ( @@ -29,7 +31,6 @@ UserDefinedBackoffException, ) from airbyte_cdk.sources.types import Config -from requests import PreparedRequest @pytest.fixture diff --git a/unit_tests/sources/declarative/requesters/test_interpolated_request_input_provider.py b/unit_tests/sources/declarative/requesters/test_interpolated_request_input_provider.py index 8882e9181..6a332b528 100644 --- a/unit_tests/sources/declarative/requesters/test_interpolated_request_input_provider.py +++ b/unit_tests/sources/declarative/requesters/test_interpolated_request_input_provider.py @@ -3,6 +3,7 @@ # import pytest as pytest + from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import InterpolatedMapping from airbyte_cdk.sources.declarative.requesters.request_options.interpolated_request_input_provider import ( InterpolatedRequestInputProvider, diff --git a/unit_tests/sources/declarative/retrievers/test_simple_retriever.py b/unit_tests/sources/declarative/retrievers/test_simple_retriever.py index d2eb2d152..cb7037772 100644 --- a/unit_tests/sources/declarative/retrievers/test_simple_retriever.py +++ b/unit_tests/sources/declarative/retrievers/test_simple_retriever.py @@ -7,6 +7,7 @@ import pytest import requests + from airbyte_cdk import YamlDeclarativeSource from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Level, SyncMode, Type from airbyte_cdk.sources.declarative.auth.declarative_authenticator import NoAuth diff --git a/unit_tests/sources/declarative/schema/test_default_schema_loader.py b/unit_tests/sources/declarative/schema/test_default_schema_loader.py index 38e617f91..6e835959e 100644 --- a/unit_tests/sources/declarative/schema/test_default_schema_loader.py +++ b/unit_tests/sources/declarative/schema/test_default_schema_loader.py @@ -5,6 +5,7 @@ from unittest.mock import MagicMock import pytest + from airbyte_cdk.sources.declarative.schema import DefaultSchemaLoader diff --git a/unit_tests/sources/declarative/schema/test_inline_schema_loader.py b/unit_tests/sources/declarative/schema/test_inline_schema_loader.py index ad44ee334..e5d7071f9 100644 --- a/unit_tests/sources/declarative/schema/test_inline_schema_loader.py +++ b/unit_tests/sources/declarative/schema/test_inline_schema_loader.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.declarative.schema import InlineSchemaLoader diff --git a/unit_tests/sources/declarative/schema/test_json_file_schema_loader.py b/unit_tests/sources/declarative/schema/test_json_file_schema_loader.py index a53a88a9b..840f2cd59 100644 --- a/unit_tests/sources/declarative/schema/test_json_file_schema_loader.py +++ b/unit_tests/sources/declarative/schema/test_json_file_schema_loader.py @@ -4,6 +4,7 @@ from unittest.mock import patch import pytest + from airbyte_cdk.sources.declarative.schema.json_file_schema_loader import ( JsonFileSchemaLoader, _default_file_path, diff --git a/unit_tests/sources/declarative/spec/test_spec.py b/unit_tests/sources/declarative/spec/test_spec.py index 8b924cb42..aaf35e4a1 100644 --- a/unit_tests/sources/declarative/spec/test_spec.py +++ b/unit_tests/sources/declarative/spec/test_spec.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.models import AdvancedAuth, AuthFlowType, ConnectorSpecification from airbyte_cdk.sources.declarative.models.declarative_component_schema import AuthFlow from airbyte_cdk.sources.declarative.spec.spec import Spec diff --git a/unit_tests/sources/declarative/test_concurrent_declarative_source.py b/unit_tests/sources/declarative/test_concurrent_declarative_source.py index bc97b2c55..f9f89fae6 100644 --- a/unit_tests/sources/declarative/test_concurrent_declarative_source.py +++ b/unit_tests/sources/declarative/test_concurrent_declarative_source.py @@ -10,6 +10,8 @@ import freezegun import isodate import pendulum +from deprecated.classic import deprecated + from airbyte_cdk.models import ( AirbyteMessage, AirbyteRecordMessage, @@ -38,7 +40,6 @@ from airbyte_cdk.sources.types import Record, StreamSlice from airbyte_cdk.test.mock_http import HttpMocker, HttpRequest, HttpResponse from airbyte_cdk.utils import AirbyteTracedException -from deprecated.classic import deprecated _CONFIG = {"start_date": "2024-07-01T00:00:00.000Z"} diff --git a/unit_tests/sources/declarative/test_declarative_stream.py b/unit_tests/sources/declarative/test_declarative_stream.py index f34fd1371..747b73840 100644 --- a/unit_tests/sources/declarative/test_declarative_stream.py +++ b/unit_tests/sources/declarative/test_declarative_stream.py @@ -5,6 +5,7 @@ from unittest.mock import MagicMock import pytest + from airbyte_cdk.models import ( AirbyteLogMessage, AirbyteMessage, diff --git a/unit_tests/sources/declarative/test_manifest_declarative_source.py b/unit_tests/sources/declarative/test_manifest_declarative_source.py index defbe1275..1f4b6df56 100644 --- a/unit_tests/sources/declarative/test_manifest_declarative_source.py +++ b/unit_tests/sources/declarative/test_manifest_declarative_source.py @@ -14,6 +14,8 @@ import pytest import requests import yaml +from jsonschema.exceptions import ValidationError + from airbyte_cdk.models import ( AirbyteLogMessage, AirbyteMessage, @@ -28,7 +30,6 @@ from airbyte_cdk.sources.declarative.declarative_stream import DeclarativeStream from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource from airbyte_cdk.sources.declarative.retrievers.simple_retriever import SimpleRetriever -from jsonschema.exceptions import ValidationError logger = logging.getLogger("airbyte") diff --git a/unit_tests/sources/declarative/test_types.py b/unit_tests/sources/declarative/test_types.py index 1a15dcfac..b36ce9a2e 100644 --- a/unit_tests/sources/declarative/test_types.py +++ b/unit_tests/sources/declarative/test_types.py @@ -1,6 +1,7 @@ # Copyright (c) 2023 Airbyte, Inc., all rights reserved. import pytest + from airbyte_cdk.sources.types import StreamSlice diff --git a/unit_tests/sources/declarative/test_yaml_declarative_source.py b/unit_tests/sources/declarative/test_yaml_declarative_source.py index fc35f5b3d..67f198eb2 100644 --- a/unit_tests/sources/declarative/test_yaml_declarative_source.py +++ b/unit_tests/sources/declarative/test_yaml_declarative_source.py @@ -7,9 +7,10 @@ import tempfile import pytest +from yaml.parser import ParserError + from airbyte_cdk.sources.declarative.parsers.custom_exceptions import UndefinedReferenceException from airbyte_cdk.sources.declarative.yaml_declarative_source import YamlDeclarativeSource -from yaml.parser import ParserError logger = logging.getLogger("airbyte") diff --git a/unit_tests/sources/declarative/transformations/test_add_fields.py b/unit_tests/sources/declarative/transformations/test_add_fields.py index b598e7bc0..507f60abc 100644 --- a/unit_tests/sources/declarative/transformations/test_add_fields.py +++ b/unit_tests/sources/declarative/transformations/test_add_fields.py @@ -5,6 +5,7 @@ from typing import Any, List, Mapping, Optional, Tuple import pytest + from airbyte_cdk.sources.declarative.transformations import AddFields from airbyte_cdk.sources.declarative.transformations.add_fields import AddedFieldDefinition from airbyte_cdk.sources.types import FieldPointer diff --git a/unit_tests/sources/declarative/transformations/test_remove_fields.py b/unit_tests/sources/declarative/transformations/test_remove_fields.py index 4638b7ea2..3bbc916b3 100644 --- a/unit_tests/sources/declarative/transformations/test_remove_fields.py +++ b/unit_tests/sources/declarative/transformations/test_remove_fields.py @@ -5,6 +5,7 @@ from typing import Any, List, Mapping import pytest + from airbyte_cdk.sources.declarative.transformations import RemoveFields from airbyte_cdk.sources.types import FieldPointer diff --git a/unit_tests/sources/file_based/config/test_abstract_file_based_spec.py b/unit_tests/sources/file_based/config/test_abstract_file_based_spec.py index 84de3ad6a..ec37567a8 100644 --- a/unit_tests/sources/file_based/config/test_abstract_file_based_spec.py +++ b/unit_tests/sources/file_based/config/test_abstract_file_based_spec.py @@ -5,13 +5,14 @@ from typing import Type import pytest +from jsonschema import ValidationError, validate +from pydantic.v1 import BaseModel + from airbyte_cdk.sources.file_based.config.file_based_stream_config import ( AvroFormat, CsvFormat, ParquetFormat, ) -from jsonschema import ValidationError, validate -from pydantic.v1 import BaseModel @pytest.mark.parametrize( diff --git a/unit_tests/sources/file_based/config/test_csv_format.py b/unit_tests/sources/file_based/config/test_csv_format.py index ace9e0344..919e0f6c4 100644 --- a/unit_tests/sources/file_based/config/test_csv_format.py +++ b/unit_tests/sources/file_based/config/test_csv_format.py @@ -5,13 +5,14 @@ import unittest import pytest +from pydantic.v1.error_wrappers import ValidationError + from airbyte_cdk.sources.file_based.config.csv_format import ( CsvFormat, CsvHeaderAutogenerated, CsvHeaderFromCsv, CsvHeaderUserProvided, ) -from pydantic.v1.error_wrappers import ValidationError class CsvHeaderDefinitionTest(unittest.TestCase): diff --git a/unit_tests/sources/file_based/config/test_file_based_stream_config.py b/unit_tests/sources/file_based/config/test_file_based_stream_config.py index addc72234..4c6c9d02f 100644 --- a/unit_tests/sources/file_based/config/test_file_based_stream_config.py +++ b/unit_tests/sources/file_based/config/test_file_based_stream_config.py @@ -5,11 +5,12 @@ from typing import Any, Mapping, Type import pytest as pytest +from pydantic.v1.error_wrappers import ValidationError + from airbyte_cdk.sources.file_based.config.file_based_stream_config import ( CsvFormat, FileBasedStreamConfig, ) -from pydantic.v1.error_wrappers import ValidationError @pytest.mark.parametrize( diff --git a/unit_tests/sources/file_based/file_types/test_avro_parser.py b/unit_tests/sources/file_based/file_types/test_avro_parser.py index 2c52f9f84..ca9d2dfad 100644 --- a/unit_tests/sources/file_based/file_types/test_avro_parser.py +++ b/unit_tests/sources/file_based/file_types/test_avro_parser.py @@ -6,6 +6,7 @@ import uuid import pytest + from airbyte_cdk.sources.file_based.config.avro_format import AvroFormat from airbyte_cdk.sources.file_based.file_types import AvroParser diff --git a/unit_tests/sources/file_based/file_types/test_csv_parser.py b/unit_tests/sources/file_based/file_types/test_csv_parser.py index 295c4da6f..0b49dd66d 100644 --- a/unit_tests/sources/file_based/file_types/test_csv_parser.py +++ b/unit_tests/sources/file_based/file_types/test_csv_parser.py @@ -13,6 +13,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.file_based.config.csv_format import ( DEFAULT_FALSE_VALUES, diff --git a/unit_tests/sources/file_based/file_types/test_excel_parser.py b/unit_tests/sources/file_based/file_types/test_excel_parser.py index aac74be90..f744e9e8a 100644 --- a/unit_tests/sources/file_based/file_types/test_excel_parser.py +++ b/unit_tests/sources/file_based/file_types/test_excel_parser.py @@ -9,6 +9,7 @@ import pandas as pd import pytest + from airbyte_cdk.sources.file_based.config.file_based_stream_config import ( ExcelFormat, FileBasedStreamConfig, diff --git a/unit_tests/sources/file_based/file_types/test_jsonl_parser.py b/unit_tests/sources/file_based/file_types/test_jsonl_parser.py index cf9241312..e2d87c9d9 100644 --- a/unit_tests/sources/file_based/file_types/test_jsonl_parser.py +++ b/unit_tests/sources/file_based/file_types/test_jsonl_parser.py @@ -9,6 +9,7 @@ from unittest.mock import MagicMock, Mock import pytest + from airbyte_cdk.sources.file_based.exceptions import RecordParseError from airbyte_cdk.sources.file_based.file_based_stream_reader import AbstractFileBasedStreamReader from airbyte_cdk.sources.file_based.file_types import JsonlParser diff --git a/unit_tests/sources/file_based/file_types/test_parquet_parser.py b/unit_tests/sources/file_based/file_types/test_parquet_parser.py index e0c06e865..17814813b 100644 --- a/unit_tests/sources/file_based/file_types/test_parquet_parser.py +++ b/unit_tests/sources/file_based/file_types/test_parquet_parser.py @@ -10,6 +10,8 @@ import pyarrow as pa import pytest +from pyarrow import Scalar + from airbyte_cdk.sources.file_based.config.csv_format import CsvFormat from airbyte_cdk.sources.file_based.config.file_based_stream_config import ( FileBasedStreamConfig, @@ -19,7 +21,6 @@ from airbyte_cdk.sources.file_based.config.parquet_format import ParquetFormat from airbyte_cdk.sources.file_based.file_types import ParquetParser from airbyte_cdk.sources.file_based.remote_file import RemoteFile -from pyarrow import Scalar _default_parquet_format = ParquetFormat() _decimal_as_float_parquet_format = ParquetFormat(decimal_as_float=True) diff --git a/unit_tests/sources/file_based/file_types/test_unstructured_parser.py b/unit_tests/sources/file_based/file_types/test_unstructured_parser.py index ea4e091a7..374a02eed 100644 --- a/unit_tests/sources/file_based/file_types/test_unstructured_parser.py +++ b/unit_tests/sources/file_based/file_types/test_unstructured_parser.py @@ -9,6 +9,9 @@ import pytest import requests +from unstructured.documents.elements import ElementMetadata, Formula, ListItem, Text, Title +from unstructured.file_utils.filetype import FileType + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.file_based.config.file_based_stream_config import FileBasedStreamConfig from airbyte_cdk.sources.file_based.config.unstructured_format import ( @@ -20,8 +23,6 @@ from airbyte_cdk.sources.file_based.file_types import UnstructuredParser from airbyte_cdk.sources.file_based.remote_file import RemoteFile from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from unstructured.documents.elements import ElementMetadata, Formula, ListItem, Text, Title -from unstructured.file_utils.filetype import FileType FILE_URI = "path/to/file.xyz" diff --git a/unit_tests/sources/file_based/in_memory_files_source.py b/unit_tests/sources/file_based/in_memory_files_source.py index 1a6ef55ba..f3e3a90e2 100644 --- a/unit_tests/sources/file_based/in_memory_files_source.py +++ b/unit_tests/sources/file_based/in_memory_files_source.py @@ -16,6 +16,9 @@ import pandas as pd import pyarrow as pa import pyarrow.parquet as pq +from avro import datafile +from pydantic.v1 import AnyUrl + from airbyte_cdk.models import ConfiguredAirbyteCatalog, ConfiguredAirbyteCatalogSerializer from airbyte_cdk.sources.file_based.availability_strategy import ( AbstractFileBasedAvailabilityStrategy, @@ -42,8 +45,6 @@ DefaultFileBasedCursor, ) from airbyte_cdk.sources.source import TState -from avro import datafile -from pydantic.v1 import AnyUrl class InMemoryFilesSource(FileBasedSource): diff --git a/unit_tests/sources/file_based/scenarios/parquet_scenarios.py b/unit_tests/sources/file_based/scenarios/parquet_scenarios.py index 5ddb8468b..f90acb242 100644 --- a/unit_tests/sources/file_based/scenarios/parquet_scenarios.py +++ b/unit_tests/sources/file_based/scenarios/parquet_scenarios.py @@ -6,6 +6,7 @@ import decimal import pyarrow as pa + from airbyte_cdk.utils.traced_exception import AirbyteTracedException from unit_tests.sources.file_based.in_memory_files_source import TemporaryParquetFilesStreamReader from unit_tests.sources.file_based.scenarios.file_based_source_builder import FileBasedSourceBuilder diff --git a/unit_tests/sources/file_based/scenarios/unstructured_scenarios.py b/unit_tests/sources/file_based/scenarios/unstructured_scenarios.py index c8d3dae9a..c0db46e7a 100644 --- a/unit_tests/sources/file_based/scenarios/unstructured_scenarios.py +++ b/unit_tests/sources/file_based/scenarios/unstructured_scenarios.py @@ -4,6 +4,7 @@ import base64 import nltk + from airbyte_cdk.utils.traced_exception import AirbyteTracedException from unit_tests.sources.file_based.scenarios.file_based_source_builder import FileBasedSourceBuilder from unit_tests.sources.file_based.scenarios.scenario_builder import TestScenarioBuilder diff --git a/unit_tests/sources/file_based/schema_validation_policies/test_default_schema_validation_policy.py b/unit_tests/sources/file_based/schema_validation_policies/test_default_schema_validation_policy.py index 9cbf33e53..ab4e87919 100644 --- a/unit_tests/sources/file_based/schema_validation_policies/test_default_schema_validation_policy.py +++ b/unit_tests/sources/file_based/schema_validation_policies/test_default_schema_validation_policy.py @@ -5,6 +5,7 @@ from typing import Any, Mapping import pytest + from airbyte_cdk.sources.file_based.config.file_based_stream_config import ValidationPolicy from airbyte_cdk.sources.file_based.exceptions import StopSyncPerValidationPolicy from airbyte_cdk.sources.file_based.schema_validation_policies import ( diff --git a/unit_tests/sources/file_based/stream/concurrent/test_adapters.py b/unit_tests/sources/file_based/stream/concurrent/test_adapters.py index aea439735..675e30baa 100644 --- a/unit_tests/sources/file_based/stream/concurrent/test_adapters.py +++ b/unit_tests/sources/file_based/stream/concurrent/test_adapters.py @@ -7,6 +7,8 @@ from unittest.mock import MagicMock, Mock import pytest +from freezegun import freeze_time + from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, AirbyteStream, Level, SyncMode from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources.file_based.availability_strategy import ( @@ -32,7 +34,6 @@ from airbyte_cdk.sources.streams.concurrent.partitions.record import Record from airbyte_cdk.sources.utils.slice_logger import SliceLogger from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer -from freezegun import freeze_time _ANY_SYNC_MODE = SyncMode.full_refresh _ANY_STATE = {"state_key": "state_value"} diff --git a/unit_tests/sources/file_based/stream/concurrent/test_file_based_concurrent_cursor.py b/unit_tests/sources/file_based/stream/concurrent/test_file_based_concurrent_cursor.py index 4f4d0b5fa..2c8b74ea5 100644 --- a/unit_tests/sources/file_based/stream/concurrent/test_file_based_concurrent_cursor.py +++ b/unit_tests/sources/file_based/stream/concurrent/test_file_based_concurrent_cursor.py @@ -6,13 +6,14 @@ from unittest.mock import MagicMock import pytest +from freezegun import freeze_time + from airbyte_cdk.models import AirbyteStateMessage, SyncMode from airbyte_cdk.sources.connector_state_manager import ConnectorStateManager from airbyte_cdk.sources.file_based.remote_file import RemoteFile from airbyte_cdk.sources.file_based.stream.concurrent.adapters import FileBasedStreamPartition from airbyte_cdk.sources.file_based.stream.concurrent.cursor import FileBasedConcurrentCursor from airbyte_cdk.sources.streams.concurrent.cursor import CursorField -from freezegun import freeze_time DATE_TIME_FORMAT = FileBasedConcurrentCursor.DATE_TIME_FORMAT MOCK_DAYS_TO_SYNC_IF_HISTORY_IS_FULL = 3 diff --git a/unit_tests/sources/file_based/stream/test_default_file_based_cursor.py b/unit_tests/sources/file_based/stream/test_default_file_based_cursor.py index 6cd3e20b7..afd81eeeb 100644 --- a/unit_tests/sources/file_based/stream/test_default_file_based_cursor.py +++ b/unit_tests/sources/file_based/stream/test_default_file_based_cursor.py @@ -7,6 +7,8 @@ from unittest.mock import MagicMock import pytest +from freezegun import freeze_time + from airbyte_cdk.sources.file_based.config.csv_format import CsvFormat from airbyte_cdk.sources.file_based.config.file_based_stream_config import ( FileBasedStreamConfig, @@ -16,7 +18,6 @@ from airbyte_cdk.sources.file_based.stream.cursor.default_file_based_cursor import ( DefaultFileBasedCursor, ) -from freezegun import freeze_time @pytest.mark.parametrize( diff --git a/unit_tests/sources/file_based/stream/test_default_file_based_stream.py b/unit_tests/sources/file_based/stream/test_default_file_based_stream.py index 8eea01d65..a7bde7755 100644 --- a/unit_tests/sources/file_based/stream/test_default_file_based_stream.py +++ b/unit_tests/sources/file_based/stream/test_default_file_based_stream.py @@ -10,6 +10,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Level from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources.file_based.availability_strategy import ( diff --git a/unit_tests/sources/file_based/test_file_based_scenarios.py b/unit_tests/sources/file_based/test_file_based_scenarios.py index a930192fe..278dcf1ac 100644 --- a/unit_tests/sources/file_based/test_file_based_scenarios.py +++ b/unit_tests/sources/file_based/test_file_based_scenarios.py @@ -6,8 +6,9 @@ import pytest from _pytest.capture import CaptureFixture -from airbyte_cdk.sources.abstract_source import AbstractSource from freezegun import freeze_time + +from airbyte_cdk.sources.abstract_source import AbstractSource from unit_tests.sources.file_based.scenarios.avro_scenarios import ( avro_all_types_scenario, avro_file_with_double_as_number_scenario, diff --git a/unit_tests/sources/file_based/test_file_based_stream_reader.py b/unit_tests/sources/file_based/test_file_based_stream_reader.py index 66729af43..196e207c8 100644 --- a/unit_tests/sources/file_based/test_file_based_stream_reader.py +++ b/unit_tests/sources/file_based/test_file_based_stream_reader.py @@ -7,10 +7,11 @@ from typing import Any, Dict, Iterable, List, Mapping, Optional, Set import pytest +from pydantic.v1 import AnyUrl + from airbyte_cdk.sources.file_based.config.abstract_file_based_spec import AbstractFileBasedSpec from airbyte_cdk.sources.file_based.file_based_stream_reader import AbstractFileBasedStreamReader from airbyte_cdk.sources.file_based.remote_file import RemoteFile -from pydantic.v1 import AnyUrl from unit_tests.sources.file_based.helpers import make_remote_files reader = AbstractFileBasedStreamReader diff --git a/unit_tests/sources/file_based/test_scenarios.py b/unit_tests/sources/file_based/test_scenarios.py index 14da71763..214dd0872 100644 --- a/unit_tests/sources/file_based/test_scenarios.py +++ b/unit_tests/sources/file_based/test_scenarios.py @@ -10,6 +10,7 @@ import pytest from _pytest.capture import CaptureFixture from _pytest.reports import ExceptionInfo + from airbyte_cdk.entrypoint import launch from airbyte_cdk.models import ( AirbyteAnalyticsTraceMessage, diff --git a/unit_tests/sources/file_based/test_schema_helpers.py b/unit_tests/sources/file_based/test_schema_helpers.py index 20bcadccc..b3d1a5220 100644 --- a/unit_tests/sources/file_based/test_schema_helpers.py +++ b/unit_tests/sources/file_based/test_schema_helpers.py @@ -5,6 +5,7 @@ from typing import Any, Mapping, Optional import pytest + from airbyte_cdk.sources.file_based.exceptions import ConfigValidationError, SchemaInferenceError from airbyte_cdk.sources.file_based.schema_helpers import ( ComparableType, diff --git a/unit_tests/sources/fixtures/source_test_fixture.py b/unit_tests/sources/fixtures/source_test_fixture.py index 620ad8c49..3c2183b68 100644 --- a/unit_tests/sources/fixtures/source_test_fixture.py +++ b/unit_tests/sources/fixtures/source_test_fixture.py @@ -8,6 +8,8 @@ from typing import Any, Iterable, List, Mapping, Optional, Tuple, Union import requests +from requests.auth import AuthBase + from airbyte_cdk.models import ( AirbyteStream, ConfiguredAirbyteCatalog, @@ -20,7 +22,6 @@ from airbyte_cdk.sources.streams import Stream from airbyte_cdk.sources.streams.http import HttpStream from airbyte_cdk.sources.streams.http.requests_native_auth import Oauth2Authenticator -from requests.auth import AuthBase class SourceTestFixture(AbstractSource): diff --git a/unit_tests/sources/message/test_repository.py b/unit_tests/sources/message/test_repository.py index 6d637a6bf..39afc2afb 100644 --- a/unit_tests/sources/message/test_repository.py +++ b/unit_tests/sources/message/test_repository.py @@ -5,6 +5,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.models import ( AirbyteControlConnectorConfigMessage, AirbyteControlMessage, diff --git a/unit_tests/sources/mock_server_tests/mock_source_fixture.py b/unit_tests/sources/mock_server_tests/mock_source_fixture.py index b5927219d..bc285a73d 100644 --- a/unit_tests/sources/mock_server_tests/mock_source_fixture.py +++ b/unit_tests/sources/mock_server_tests/mock_source_fixture.py @@ -9,13 +9,14 @@ import pendulum import requests +from requests import HTTPError + from airbyte_cdk.models import ConnectorSpecification, SyncMode from airbyte_cdk.sources import AbstractSource, Source from airbyte_cdk.sources.streams import CheckpointMixin, IncrementalMixin, Stream from airbyte_cdk.sources.streams.core import StreamData from airbyte_cdk.sources.streams.http import HttpStream from airbyte_cdk.sources.streams.http.availability_strategy import HttpAvailabilityStrategy -from requests import HTTPError class FixtureAvailabilityStrategy(HttpAvailabilityStrategy): diff --git a/unit_tests/sources/mock_server_tests/test_helpers/airbyte_message_assertions.py b/unit_tests/sources/mock_server_tests/test_helpers/airbyte_message_assertions.py index 4e2f00512..73e125d71 100644 --- a/unit_tests/sources/mock_server_tests/test_helpers/airbyte_message_assertions.py +++ b/unit_tests/sources/mock_server_tests/test_helpers/airbyte_message_assertions.py @@ -5,6 +5,7 @@ from typing import List import pytest + from airbyte_cdk.models import AirbyteMessage, AirbyteStreamStatus, Type diff --git a/unit_tests/sources/mock_server_tests/test_mock_server_abstract_source.py b/unit_tests/sources/mock_server_tests/test_mock_server_abstract_source.py index 0670b28c4..4e1d08f1a 100644 --- a/unit_tests/sources/mock_server_tests/test_mock_server_abstract_source.py +++ b/unit_tests/sources/mock_server_tests/test_mock_server_abstract_source.py @@ -7,6 +7,7 @@ from unittest import TestCase import freezegun + from airbyte_cdk.models import AirbyteStateBlob, ConfiguredAirbyteCatalog, SyncMode, Type from airbyte_cdk.test.catalog_builder import CatalogBuilder from airbyte_cdk.test.entrypoint_wrapper import read diff --git a/unit_tests/sources/mock_server_tests/test_resumable_full_refresh.py b/unit_tests/sources/mock_server_tests/test_resumable_full_refresh.py index b3e3c2acb..5ba58e384 100644 --- a/unit_tests/sources/mock_server_tests/test_resumable_full_refresh.py +++ b/unit_tests/sources/mock_server_tests/test_resumable_full_refresh.py @@ -7,6 +7,7 @@ from unittest import TestCase import freezegun + from airbyte_cdk.models import ( AirbyteStateBlob, AirbyteStreamStatus, diff --git a/unit_tests/sources/streams/checkpoint/test_checkpoint_reader.py b/unit_tests/sources/streams/checkpoint/test_checkpoint_reader.py index 35db9c24d..3739aa500 100644 --- a/unit_tests/sources/streams/checkpoint/test_checkpoint_reader.py +++ b/unit_tests/sources/streams/checkpoint/test_checkpoint_reader.py @@ -3,6 +3,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.sources.streams.checkpoint import ( CursorBasedCheckpointReader, FullRefreshCheckpointReader, diff --git a/unit_tests/sources/streams/checkpoint/test_substream_resumable_full_refresh_cursor.py b/unit_tests/sources/streams/checkpoint/test_substream_resumable_full_refresh_cursor.py index f023b038e..d0dcfc018 100644 --- a/unit_tests/sources/streams/checkpoint/test_substream_resumable_full_refresh_cursor.py +++ b/unit_tests/sources/streams/checkpoint/test_substream_resumable_full_refresh_cursor.py @@ -1,6 +1,7 @@ # Copyright (c) 2024 Airbyte, Inc., all rights reserved. import pytest + from airbyte_cdk.sources.streams.checkpoint.substream_resumable_full_refresh_cursor import ( SubstreamResumableFullRefreshCursor, ) diff --git a/unit_tests/sources/streams/concurrent/scenarios/test_concurrent_scenarios.py b/unit_tests/sources/streams/concurrent/scenarios/test_concurrent_scenarios.py index a0abaec02..5d278086c 100644 --- a/unit_tests/sources/streams/concurrent/scenarios/test_concurrent_scenarios.py +++ b/unit_tests/sources/streams/concurrent/scenarios/test_concurrent_scenarios.py @@ -7,6 +7,7 @@ import pytest from _pytest.capture import CaptureFixture from freezegun import freeze_time + from unit_tests.sources.file_based.scenarios.scenario_builder import TestScenario from unit_tests.sources.file_based.test_scenarios import verify_discover, verify_read from unit_tests.sources.streams.concurrent.scenarios.incremental_scenarios import ( diff --git a/unit_tests/sources/streams/concurrent/test_adapters.py b/unit_tests/sources/streams/concurrent/test_adapters.py index c7c168c0b..38aa06d87 100644 --- a/unit_tests/sources/streams/concurrent/test_adapters.py +++ b/unit_tests/sources/streams/concurrent/test_adapters.py @@ -6,6 +6,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, AirbyteStream, Level, SyncMode from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources.message import InMemoryMessageRepository diff --git a/unit_tests/sources/streams/concurrent/test_concurrent_read_processor.py b/unit_tests/sources/streams/concurrent/test_concurrent_read_processor.py index cf94f8f9f..0ef10241a 100644 --- a/unit_tests/sources/streams/concurrent/test_concurrent_read_processor.py +++ b/unit_tests/sources/streams/concurrent/test_concurrent_read_processor.py @@ -7,6 +7,7 @@ import freezegun import pytest + from airbyte_cdk.models import ( AirbyteLogMessage, AirbyteMessage, @@ -15,9 +16,11 @@ AirbyteStreamStatus, AirbyteStreamStatusTraceMessage, AirbyteTraceMessage, + StreamDescriptor, + SyncMode, + TraceType, ) from airbyte_cdk.models import Level as LogLevel -from airbyte_cdk.models import StreamDescriptor, SyncMode, TraceType from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources.concurrent_source.concurrent_read_processor import ConcurrentReadProcessor from airbyte_cdk.sources.concurrent_source.partition_generation_completed_sentinel import ( diff --git a/unit_tests/sources/streams/concurrent/test_cursor.py b/unit_tests/sources/streams/concurrent/test_cursor.py index 75ae05c38..a3e78aac3 100644 --- a/unit_tests/sources/streams/concurrent/test_cursor.py +++ b/unit_tests/sources/streams/concurrent/test_cursor.py @@ -10,6 +10,7 @@ import freezegun import pytest +from isodate import parse_duration from airbyte_cdk.sources.connector_state_manager import ConnectorStateManager from airbyte_cdk.sources.declarative.datetime.min_max_datetime import MinMaxDatetime @@ -30,7 +31,6 @@ IsoMillisConcurrentStreamStateConverter, ) from airbyte_cdk.sources.types import StreamSlice -from isodate import parse_duration _A_STREAM_NAME = "a stream name" _A_STREAM_NAMESPACE = "a stream namespace" diff --git a/unit_tests/sources/streams/concurrent/test_datetime_state_converter.py b/unit_tests/sources/streams/concurrent/test_datetime_state_converter.py index 322729739..ebcb3c20c 100644 --- a/unit_tests/sources/streams/concurrent/test_datetime_state_converter.py +++ b/unit_tests/sources/streams/concurrent/test_datetime_state_converter.py @@ -5,6 +5,7 @@ from datetime import datetime, timezone import pytest + from airbyte_cdk.sources.streams.concurrent.cursor import CursorField from airbyte_cdk.sources.streams.concurrent.state_converters.abstract_stream_state_converter import ( ConcurrencyCompatibleStateType, diff --git a/unit_tests/sources/streams/concurrent/test_partition_reader.py b/unit_tests/sources/streams/concurrent/test_partition_reader.py index 16d707197..b8d89cfe1 100644 --- a/unit_tests/sources/streams/concurrent/test_partition_reader.py +++ b/unit_tests/sources/streams/concurrent/test_partition_reader.py @@ -7,6 +7,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.sources.concurrent_source.stream_thread_exception import StreamThreadException from airbyte_cdk.sources.streams.concurrent.partition_reader import PartitionReader from airbyte_cdk.sources.streams.concurrent.partitions.partition import Partition diff --git a/unit_tests/sources/streams/http/error_handlers/test_default_backoff_strategy.py b/unit_tests/sources/streams/http/error_handlers/test_default_backoff_strategy.py index ee487e97c..99b626b43 100644 --- a/unit_tests/sources/streams/http/error_handlers/test_default_backoff_strategy.py +++ b/unit_tests/sources/streams/http/error_handlers/test_default_backoff_strategy.py @@ -3,6 +3,7 @@ from typing import Optional, Union import requests + from airbyte_cdk.sources.streams.http.error_handlers import BackoffStrategy, DefaultBackoffStrategy _ANY_ATTEMPT_COUNT = 123 diff --git a/unit_tests/sources/streams/http/error_handlers/test_http_status_error_handler.py b/unit_tests/sources/streams/http/error_handlers/test_http_status_error_handler.py index 355d20b80..97e71ee5a 100644 --- a/unit_tests/sources/streams/http/error_handlers/test_http_status_error_handler.py +++ b/unit_tests/sources/streams/http/error_handlers/test_http_status_error_handler.py @@ -5,6 +5,7 @@ import pytest import requests + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.streams.http.error_handlers import ( ErrorResolution, diff --git a/unit_tests/sources/streams/http/error_handlers/test_json_error_message_parser.py b/unit_tests/sources/streams/http/error_handlers/test_json_error_message_parser.py index fecaa13fc..19b53e822 100644 --- a/unit_tests/sources/streams/http/error_handlers/test_json_error_message_parser.py +++ b/unit_tests/sources/streams/http/error_handlers/test_json_error_message_parser.py @@ -4,6 +4,7 @@ import pytest import requests + from airbyte_cdk.sources.streams.http.error_handlers import JsonErrorMessageParser diff --git a/unit_tests/sources/streams/http/error_handlers/test_response_models.py b/unit_tests/sources/streams/http/error_handlers/test_response_models.py index 7d0eb776d..a6672d912 100644 --- a/unit_tests/sources/streams/http/error_handlers/test_response_models.py +++ b/unit_tests/sources/streams/http/error_handlers/test_response_models.py @@ -4,6 +4,7 @@ import requests import requests_mock + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.streams.http.error_handlers.response_models import ( ResponseAction, diff --git a/unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py b/unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py index c8345c42d..093c136e5 100644 --- a/unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py +++ b/unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py @@ -11,6 +11,9 @@ import pendulum import pytest import requests +from requests import Response +from requests.exceptions import RequestException + from airbyte_cdk.models import FailureType, OrchestratorType, Type from airbyte_cdk.sources.streams.http.requests_native_auth import ( BasicHttpAuthenticator, @@ -20,8 +23,6 @@ TokenAuthenticator, ) from airbyte_cdk.utils import AirbyteTracedException -from requests import Response -from requests.exceptions import RequestException LOGGER = logging.getLogger(__name__) diff --git a/unit_tests/sources/streams/http/test_availability_strategy.py b/unit_tests/sources/streams/http/test_availability_strategy.py index 766d0e357..bf49e09b4 100644 --- a/unit_tests/sources/streams/http/test_availability_strategy.py +++ b/unit_tests/sources/streams/http/test_availability_strategy.py @@ -9,6 +9,7 @@ import pytest import requests + from airbyte_cdk.sources.streams.http.availability_strategy import HttpAvailabilityStrategy from airbyte_cdk.sources.streams.http.http import HttpStream diff --git a/unit_tests/sources/streams/http/test_http.py b/unit_tests/sources/streams/http/test_http.py index 77a5fca3e..02f4517fc 100644 --- a/unit_tests/sources/streams/http/test_http.py +++ b/unit_tests/sources/streams/http/test_http.py @@ -11,6 +11,7 @@ import pytest import requests + from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Level, SyncMode, Type from airbyte_cdk.sources.streams import CheckpointMixin from airbyte_cdk.sources.streams.checkpoint import ResumableFullRefreshCursor diff --git a/unit_tests/sources/streams/http/test_http_client.py b/unit_tests/sources/streams/http/test_http_client.py index 4ef9e968b..fcdaf9a2b 100644 --- a/unit_tests/sources/streams/http/test_http_client.py +++ b/unit_tests/sources/streams/http/test_http_client.py @@ -6,6 +6,8 @@ import pytest import requests +from requests_cache import CachedRequest + from airbyte_cdk.models import FailureType from airbyte_cdk.sources.streams.call_rate import CachedLimiterSession, LimiterSession from airbyte_cdk.sources.streams.http import HttpClient @@ -22,7 +24,6 @@ ) from airbyte_cdk.sources.streams.http.requests_native_auth import TokenAuthenticator from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from requests_cache import CachedRequest def test_http_client(): diff --git a/unit_tests/sources/streams/test_call_rate.py b/unit_tests/sources/streams/test_call_rate.py index 518951cd2..894142fcb 100644 --- a/unit_tests/sources/streams/test_call_rate.py +++ b/unit_tests/sources/streams/test_call_rate.py @@ -9,6 +9,8 @@ import pytest import requests +from requests import Request + from airbyte_cdk.models import SyncMode from airbyte_cdk.sources.streams.call_rate import ( APIBudget, @@ -22,7 +24,6 @@ from airbyte_cdk.sources.streams.http import HttpStream from airbyte_cdk.sources.streams.http.requests_native_auth import TokenAuthenticator from airbyte_cdk.utils.constants import ENV_REQUEST_CACHE_PATH -from requests import Request class StubDummyHttpStream(HttpStream): diff --git a/unit_tests/sources/streams/test_stream_read.py b/unit_tests/sources/streams/test_stream_read.py index f079fe995..7c1b1a221 100644 --- a/unit_tests/sources/streams/test_stream_read.py +++ b/unit_tests/sources/streams/test_stream_read.py @@ -8,6 +8,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.models import ( AirbyteLogMessage, AirbyteMessage, diff --git a/unit_tests/sources/streams/test_streams_core.py b/unit_tests/sources/streams/test_streams_core.py index 9f21ebabb..3e0f59c12 100644 --- a/unit_tests/sources/streams/test_streams_core.py +++ b/unit_tests/sources/streams/test_streams_core.py @@ -8,6 +8,7 @@ import pytest import requests + from airbyte_cdk.models import AirbyteStream, SyncMode from airbyte_cdk.sources.streams import CheckpointMixin, Stream from airbyte_cdk.sources.streams.checkpoint import ( diff --git a/unit_tests/sources/streams/utils/test_stream_helper.py b/unit_tests/sources/streams/utils/test_stream_helper.py index 39b642cb1..2f1494a33 100644 --- a/unit_tests/sources/streams/utils/test_stream_helper.py +++ b/unit_tests/sources/streams/utils/test_stream_helper.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.sources.streams.http.availability_strategy import HttpAvailabilityStrategy diff --git a/unit_tests/sources/test_abstract_source.py b/unit_tests/sources/test_abstract_source.py index 2cc0db543..4ca7f7fb6 100644 --- a/unit_tests/sources/test_abstract_source.py +++ b/unit_tests/sources/test_abstract_source.py @@ -20,6 +20,8 @@ from unittest.mock import Mock import pytest +from pytest import fixture + from airbyte_cdk.models import ( AirbyteCatalog, AirbyteConnectionStatus, @@ -44,8 +46,8 @@ StreamDescriptor, SyncMode, TraceType, + Type, ) -from airbyte_cdk.models import Type from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources import AbstractSource from airbyte_cdk.sources.message import MessageRepository @@ -53,7 +55,6 @@ from airbyte_cdk.sources.utils.record_helper import stream_data_to_airbyte_message from airbyte_cdk.utils.airbyte_secrets_utils import update_secrets from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from pytest import fixture logger = logging.getLogger("airbyte") diff --git a/unit_tests/sources/test_config.py b/unit_tests/sources/test_config.py index 933bdc8f3..23177c683 100644 --- a/unit_tests/sources/test_config.py +++ b/unit_tests/sources/test_config.py @@ -4,9 +4,10 @@ from typing import List, Union -from airbyte_cdk.sources.config import BaseConfig from pydantic.v1 import BaseModel, Field +from airbyte_cdk.sources.config import BaseConfig + class InnerClass(BaseModel): field1: str diff --git a/unit_tests/sources/test_connector_state_manager.py b/unit_tests/sources/test_connector_state_manager.py index 9e53f2e6a..f3bfa48c0 100644 --- a/unit_tests/sources/test_connector_state_manager.py +++ b/unit_tests/sources/test_connector_state_manager.py @@ -6,6 +6,7 @@ from typing import List import pytest + from airbyte_cdk.models import ( AirbyteMessage, AirbyteStateBlob, diff --git a/unit_tests/sources/test_http_logger.py b/unit_tests/sources/test_http_logger.py index 29f73e692..d2491f710 100644 --- a/unit_tests/sources/test_http_logger.py +++ b/unit_tests/sources/test_http_logger.py @@ -4,6 +4,7 @@ import pytest import requests + from airbyte_cdk.sources.http_logger import format_http_message A_TITLE = "a title" diff --git a/unit_tests/sources/test_integration_source.py b/unit_tests/sources/test_integration_source.py index 1f86d1e70..39573fd35 100644 --- a/unit_tests/sources/test_integration_source.py +++ b/unit_tests/sources/test_integration_source.py @@ -10,6 +10,7 @@ import pytest import requests + from airbyte_cdk.entrypoint import launch from airbyte_cdk.utils import AirbyteTracedException from unit_tests.sources.fixtures.source_test_fixture import ( diff --git a/unit_tests/sources/test_source.py b/unit_tests/sources/test_source.py index c47b12a0b..60c1ecf57 100644 --- a/unit_tests/sources/test_source.py +++ b/unit_tests/sources/test_source.py @@ -9,6 +9,9 @@ from typing import Any, List, Mapping, MutableMapping, Optional, Tuple, Union import pytest +from orjson import orjson +from serpyco_rs import SchemaValidationError + from airbyte_cdk.models import ( AirbyteGlobalState, AirbyteStateBlob, @@ -26,8 +29,6 @@ from airbyte_cdk.sources.streams.core import Stream from airbyte_cdk.sources.streams.http.http import HttpStream from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer -from orjson import orjson -from serpyco_rs import SchemaValidationError class MockSource(Source): diff --git a/unit_tests/sources/test_source_read.py b/unit_tests/sources/test_source_read.py index a4878a8c4..a25f54a5a 100644 --- a/unit_tests/sources/test_source_read.py +++ b/unit_tests/sources/test_source_read.py @@ -6,6 +6,7 @@ from unittest.mock import Mock import freezegun + from airbyte_cdk.models import ( AirbyteMessage, AirbyteRecordMessage, diff --git a/unit_tests/sources/utils/test_record_helper.py b/unit_tests/sources/utils/test_record_helper.py index 71f882df1..94575a699 100644 --- a/unit_tests/sources/utils/test_record_helper.py +++ b/unit_tests/sources/utils/test_record_helper.py @@ -5,6 +5,7 @@ from unittest.mock import MagicMock import pytest + from airbyte_cdk.models import ( AirbyteLogMessage, AirbyteMessage, diff --git a/unit_tests/sources/utils/test_schema_helpers.py b/unit_tests/sources/utils/test_schema_helpers.py index 495c728eb..3ccb13a90 100644 --- a/unit_tests/sources/utils/test_schema_helpers.py +++ b/unit_tests/sources/utils/test_schema_helpers.py @@ -14,6 +14,9 @@ import jsonref import pytest +from pytest import fixture +from pytest import raises as pytest_raises + from airbyte_cdk.models import ConnectorSpecification, ConnectorSpecificationSerializer, FailureType from airbyte_cdk.sources.utils.schema_helpers import ( InternalConfig, @@ -21,8 +24,6 @@ check_config_against_spec_or_exit, ) from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from pytest import fixture -from pytest import raises as pytest_raises logger = logging.getLogger("airbyte") diff --git a/unit_tests/sources/utils/test_slice_logger.py b/unit_tests/sources/utils/test_slice_logger.py index 43b54050c..8ac5c5108 100644 --- a/unit_tests/sources/utils/test_slice_logger.py +++ b/unit_tests/sources/utils/test_slice_logger.py @@ -5,6 +5,7 @@ import logging import pytest + from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Level from airbyte_cdk.models import Type as MessageType from airbyte_cdk.sources.utils.slice_logger import AlwaysLogSliceLogger, DebugSliceLogger diff --git a/unit_tests/sources/utils/test_transform.py b/unit_tests/sources/utils/test_transform.py index 5d7aa1a6f..cfa0ebd0c 100644 --- a/unit_tests/sources/utils/test_transform.py +++ b/unit_tests/sources/utils/test_transform.py @@ -5,6 +5,7 @@ import json import pytest + from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer SIMPLE_SCHEMA = {"type": "object", "properties": {"value": {"type": "string"}}} diff --git a/unit_tests/test/mock_http/test_mocker.py b/unit_tests/test/mock_http/test_mocker.py index 0aff08b9c..4ff5afe01 100644 --- a/unit_tests/test/mock_http/test_mocker.py +++ b/unit_tests/test/mock_http/test_mocker.py @@ -4,6 +4,7 @@ import pytest import requests + from airbyte_cdk.test.mock_http import HttpMocker, HttpRequest, HttpResponse # Ensure that the scheme is HTTP as requests only partially supports other schemes diff --git a/unit_tests/test/mock_http/test_request.py b/unit_tests/test/mock_http/test_request.py index 15d1f667d..081879bf6 100644 --- a/unit_tests/test/mock_http/test_request.py +++ b/unit_tests/test/mock_http/test_request.py @@ -3,6 +3,7 @@ from unittest import TestCase import pytest + from airbyte_cdk.test.mock_http.request import ANY_QUERY_PARAMS, HttpRequest diff --git a/unit_tests/test/mock_http/test_response_builder.py b/unit_tests/test/mock_http/test_response_builder.py index cf7fbe50f..f5db2e73a 100644 --- a/unit_tests/test/mock_http/test_response_builder.py +++ b/unit_tests/test/mock_http/test_response_builder.py @@ -7,6 +7,7 @@ from unittest.mock import Mock import pytest + from airbyte_cdk.test.mock_http.response import HttpResponse from airbyte_cdk.test.mock_http.response_builder import ( FieldPath, diff --git a/unit_tests/test/test_entrypoint_wrapper.py b/unit_tests/test/test_entrypoint_wrapper.py index 3ead41f5f..fad3db953 100644 --- a/unit_tests/test/test_entrypoint_wrapper.py +++ b/unit_tests/test/test_entrypoint_wrapper.py @@ -7,6 +7,8 @@ from unittest import TestCase from unittest.mock import Mock, patch +from orjson import orjson + from airbyte_cdk.models import ( AirbyteAnalyticsTraceMessage, AirbyteCatalog, @@ -31,7 +33,6 @@ from airbyte_cdk.sources.abstract_source import AbstractSource from airbyte_cdk.test.entrypoint_wrapper import EntrypointOutput, discover, read from airbyte_cdk.test.state_builder import StateBuilder -from orjson import orjson def _a_state_message(stream_name: str, stream_state: Mapping[str, Any]) -> AirbyteMessage: diff --git a/unit_tests/test_config_observation.py b/unit_tests/test_config_observation.py index 677e318fa..71bccd628 100644 --- a/unit_tests/test_config_observation.py +++ b/unit_tests/test_config_observation.py @@ -6,6 +6,7 @@ import time import pytest + from airbyte_cdk.config_observation import ( ConfigObserver, ObservedDict, diff --git a/unit_tests/test_connector.py b/unit_tests/test_connector.py index bc7255b9c..cf10dba01 100644 --- a/unit_tests/test_connector.py +++ b/unit_tests/test_connector.py @@ -13,6 +13,7 @@ import pytest import yaml + from airbyte_cdk import Connector from airbyte_cdk.models import AirbyteConnectionStatus diff --git a/unit_tests/test_entrypoint.py b/unit_tests/test_entrypoint.py index 40781e89e..a5ffb21fb 100644 --- a/unit_tests/test_entrypoint.py +++ b/unit_tests/test_entrypoint.py @@ -13,6 +13,8 @@ import freezegun import pytest import requests +from orjson import orjson + from airbyte_cdk import AirbyteEntrypoint from airbyte_cdk import entrypoint as entrypoint_module from airbyte_cdk.models import ( @@ -44,7 +46,6 @@ from airbyte_cdk.sources import Source from airbyte_cdk.sources.connector_state_manager import HashableStreamDescriptor from airbyte_cdk.utils import AirbyteTracedException -from orjson import orjson class MockSource(Source): diff --git a/unit_tests/test_exception_handler.py b/unit_tests/test_exception_handler.py index ee4bfaa11..0edcf1247 100644 --- a/unit_tests/test_exception_handler.py +++ b/unit_tests/test_exception_handler.py @@ -8,6 +8,7 @@ import sys import pytest + from airbyte_cdk.exception_handler import assemble_uncaught_exception from airbyte_cdk.models import ( AirbyteErrorTraceMessage, diff --git a/unit_tests/test_logger.py b/unit_tests/test_logger.py index 3b6db8b89..68d32ed74 100644 --- a/unit_tests/test_logger.py +++ b/unit_tests/test_logger.py @@ -7,6 +7,7 @@ from typing import Dict import pytest + from airbyte_cdk.logger import AirbyteLogFormatter diff --git a/unit_tests/test_secure_logger.py b/unit_tests/test_secure_logger.py index 4f2abf901..0237091fe 100644 --- a/unit_tests/test_secure_logger.py +++ b/unit_tests/test_secure_logger.py @@ -8,6 +8,7 @@ from typing import Any, Iterable, Mapping, MutableMapping import pytest + from airbyte_cdk import AirbyteEntrypoint from airbyte_cdk.logger import AirbyteLogFormatter from airbyte_cdk.models import ( diff --git a/unit_tests/utils/test_datetime_format_inferrer.py b/unit_tests/utils/test_datetime_format_inferrer.py index 1e69f3d1b..7e21c1ccc 100644 --- a/unit_tests/utils/test_datetime_format_inferrer.py +++ b/unit_tests/utils/test_datetime_format_inferrer.py @@ -5,6 +5,7 @@ from typing import Dict, List import pytest + from airbyte_cdk.models import AirbyteRecordMessage from airbyte_cdk.utils.datetime_format_inferrer import DatetimeFormatInferrer diff --git a/unit_tests/utils/test_mapping_helpers.py b/unit_tests/utils/test_mapping_helpers.py index f5dc979e3..272ce9b7a 100644 --- a/unit_tests/utils/test_mapping_helpers.py +++ b/unit_tests/utils/test_mapping_helpers.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.utils.mapping_helpers import combine_mappings diff --git a/unit_tests/utils/test_message_utils.py b/unit_tests/utils/test_message_utils.py index e4567164d..65d6160f6 100644 --- a/unit_tests/utils/test_message_utils.py +++ b/unit_tests/utils/test_message_utils.py @@ -1,6 +1,7 @@ # Copyright (c) 2024 Airbyte, Inc., all rights reserved. import pytest + from airbyte_cdk.models import ( AirbyteControlConnectorConfigMessage, AirbyteControlMessage, diff --git a/unit_tests/utils/test_rate_limiting.py b/unit_tests/utils/test_rate_limiting.py index d4a781402..b54f411d2 100644 --- a/unit_tests/utils/test_rate_limiting.py +++ b/unit_tests/utils/test_rate_limiting.py @@ -3,9 +3,10 @@ # import pytest -from airbyte_cdk.sources.streams.http.rate_limiting import default_backoff_handler from requests import exceptions +from airbyte_cdk.sources.streams.http.rate_limiting import default_backoff_handler + def helper_with_exceptions(exception_type): raise exception_type diff --git a/unit_tests/utils/test_schema_inferrer.py b/unit_tests/utils/test_schema_inferrer.py index 535ff41d5..2c8813699 100644 --- a/unit_tests/utils/test_schema_inferrer.py +++ b/unit_tests/utils/test_schema_inferrer.py @@ -5,6 +5,7 @@ from typing import List, Mapping import pytest + from airbyte_cdk.models import AirbyteRecordMessage from airbyte_cdk.utils.schema_inferrer import SchemaInferrer, SchemaValidationException diff --git a/unit_tests/utils/test_secret_utils.py b/unit_tests/utils/test_secret_utils.py index 846d0e124..73c93e670 100644 --- a/unit_tests/utils/test_secret_utils.py +++ b/unit_tests/utils/test_secret_utils.py @@ -3,6 +3,7 @@ # import pytest + from airbyte_cdk.utils.airbyte_secrets_utils import ( add_to_secrets, filter_secrets, diff --git a/unit_tests/utils/test_traced_exception.py b/unit_tests/utils/test_traced_exception.py index 2d2bcc813..ac3c4318a 100644 --- a/unit_tests/utils/test_traced_exception.py +++ b/unit_tests/utils/test_traced_exception.py @@ -4,6 +4,8 @@ import pytest +from orjson import orjson + from airbyte_cdk.models import ( AirbyteErrorTraceMessage, AirbyteMessage, @@ -16,7 +18,6 @@ ) from airbyte_cdk.models import Type as MessageType from airbyte_cdk.utils.traced_exception import AirbyteTracedException -from orjson import orjson _AN_EXCEPTION = ValueError("An exception") _A_STREAM_DESCRIPTOR = StreamDescriptor(name="a_stream")