summaryrefslogtreecommitdiff
path: root/poezio/timed_events.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-07-22 14:23:39 +0200
committermathieui <mathieui@mathieui.net>2018-07-22 14:25:18 +0200
commite2414121af16474744d012cdb8466de6ae3136e4 (patch)
treee7d90b34da1d971e6e14cd8707837cab9200f0a3 /poezio/timed_events.py
parent3cb8e33f938db6bb6e86dd349f8b56676b83556f (diff)
downloadpoezio-e2414121af16474744d012cdb8466de6ae3136e4.tar.gz
poezio-e2414121af16474744d012cdb8466de6ae3136e4.tar.bz2
poezio-e2414121af16474744d012cdb8466de6ae3136e4.tar.xz
poezio-e2414121af16474744d012cdb8466de6ae3136e4.zip
Add type hints here and there
Diffstat (limited to 'poezio/timed_events.py')
-rw-r--r--poezio/timed_events.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/poezio/timed_events.py b/poezio/timed_events.py
index 5a5cadc2..3eeca2b3 100644
--- a/poezio/timed_events.py
+++ b/poezio/timed_events.py
@@ -12,7 +12,8 @@ Once created, they must be added to the list of checked events with
:py:func:`.PluginAPI.add_timed_event` (within a plugin).
"""
-import datetime
+from datetime import datetime
+from typing import Callable
class DelayedEvent:
@@ -21,7 +22,7 @@ class DelayedEvent:
Use it if you want an event to happen in, e.g. 6 seconds.
"""
- def __init__(self, delay, callback, *args):
+ def __init__(self, delay: int, callback: Callable, *args) -> None:
"""
Create a new DelayedEvent.
@@ -43,7 +44,7 @@ class TimedEvent(DelayedEvent):
The callback and its arguments should be passed as the lasts arguments.
"""
- def __init__(self, date, callback, *args):
+ def __init__(self, date: datetime, callback: Callable, *args) -> None:
"""
Create a new timed event.
@@ -51,6 +52,6 @@ class TimedEvent(DelayedEvent):
:param function callback: The handler that will be executed.
:param \*args: Optional arguments passed to the handler.
"""
- delta = date - datetime.datetime.now()
+ delta = date - datetime.now()
delay = delta.total_seconds()
DelayedEvent.__init__(self, delay, callback, *args)