Skip to content

Commit

Permalink
mypy fixes round 1
Browse files Browse the repository at this point in the history
  • Loading branch information
BuzzCutNorman committed Jul 25, 2023
1 parent 66f750e commit 62c2c32
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
14 changes: 7 additions & 7 deletions singer_sdk/helpers/_perftimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class PerfTimerError(Exception):
class PerfTimer:
"""A Basic Performance Timer Class."""

_start_time: float = None
_stop_time: float = None
_lap_time: float = None
_start_time: float | None = None
_stop_time: float | None = None
_lap_time: float | None = None

@property
def start_time(self):
Expand Down Expand Up @@ -52,11 +52,11 @@ class BatchPerfTimer(PerfTimer):

def __init__(
self,
max_size: int | None = None,
max_perf_counter: float = 1,
max_size: int,
max_perf_counter: float,
) -> None:
self._sink_max_size: int = max_size
self._max_perf_counter = max_perf_counter
self._max_perf_counter: float = max_perf_counter

SINK_MAX_SIZE_CELING: int = 100000
"""The max size a bulk insert can be"""
Expand Down Expand Up @@ -86,7 +86,7 @@ def perf_diff(self) -> float:
"""Difference between wanted elapsed time and actual elpased time."""
if self._lap_time:
return self.max_perf_counter - self.lap_time
return None
return float(0)

def counter_based_max_size(self) -> int: # noqa: C901
"""Caclulate performance based batch size."""
Expand Down
11 changes: 6 additions & 5 deletions singer_sdk/sinks/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ def __init__(
self._batch_wait_limit_seconds: int | None = target.config.get(
"batch_wait_limit_seconds",
)
self._sink_timer: BatchSink | None = None

self._sink_timer: BatchPerfTimer | None = None

if self._batch_wait_limit_seconds is not None:
self._batch_size_rows = 100
self._sink_timer: BatchPerfTimer | None = BatchPerfTimer(
self._sink_timer = BatchPerfTimer(
self._batch_size_rows,
self._batch_wait_limit_seconds,
)
Expand Down Expand Up @@ -105,7 +106,7 @@ def batch_size_rows(self, new_value: int) -> None:
self._batch_size_rows = new_value

@property
def batch_wait_limit_seconds(self) -> int:
def batch_wait_limit_seconds(self) -> int | None:
"""Get batch_wait_limit_seconds object.
Returns:
Expand All @@ -114,11 +115,11 @@ def batch_wait_limit_seconds(self) -> int:
return self._batch_wait_limit_seconds

@property
def sink_timer(self) -> BatchPerfTimer:
def sink_timer(self) -> BatchPerfTimer | None:
"""Get sink_timer object.
Returns:
A sink_timer object of type BatchPerfTimer.
A sink_timer object.
"""
return self._sink_timer

Expand Down

0 comments on commit 62c2c32

Please sign in to comment.