Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Sep 11, 2024
1 parent 8bd62a2 commit 7c2dfaa
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tempora/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import bisect
import datetime
import numbers
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

from .utc import fromtimestamp as from_timestamp
from .utc import now
Expand All @@ -44,7 +44,7 @@ class DelayedCommand(datetime.datetime):
"""

delay: datetime.timedelta = datetime.timedelta()
target: datetime.timedelta = datetime.timedelta()
target: Any # Expected type depends on the scheduler used

@classmethod
def from_datetime(cls, other) -> Self:
Expand Down Expand Up @@ -171,8 +171,7 @@ class Scheduler:
def __init__(self) -> None:
self.queue: list[DelayedCommand] = []

def add(self, command) -> None:
assert isinstance(command, DelayedCommand)
def add(self, command: DelayedCommand) -> None:
bisect.insort(self.queue, command)

def run_pending(self) -> None:
Expand All @@ -186,7 +185,7 @@ def run_pending(self) -> None:
del self.queue[0]

@abc.abstractmethod
def run(self, command) -> None:
def run(self, command: DelayedCommand) -> None:
"""
Run the command
"""
Expand All @@ -197,7 +196,7 @@ class InvokeScheduler(Scheduler):
Command targets are functions to be invoked on schedule.
"""

def run(self, command) -> None:
def run(self, command: DelayedCommand) -> None:
command.target()


Expand All @@ -210,5 +209,5 @@ def __init__(self, dispatch) -> None:
super().__init__()
self.dispatch = dispatch

def run(self, command) -> None:
def run(self, command: DelayedCommand) -> None:
self.dispatch(command.target)

0 comments on commit 7c2dfaa

Please sign in to comment.