Skip to content

Commit

Permalink
Black 24
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jan 26, 2024
1 parent 5694d38 commit dc7f513
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ ci:

repos:
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.1.14
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
6 changes: 3 additions & 3 deletions src/stamina/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class _Config:

lock: Lock
_is_active: bool
_on_retry: tuple[RetryHook, ...] | tuple[
RetryHook | RetryHookFactory, ...
] | None
_on_retry: (
tuple[RetryHook, ...] | tuple[RetryHook | RetryHookFactory, ...] | None
)
_get_on_retry: Callable[[], tuple[RetryHook, ...]]

def __init__(self, lock: Lock) -> None:
Expand Down
32 changes: 20 additions & 12 deletions src/stamina/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,30 @@ def from_params(
_t_kw={
"retry": _t.retry_if_exception_type(on),
"wait": _t.wait_exponential_jitter(
initial=wait_initial.total_seconds()
if isinstance(wait_initial, dt.timedelta)
else wait_initial,
max=wait_max.total_seconds()
if isinstance(wait_max, dt.timedelta)
else wait_max,
initial=(
wait_initial.total_seconds()
if isinstance(wait_initial, dt.timedelta)
else wait_initial
),
max=(
wait_max.total_seconds()
if isinstance(wait_max, dt.timedelta)
else wait_max
),
exp_base=wait_exp_base,
jitter=wait_jitter.total_seconds()
if isinstance(wait_jitter, dt.timedelta)
else wait_jitter,
jitter=(
wait_jitter.total_seconds()
if isinstance(wait_jitter, dt.timedelta)
else wait_jitter
),
),
"stop": _make_stop(
attempts=attempts,
timeout=timeout.total_seconds()
if isinstance(timeout, dt.timedelta)
else timeout,
timeout=(
timeout.total_seconds()
if isinstance(timeout, dt.timedelta)
else timeout
),
),
"reraise": True,
},
Expand Down
3 changes: 1 addition & 2 deletions src/stamina/instrumentation/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ class RetryHook(Protocol):
.. versionadded:: 23.2.0
"""

def __call__(self, details: RetryDetails) -> None:
...
def __call__(self, details: RetryDetails) -> None: ...


@dataclass(frozen=True)
Expand Down
27 changes: 9 additions & 18 deletions tests/typing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,27 @@


@retry(on=ValueError)
def just_exc() -> None:
...
def just_exc() -> None: ...


@retry(on=TypeError)
async def just_exc_async() -> None:
...
async def just_exc_async() -> None: ...


@retry(on=TypeError, timeout=13.0)
def exc_timeout() -> None:
...
def exc_timeout() -> None: ...


@retry(on=TypeError, timeout=dt.timedelta(seconds=13.0))
def exc_timeout_timedelta() -> None:
...
def exc_timeout_timedelta() -> None: ...


@retry(on=TypeError, timeout=13.0, attempts=10)
def exc_timeout_attempts() -> None:
...
def exc_timeout_attempts() -> None: ...


@retry(on=TypeError, timeout=None, attempts=None)
def exc_timeout_attempts_none() -> None:
...
def exc_timeout_attempts_none() -> None: ...


@retry(
Expand All @@ -63,8 +57,7 @@ def exc_timeout_attempts_none() -> None:
wait_jitter=1.0,
wait_exp_base=2.0,
)
def exc_tune_waiting() -> None:
...
def exc_tune_waiting() -> None: ...


@retry(
Expand All @@ -74,8 +67,7 @@ def exc_tune_waiting() -> None:
wait_jitter=3,
wait_exp_base=4,
)
def exc_tune_waiting_ints() -> None:
...
def exc_tune_waiting_ints() -> None: ...


one_sec = dt.timedelta(seconds=1.0)
Expand All @@ -88,8 +80,7 @@ def exc_tune_waiting_ints() -> None:
wait_max=one_sec,
wait_jitter=one_sec,
)
def exc_tune_waiting_timedelta() -> None:
...
def exc_tune_waiting_timedelta() -> None: ...


set_active(False)
Expand Down

0 comments on commit dc7f513

Please sign in to comment.