Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Mar 31, 2024
1 parent c271b79 commit 5d1e99d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions metronomes/metronome.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import escape
from emptylog import EmptyLogger, LoggerProtocol
from cantok import AbstractToken, SimpleToken
from locklib import ContextLockProtocol

from metronomes.errors import RunStoppedMetronomeError, RunAlreadyStartedMetronomeError, StopNotStartedMetronomeError, StopStoppedMetronomeError

Expand All @@ -14,15 +15,15 @@ def __init__(self, duration: Union[int, float], callback: Callable[[], Any], sup
if duration <= 0:
raise ValueError('The duration of the metronome iteration (tick-tock time) must be greater than zero.')

self.duration = duration
self.callback = callback
self.suppress_exceptions = suppress_exceptions
self.logger = logger
self.token = SimpleToken(cancellation_token) if cancellation_token is not None else SimpleToken()
self.thread = None
self.started = False
self.stopped = False
self.lock = Lock()
self.duration: Union[int, float] = duration
self.callback: Callable[[], Any] = callback
self.suppress_exceptions: bool = suppress_exceptions
self.logger: LoggerProtocol = logger
self.token: AbstractToken = SimpleToken(cancellation_token) if cancellation_token is not None else SimpleToken()
self.thread: Optional[Thread] = None
self.started: bool = False
self.stopped: bool = False
self.lock: ContextLockProtocol = Lock()

def start(self) -> None:
with self.lock:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies = [
'emptylog>=0.0.4',
'cantok>=0.0.22',
'escaping>=0.0.11',
'locklib>=0.0.14',
]
classifiers = [
'Operating System :: OS Independent',
Expand Down

0 comments on commit 5d1e99d

Please sign in to comment.