Skip to content

Commit

Permalink
style: satisfy black formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Jun 16, 2024
1 parent 0e117cd commit a1110e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion sardine_core/handlers/sleep_handler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _check_running(self):
self._poll_task.cancel()

def _create_handle(self, deadline: NUMBER) -> TimeHandle:
#TODO: document this function
# TODO: document this function
handle = TimeHandle(deadline)

if self.env.clock.time >= deadline:
Expand Down
2 changes: 1 addition & 1 deletion sardine_core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def decorator(func: Union[Callable, AsyncRunner], /) -> AsyncRunner:
else:
runner.push_deferred(deadline, func, *args, **kwargs)

# Intentionally avoid interval correction so the user doesn't
# Intentionally avoid interval correction so the user doesn't
# accidentally nudge the runner
runner.swim()
runner.reload()
Expand Down
31 changes: 16 additions & 15 deletions sardine_core/scheduler/async_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,9 @@ async def _runner(self):
"""

# Query time position
current_beat = self.scheduler.env.clock.beat % self.scheduler.env.clock.beats_per_bar
current_bar = self.scheduler.env.clock.bar
current_phase = self.scheduler.env.clock.phase
current_beat = self.clock.beat % self.clock.beats_per_bar
current_bar = self.clock.bar
current_phase = self.clock.phase

# Preparing the runner for an incoming iteration
try:
Expand Down Expand Up @@ -637,7 +637,7 @@ def _prepare(self):
# Extract period from state
period = self._get_period(self._last_state)

self._last_interval = (period * self.clock.beat_duration)
self._last_interval = period * self.clock.beat_duration

async def _run_once(self) -> None:
"""
Expand Down Expand Up @@ -756,10 +756,15 @@ def _get_period(self, state: Optional[FunctionState]) -> Union[float, int]:
Union[float, int]: The period to use for the next iteration.
"""
# If we don't have a state, we can't extract a period given by the user
if state is None:
return 0.0

# Extract the period from the state or assign default period if missing
return _extract_new_period(
inspect.signature(state.func), state.kwargs, self.period
) if state is not None else 0.0
inspect.signature(state.func),
state.kwargs,
self.period,
)

def _get_state(self) -> Optional[FunctionState]:
"""
Expand Down Expand Up @@ -789,19 +794,15 @@ def _maybe_print_new_state(self, state: FunctionState) -> None:
a new state has been pushed. It will print a message to the console indicating
how well the runner is doing (update or saved from crash).
"""
current_beat = self.scheduler.env.clock.beat % self.scheduler.env.clock.beats_per_bar
current_bar = self.scheduler.env.clock.bar
current_phase = self.scheduler.env.clock.phase
current_beat = self.clock.beat % self.clock.beats_per_bar
current_bar = self.clock.bar
current_phase = self.clock.phase

if self._last_state is not None and state is not self._last_state:
if not self._has_reverted:
print(
f"[yellow][Updating [red]{self.name}[/red]]"
)
print(f"[yellow][Updating [red]{self.name}[/red]]")
else:
print(
f"[yellow][Saving [red]{self.name}[/red] from crash]"
)
print(f"[yellow][Saving [red]{self.name}[/red] from crash]")
self._has_reverted = False

async def _sleep_until(self, deadline: Union[float, int]) -> bool:
Expand Down

0 comments on commit a1110e9

Please sign in to comment.