Skip to content

Commit

Permalink
feat: add sorting import option for ruff (#94)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Inzhyyants <[email protected]>
Co-authored-by: octavia-squidington-iii <[email protected]>
  • Loading branch information
artem1205 and octavia-squidington-iii authored Nov 28, 2024
1 parent a8b1b2b commit 5f0831e
Show file tree
Hide file tree
Showing 260 changed files with 415 additions and 161 deletions.
3 changes: 2 additions & 1 deletion airbyte_cdk/cli/source_declarative_manifest/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion airbyte_cdk/config_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions airbyte_cdk/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Any, Generic, Mapping, Optional, Protocol, TypeVar

import yaml

from airbyte_cdk.models import (
AirbyteConnectionStatus,
ConnectorSpecification,
Expand Down
2 changes: 1 addition & 1 deletion airbyte_cdk/connector_builder/connector_builder_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion airbyte_cdk/connector_builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion airbyte_cdk/destinations/destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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")

Expand Down
3 changes: 2 additions & 1 deletion airbyte_cdk/destinations/vector_db_based/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
Expand Down
9 changes: 5 additions & 4 deletions airbyte_cdk/destinations/vector_db_based/embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions airbyte_cdk/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")

Expand Down
3 changes: 2 additions & 1 deletion airbyte_cdk/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,7 +17,6 @@
Type,
)
from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets
from orjson import orjson

LOGGING_CONFIG = {
"version": 1,
Expand Down
3 changes: 2 additions & 1 deletion airbyte_cdk/models/airbyte_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *'


Expand Down
3 changes: 2 additions & 1 deletion airbyte_cdk/sources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions airbyte_cdk/sources/declarative/auth/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions airbyte_cdk/sources/declarative/auth/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any, List, Mapping

import dpath

from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator


Expand Down
3 changes: 2 additions & 1 deletion airbyte_cdk/sources/declarative/auth/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,7 +18,6 @@
RequestOptionType,
)
from airbyte_cdk.sources.types import Config
from cachetools import TTLCache, cached


@dataclass
Expand Down
5 changes: 3 additions & 2 deletions airbyte_cdk/sources/declarative/auth/token_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions airbyte_cdk/sources/declarative/concurrent_declarative_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -27,29 +27,31 @@
)
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,
)
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 (
AlwaysAvailableAvailabilityStrategy,
)
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]):
Expand Down
5 changes: 3 additions & 2 deletions airbyte_cdk/sources/declarative/decoders/json_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
1 change: 1 addition & 0 deletions airbyte_cdk/sources/declarative/decoders/noop_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Any, Generator, MutableMapping

import requests

from airbyte_cdk.sources.declarative.decoders import Decoder

logger = logging.getLogger("airbyte")
Expand Down
1 change: 1 addition & 0 deletions airbyte_cdk/sources/declarative/decoders/xml_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import requests
import xmltodict

from airbyte_cdk.sources.declarative.decoders.decoder import Decoder

logger = logging.getLogger("airbyte")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any, Iterable, Mapping, Optional

import requests

from airbyte_cdk.sources.types import Record, StreamSlice, StreamState


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 5f0831e

Please sign in to comment.