Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: resolve ruff lint issues #16

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion airbyte_cdk/models/airbyte_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
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 *
from airbyte_protocol_dataclasses.models import * # noqa: F403 # Allow '*'
from serpyco_rs.metadata import Alias

# ruff: noqa: F405 # ignore fuzzy import issues with 'import *'


@dataclass
class AirbyteStateBlob:
Expand Down
2 changes: 1 addition & 1 deletion airbyte_cdk/models/well_known_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#

from airbyte_protocol_dataclasses.models.well_known_types import *
from airbyte_protocol_dataclasses.models.well_known_types import * # noqa: F403 # Allow '*'
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MinMaxDatetime:
parameters: InitVar[Mapping[str, Any]]
# datetime_format is a unique case where we inherit it from the parent if it is not specified before using the default value
# which is why we need dedicated getter/setter methods and private dataclass field
datetime_format: str = ""
datetime_format: str
_datetime_format: str = field(init=False, repr=False, default="")
min_datetime: Union[InterpolatedString, str] = ""
max_datetime: Union[InterpolatedString, str] = ""
Expand Down
6 changes: 3 additions & 3 deletions airbyte_cdk/sources/file_based/file_types/csv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,22 +362,22 @@ def _cast_types(
else:
warnings.append(_format_warning(key, value, prop_type))

elif python_type == bool:
elif python_type is bool:
try:
cast_value = _value_to_bool(
value, config_format.true_values, config_format.false_values
)
except ValueError:
warnings.append(_format_warning(key, value, prop_type))

elif python_type == dict:
elif python_type is dict:
try:
# we don't re-use _value_to_object here because we type the column as object as long as there is only one object
cast_value = orjson.loads(value)
except orjson.JSONDecodeError:
warnings.append(_format_warning(key, value, prop_type))

elif python_type == list:
elif python_type is list:
try:
cast_value = _value_to_list(value)
except (ValueError, json.JSONDecodeError):
Expand Down
2 changes: 1 addition & 1 deletion airbyte_cdk/sources/file_based/file_types/excel_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def dtype_to_json_type(current_type: Optional[str], dtype: dtype_) -> str:
if current_type == "string":
# Previous column values were of the string type, no need to look further.
return current_type
if dtype == object:
if dtype is object:
return "string"
if dtype in number_types and (not current_type or current_type == "number"):
return "number"
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ skip = ["__init__.py"] # TODO: Remove after this is fixed: https://github.com/a
[tool.ruff]
exclude = ["__init__.py"] # TODO: Remove after this is fixed: https://github.com/airbytehq/airbyte-python-cdk/issues/12

# Setting python version to at least 3.10 avoids `from __future__ import annotations`.
target-version = "py310"
# This is consistent with airbytehq/airbyte root pyproject.toml Black rule defined.
line-length = 100

[tool.poe.tasks]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,35 +735,6 @@ def test_given_partition_completion_is_not_success_then_do_not_close_partition(s

assert self._an_open_partition.close.call_count == 0

def test_given_partition_completion_is_not_success_then_do_not_close_partition(self):
stream_instances_to_read_from = [self._stream, self._another_stream]

handler = ConcurrentReadProcessor(
stream_instances_to_read_from,
self._partition_enqueuer,
self._thread_pool_manager,
self._logger,
self._slice_logger,
self._message_repository,
self._partition_reader,
)

handler.start_next_partition_generator()
handler.on_partition(self._an_open_partition)
list(
handler.on_partition_generation_completed(
PartitionGenerationCompletedSentinel(self._stream)
)
)

list(
handler.on_partition_complete_sentinel(
PartitionCompleteSentinel(self._an_open_partition, not _IS_SUCCESSFUL)
)
)

assert self._an_open_partition.close.call_count == 0

def test_is_done_is_false_if_there_are_any_instances_to_read_from(self):
stream_instances_to_read_from = [self._stream]

Expand Down
9 changes: 0 additions & 9 deletions unit_tests/test/mock_http/test_mocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,6 @@ def decorated_function(http_mocker):
with pytest.raises(ValueError):
decorated_function()

def test_given_unknown_request_when_assert_number_of_calls_then_raise(self):
@HttpMocker()
def decorated_function(http_mocker):
http_mocker.get(HttpRequest(_A_URL), _A_RESPONSE)
http_mocker.assert_number_of_calls(HttpRequest(_ANOTHER_URL), 1)

with pytest.raises(ValueError):
decorated_function()

def test_given_request_already_mocked_when_decorate_then_raise(self):
with HttpMocker() as http_mocker:
a_request = HttpRequest(_A_URL, _SOME_QUERY_PARAMS, _SOME_HEADERS)
Expand Down
Loading