Skip to content

Commit

Permalink
chore: Enable ARG Ruff checks (#1515)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Mar 21, 2023
1 parent fbbb293 commit aee57cc
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 61 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ select = [
"RET", # flake8-return
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"ARG", # flake8-unused-arguments
]
src = ["samples", "singer_sdk", "tests"]
target-version = "py37"
Expand Down
8 changes: 6 additions & 2 deletions samples/sample_tap_gitlab/gitlab_rest_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def authenticator(self) -> SimpleAuthenticator:

def get_url_params(
self,
context: dict | None,
context: dict | None, # noqa: ARG002
next_page_token: str | None,
) -> dict[str, Any]:
"""Return a dictionary of values to be used in URL parameterization."""
Expand Down Expand Up @@ -165,7 +165,11 @@ class EpicsStream(ProjectBasedStream):

# schema_filepath = SCHEMAS_DIR / "epics.json"

def get_child_context(self, record: dict, context: dict | None) -> dict:
def get_child_context(
self,
record: dict,
context: dict | None, # noqa: ARG002
) -> dict:
"""Perform post processing, including queuing up any child stream types."""
# Ensure child state record(s) are created
return {
Expand Down
4 changes: 2 additions & 2 deletions samples/sample_tap_google_analytics/ga_tap_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def authenticator(self) -> GoogleJWTAuthenticator:

def prepare_request_payload(
self,
context: dict | None,
next_page_token: Any | None,
context: dict | None, # noqa: ARG002
next_page_token: Any | None, # noqa: ARG002
) -> dict | None:
"""Prepare the data payload for the REST API request."""
# params = self.get_url_params(context, next_page_token)
Expand Down
5 changes: 4 additions & 1 deletion samples/sample_tap_hostile/hostile_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class HostilePropertyNamesStream(Stream):
def get_random_lowercase_string():
return "".join(random.choice(string.ascii_lowercase) for _ in range(10))

def get_records(self, context: dict | None) -> Iterable[dict | tuple[dict, dict]]:
def get_records(
self,
context: dict | None, # noqa: ARG002
) -> Iterable[dict | tuple[dict, dict]]:
return (
{
key: self.get_random_lowercase_string()
Expand Down
10 changes: 7 additions & 3 deletions singer_sdk/connectors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,11 @@ def _warn_no_view_detection(self) -> None:
"Streams list may be incomplete or `is_view` may be unpopulated.",
)

def get_schema_names(self, engine: Engine, inspected: Inspector) -> list[str]:
def get_schema_names(
self,
engine: Engine, # noqa: ARG002
inspected: Inspector,
) -> list[str]:
"""Return a list of schema names in DB.
Args:
Expand All @@ -353,7 +357,7 @@ def get_schema_names(self, engine: Engine, inspected: Inspector) -> list[str]:

def get_object_names(
self,
engine: Engine,
engine: Engine, # noqa: ARG002
inspected: Inspector,
schema_name: str,
) -> list[tuple[str, bool]]:
Expand All @@ -380,7 +384,7 @@ def get_object_names(
# TODO maybe should be splitted into smaller parts?
def discover_catalog_entry(
self,
engine: Engine,
engine: Engine, # noqa: ARG002
inspected: Inspector,
schema_name: str,
table_name: str,
Expand Down
2 changes: 1 addition & 1 deletion singer_sdk/helpers/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _is_string_with_format(type_dict):


def handle_invalid_timestamp_in_record(
record,
record, # noqa: ARG001
key_breadcrumb: list[str],
invalid_value: str,
datelike_typename: str,
Expand Down
4 changes: 2 additions & 2 deletions singer_sdk/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def transform(self, record: dict) -> None:
_ = record # Drop the record
return

def get_filter_result(self, record: dict) -> bool:
def get_filter_result(self, record: dict) -> bool: # noqa: ARG002
"""Exclude all records.
Args:
Expand All @@ -222,7 +222,7 @@ def transform(self, record: dict) -> dict | None:
"""
return super().transform(record)

def get_filter_result(self, record: dict) -> bool:
def get_filter_result(self, record: dict) -> bool: # noqa: ARG002
"""Return True (always include).
Args:
Expand Down
8 changes: 4 additions & 4 deletions singer_sdk/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def advance(self, response: Response) -> None:
else:
self._value = new_value

def has_more(self, response: Response) -> bool:
def has_more(self, response: Response) -> bool: # noqa: ARG002
"""Override this method to check if the endpoint has any pages left.
Args:
Expand Down Expand Up @@ -160,7 +160,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
super().__init__(None, *args, **kwargs)

def get_next(self, response: Response) -> None:
def get_next(self, response: Response) -> None: # noqa: ARG002
"""Get the next pagination token or index from the API response.
Args:
Expand Down Expand Up @@ -345,7 +345,7 @@ def has_more(self, response: Response) -> bool:
"""
...

def get_next(self, response: Response) -> int | None:
def get_next(self, response: Response) -> int | None: # noqa: ARG002
"""Get the next page number.
Args:
Expand Down Expand Up @@ -390,7 +390,7 @@ def has_more(self, response: Response) -> bool:
"""
...

def get_next(self, response: Response) -> int | None:
def get_next(self, response: Response) -> int | None: # noqa: ARG002
"""Get the next page offset.
Args:
Expand Down
2 changes: 1 addition & 1 deletion singer_sdk/sinks/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class BatchSink(Sink):
"""Base class for batched record writers."""

def _get_context(self, record: dict) -> dict:
def _get_context(self, record: dict) -> dict: # noqa: ARG002
"""Return a batch context. If no batch is active, return a new batch context.
The SDK-generated context will contain `batch_id` (GUID string) and
Expand Down
4 changes: 2 additions & 2 deletions singer_sdk/sinks/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(

self._validator = Draft7Validator(schema, format_checker=FormatChecker())

def _get_context(self, record: dict) -> dict:
def _get_context(self, record: dict) -> dict: # noqa: ARG002
"""Return an empty dictionary by default.
NOTE: Future versions of the SDK may expand the available context attributes.
Expand Down Expand Up @@ -358,7 +358,7 @@ def _after_process_record(self, context: dict) -> None:

# SDK developer overrides:

def preprocess_record(self, record: dict, context: dict) -> dict:
def preprocess_record(self, record: dict, context: dict) -> dict: # noqa: ARG002
"""Process incoming record and return a modified result.
Args:
Expand Down
2 changes: 1 addition & 1 deletion singer_sdk/sinks/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RecordSink(Sink):

current_size = 0 # Records are always written directly

def _after_process_record(self, context: dict) -> None:
def _after_process_record(self, context: dict) -> None: # noqa: ARG002
"""Perform post-processing and record keeping. Internal hook.
The RecordSink class uses this method to tally each record written.
Expand Down
6 changes: 5 additions & 1 deletion singer_sdk/sinks/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ def full_schema_name(self) -> str:
db_name=self.database_name,
)

def conform_name(self, name: str, object_type: str | None = None) -> str:
def conform_name(
self,
name: str,
object_type: str | None = None, # noqa: ARG002
) -> str:
"""Conform a stream property name to one suitable for the target system.
Transforms names to snake case by default, applicable to most common DBMSs'.
Expand Down
8 changes: 6 additions & 2 deletions singer_sdk/streams/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def _write_starting_replication_value(self, context: dict | None) -> None:

def get_replication_key_signpost(
self,
context: dict | None,
context: dict | None, # noqa: ARG002
) -> datetime.datetime | Any | None:
"""Get the replication signpost.
Expand Down Expand Up @@ -1290,7 +1290,11 @@ def get_batches(

yield batch_config.encoding, [file_url]

def post_process(self, row: dict, context: dict | None = None) -> dict | None:
def post_process(
self,
row: dict,
context: dict | None = None, # noqa: ARG002
) -> dict | None:
"""As needed, append or transform raw data to match expected structure.
Optional. This method gives developers an opportunity to "clean up" the results
Expand Down
14 changes: 7 additions & 7 deletions singer_sdk/streams/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ def _request(

def get_url_params(
self,
context: dict | None,
next_page_token: _TToken | None,
context: dict | None, # noqa: ARG002
next_page_token: _TToken | None, # noqa: ARG002
) -> dict[str, Any]:
"""Return a dictionary of values to be used in URL parameterization.
Expand Down Expand Up @@ -371,7 +371,7 @@ def request_records(self, context: dict | None) -> Iterable[dict]:

def _write_request_duration_log(
self,
endpoint: str,
endpoint: str, # noqa: ARG002
response: requests.Response,
context: dict | None,
extra_tags: dict | None,
Expand All @@ -394,7 +394,7 @@ def _write_request_duration_log(
value=response.elapsed.total_seconds(),
tags={
metrics.Tag.STREAM: self.name,
metrics.Tag.ENDPOINT: self.path,
metrics.Tag.ENDPOINT: endpoint,
metrics.Tag.HTTP_STATUS_CODE: response.status_code,
metrics.Tag.STATUS: (
metrics.Status.SUCCEEDED
Expand Down Expand Up @@ -433,9 +433,9 @@ def update_sync_costs(

def calculate_sync_cost(
self,
request: requests.PreparedRequest,
response: requests.Response,
context: dict | None,
request: requests.PreparedRequest, # noqa: ARG002
response: requests.Response, # noqa: ARG002
context: dict | None, # noqa: ARG002
) -> dict[str, int]:
"""Calculate the cost of the last API call made.
Expand Down
4 changes: 2 additions & 2 deletions singer_sdk/testing/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def _test_replication_keys_in_schema() -> None:


def get_standard_target_tests(
target_class: type[Target],
config: dict | None = None,
target_class: type[Target], # noqa: ARG001
config: dict | None = None, # noqa: ARG001
) -> list[Callable]:
"""Return callable pytest which executes simple discovery and connection tests.
Expand Down
4 changes: 2 additions & 2 deletions singer_sdk/testing/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def run_connection_test(self) -> bool:
"""
return self.tap.run_connection_test()

def sync_all(self, **kwargs: Any) -> None:
def sync_all(self, **kwargs: Any) -> None: # noqa: ARG002
"""Run a full tap sync, assigning output to the runner object.
Args:
Expand Down Expand Up @@ -240,7 +240,7 @@ def input(self) -> IO[str]:
def input(self, value: IO[str]) -> None:
self._input = value

def sync_all(self, finalize: bool = True, **kwargs: Any) -> None:
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 Down
24 changes: 12 additions & 12 deletions singer_sdk/testing/tap_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def test(self) -> None:
@classmethod
def evaluate(
cls,
stream: Stream,
property_name: str,
stream: Stream, # noqa: ARG003
property_name: str, # noqa: ARG003
property_schema: dict,
) -> bool:
"""Determine if this attribute test is applicable to the given property.
Expand Down Expand Up @@ -189,8 +189,8 @@ def test(self) -> None:
@classmethod
def evaluate(
cls,
stream: Stream,
property_name: str,
stream: Stream, # noqa: ARG003
property_name: str, # noqa: ARG003
property_schema: dict,
) -> bool:
"""Determine if this attribute test is applicable to the given property.
Expand Down Expand Up @@ -219,8 +219,8 @@ def test(self) -> None:
@classmethod
def evaluate(
cls,
stream: Stream,
property_name: str,
stream: Stream, # noqa: ARG003
property_name: str, # noqa: ARG003
property_schema: dict,
) -> bool:
"""Determine if this attribute test is applicable to the given property.
Expand Down Expand Up @@ -252,8 +252,8 @@ def test(self) -> None:
@classmethod
def evaluate(
cls,
stream: Stream,
property_name: str,
stream: Stream, # noqa: ARG003
property_name: str, # noqa: ARG003
property_schema: dict,
) -> bool:
"""Determine if this attribute test is applicable to the given property.
Expand Down Expand Up @@ -290,8 +290,8 @@ def test(self) -> None:
@classmethod
def evaluate(
cls,
stream: Stream,
property_name: str,
stream: Stream, # noqa: ARG003
property_name: str, # noqa: ARG003
property_schema: dict,
) -> bool:
"""Determine if this attribute test is applicable to the given property.
Expand Down Expand Up @@ -322,8 +322,8 @@ def test(self) -> None:
@classmethod
def evaluate(
cls,
stream: Stream,
property_name: str,
stream: Stream, # noqa: ARG003
property_name: str, # noqa: ARG003
property_schema: dict,
) -> bool:
"""Determine if this attribute test is applicable to the given property.
Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def clone_and_alias_stream_maps():


@pytest.fixture
def cloned_and_aliased_result(stream_map_config, sample_stream):
def cloned_and_aliased_result(sample_stream):
return {
"repositories_aliased": sample_stream["repositories"],
"repositories_clone_1": sample_stream["repositories"],
Expand Down Expand Up @@ -419,7 +419,7 @@ class MappedStream(Stream):
),
).to_dict()

def get_records(self, context):
def get_records(self, context): # noqa: ARG002
yield {
"email": "[email protected]",
"count": 21,
Expand Down
Loading

0 comments on commit aee57cc

Please sign in to comment.