Skip to content

Commit

Permalink
chore: Enable FBT Ruff checks (#1599)
Browse files Browse the repository at this point in the history
`flake8-boolean-trap`
  • Loading branch information
edgarrmondragon authored Apr 11, 2023
1 parent 0948c77 commit 21d0a14
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 17 deletions.
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ select = [
"ANN", # flake8-annotations
"S", # flake8-bandit
"BLE", # flake8-blind-except
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
Expand Down Expand Up @@ -271,7 +272,7 @@ target-version = "py37"
"INP001", # flake8-no-pep420: implicit-namespace-package
]
"noxfile.py" = ["ANN"]
"tests/*" = ["ANN", "D1", "D2", "PLR2004", "S101"]
"tests/*" = ["ANN", "D1", "D2", "FBT001", "FBT003", "PLR2004", "S101"]
# Disabled some checks in samples code
"samples/*" = ["ANN", "D"]
# Don't require docstrings conventions or type annotations in private modules
Expand Down
1 change: 1 addition & 0 deletions samples/sample_mapper/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class StreamTransform(InlineMapper):

def __init__(
self,
*,
config: dict | PurePath | str | list[PurePath | str] | None = None,
parse_env_config: bool = False,
validate_config: bool = True,
Expand Down
6 changes: 3 additions & 3 deletions singer_sdk/connectors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def discover_catalog_entry(
inspected: Inspector,
schema_name: str,
table_name: str,
is_view: bool,
is_view: bool, # noqa: FBT001
) -> CatalogEntry:
"""Create `CatalogEntry` object for the given table or a view.
Expand Down Expand Up @@ -647,7 +647,7 @@ def create_empty_table(
schema: dict,
primary_keys: list[str] | None = None,
partition_keys: list[str] | None = None,
as_temp_table: bool = False,
as_temp_table: bool = False, # noqa: FBT001, FBT002
) -> None:
"""Create an empty target table.
Expand Down Expand Up @@ -733,7 +733,7 @@ def prepare_table(
schema: dict,
primary_keys: list[str],
partition_keys: list[str] | None = None,
as_temp_table: bool = False,
as_temp_table: bool = False, # noqa: FBT002, FBT001
) -> None:
"""Adapt target table to provided schema if possible.
Expand Down
1 change: 1 addition & 0 deletions singer_sdk/helpers/_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def deselect_all_streams(catalog: Catalog) -> None:
def set_catalog_stream_selected(
catalog: Catalog,
stream_name: str,
*,
selected: bool,
breadcrumb: tuple[str, ...] | None = None,
) -> None:
Expand Down
1 change: 1 addition & 0 deletions singer_sdk/helpers/_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def get_starting_replication_value(stream_or_partition_state: dict):

def increment_state(
stream_or_partition_state: dict,
*,
latest_record: dict,
replication_key: str,
is_sorted: bool,
Expand Down
1 change: 1 addition & 0 deletions singer_sdk/mapper_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def cli(cls) -> Callable: # noqa: N805
context_settings={"help_option_names": ["--help"]},
)
def cli(
*,
version: bool = False,
about: bool = False,
config: tuple[str, ...] = (),
Expand Down
2 changes: 2 additions & 0 deletions singer_sdk/plugin_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def logger(cls) -> logging.Logger: # noqa: N805

def __init__(
self,
*,
config: dict | PurePath | str | list[PurePath | str] | None = None,
parse_env_config: bool = False,
validate_config: bool = True,
Expand Down Expand Up @@ -237,6 +238,7 @@ def _is_secret_config(config_key: str) -> bool:

def _validate_config(
self,
*,
raise_errors: bool = True,
warnings_as_errors: bool = False,
) -> tuple[list[str], list[str]]:
Expand Down
1 change: 1 addition & 0 deletions singer_sdk/streams/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ def _process_record(
def _sync_records(
self,
context: dict | None = None,
*,
write_messages: bool = True,
) -> Generator[dict, Any, Any]:
"""Sync records, emitting RECORD and STATE messages.
Expand Down
3 changes: 3 additions & 0 deletions singer_sdk/tap_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Tap(PluginBase, metaclass=abc.ABCMeta):

def __init__(
self,
*,
config: dict | PurePath | str | list[PurePath | str] | None = None,
catalog: PurePath | str | dict | Catalog | None = None,
state: PurePath | str | dict | None = None,
Expand Down Expand Up @@ -463,6 +464,7 @@ def cli(cls) -> Callable: # noqa: N805
context_settings={"help_option_names": ["--help"]},
)
def cli(
*,
version: bool = False,
about: bool = False,
discover: bool = False,
Expand Down Expand Up @@ -550,6 +552,7 @@ class SQLTap(Tap):

def __init__(
self,
*,
config: dict | PurePath | str | list[PurePath | str] | None = None,
catalog: PurePath | str | dict | None = None,
state: PurePath | str | dict | None = None,
Expand Down
4 changes: 3 additions & 1 deletion singer_sdk/target_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Target(PluginBase, SingerReader, metaclass=abc.ABCMeta):

def __init__(
self,
*,
config: dict | PurePath | str | list[PurePath | str] | None = None,
parse_env_config: bool = False,
validate_config: bool = True,
Expand Down Expand Up @@ -441,7 +442,7 @@ def _process_batch_message(self, message_dict: dict) -> None:
# Sink drain methods

@final
def drain_all(self, is_endofpipe: bool = False) -> None:
def drain_all(self, *, is_endofpipe: bool = False) -> None:
"""Drains all sinks, starting with those cleared due to changed schema.
This method is internal to the SDK and should not need to be overridden.
Expand Down Expand Up @@ -524,6 +525,7 @@ def cli(cls) -> Callable: # noqa: N805
context_settings={"help_option_names": ["--help"]},
)
def cli(
*,
version: bool = False,
about: bool = False,
config: tuple[str, ...] = (),
Expand Down
2 changes: 2 additions & 0 deletions singer_sdk/testing/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def tap_sync_test(tap: Tap) -> tuple[io.StringIO, io.StringIO]:
def _get_tap_catalog(
tap_class: type[Tap],
config: dict,
*,
select_all: bool = False,
) -> dict:
"""Return a catalog dict by running discovery.
Expand Down Expand Up @@ -174,6 +175,7 @@ def _select_all(catalog_dict: dict) -> dict:
def target_sync_test(
target: Target,
input: io.StringIO | None, # noqa: A002
*,
finalize: bool = True,
) -> tuple[io.StringIO, io.StringIO]:
"""Invoke the target with the provided input.
Expand Down
3 changes: 2 additions & 1 deletion singer_sdk/testing/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def target_input(self) -> IO[str]:
def target_input(self, value: IO[str]) -> None:
self._input = value

def sync_all(self, finalize: bool = True, **kwargs: Any) -> None: # noqa: ARG002
def sync_all(self, *, finalize: bool = True, **kwargs: Any) -> None: # noqa: ARG002
"""Run a full tap sync, assigning output to the runner object.
Args:
Expand All @@ -270,6 +270,7 @@ def _execute_sync(
self,
target: Target,
target_input: IO[str],
*,
finalize: bool = True,
) -> tuple[io.StringIO, io.StringIO]:
"""Invoke the target with the provided input.
Expand Down
4 changes: 2 additions & 2 deletions singer_sdk/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,10 @@ def __init__(
self,
name: str,
wrapped: W | type[W],
required: bool = False,
required: bool = False, # noqa: FBT001, FBT002
default: _JsonValue | None = None,
description: str | None = None,
secret: bool | None = False,
secret: bool | None = False, # noqa: FBT002
allowed_values: list[Any] | None = None,
examples: list[Any] | None = None,
) -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/core/test_jsonschema_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ def test_array_type():
pytest.param(
ObjectType(
Property("id", StringType),
Property("email", StringType, True),
Property("email", StringType, True),
Property("username", StringType, True),
Property("email", StringType, required=True),
Property("email", StringType, required=True),
Property("username", StringType, required=True),
Property("phone_number", StringType),
additional_properties=False,
),
Expand Down
6 changes: 3 additions & 3 deletions tests/samples/test_target_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ def sqlite_target_test_config(path_to_target_db: str) -> dict:
@pytest.fixture
def sqlite_sample_target(sqlite_target_test_config):
"""Get a sample target object."""
return SQLiteTarget(sqlite_target_test_config)
return SQLiteTarget(config=sqlite_target_test_config)


@pytest.fixture
def sqlite_sample_target_soft_delete(sqlite_target_test_config):
"""Get a sample target object with hard_delete disabled."""
return SQLiteTarget({**sqlite_target_test_config, "hard_delete": False})
return SQLiteTarget(config={**sqlite_target_test_config, "hard_delete": False})


@pytest.fixture
def sqlite_sample_target_batch(sqlite_target_test_config):
"""Get a sample target object with hard_delete disabled."""
conf = sqlite_target_test_config

return SQLiteTarget(conf)
return SQLiteTarget(config=conf)


# SQLite Target Tests
Expand Down

0 comments on commit 21d0a14

Please sign in to comment.