Skip to content

Commit

Permalink
Make methods private
Browse files Browse the repository at this point in the history
  • Loading branch information
benmezger committed May 3, 2024
1 parent 29faedc commit d62f0b7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pyretries/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __call__(
"""
raise NotImplementedError

def save_state(self, state: RetryState[ReturnT]) -> None:
def _save_state(self, state: RetryState[ReturnT]) -> None:
"""
Saves retry state to `func`
Expand All @@ -145,7 +145,7 @@ def save_state(self, state: RetryState[ReturnT]) -> None:
"""
setattr(state.func, "state", state)

def exec_strategy(self, state: RetryState[ReturnT]):
def _exec_strategy(self, state: RetryState[ReturnT]):
"""
Applies user defined strategies.
Expand Down Expand Up @@ -180,7 +180,7 @@ def exec_strategy(self, state: RetryState[ReturnT]):
except RetryStrategyExausted:
raise RetryExaustedError

def apply(self, state: RetryState[ReturnT]) -> bool:
def _apply(self, state: RetryState[ReturnT]) -> bool:
"""
Checks if last state raised an exception and executes the next available strategy
Expand All @@ -200,7 +200,7 @@ def apply(self, state: RetryState[ReturnT]) -> bool:
if (exc := state.exception.__class__) not in (self.on_exceptions or [exc]):
raise RetryExaustedError from state.exception

self.exec_strategy(state)
self._exec_strategy(state)
state.clear()
return True

Expand Down Expand Up @@ -251,7 +251,7 @@ class AsyncRetry(BaseRetry[ReturnT]):
>>> print(await retry(ok))
"""

async def exec(self, state: RetryState[ReturnT]) -> None:
async def _exec(self, state: RetryState[ReturnT]) -> None:
"""
Executes `func` from `state`
Expand Down Expand Up @@ -304,12 +304,12 @@ async def __call__( # type:ignore

should_reapply = True
while should_reapply:
await self.exec(state)
await self._exec(state)

if not (should_reapply := self.apply(state)):
if not (should_reapply := self._apply(state)):
break

self.save_state(state)
self._save_state(state)
return state.returned_value


Expand Down Expand Up @@ -372,10 +372,10 @@ def __call__(
while should_reapply:
self.exec(state)

if not (should_reapply := self.apply(state)):
if not (should_reapply := self._apply(state)):
break

self.save_state(state)
self._save_state(state)
return state.returned_value


Expand Down

0 comments on commit d62f0b7

Please sign in to comment.