From e2414121af16474744d012cdb8466de6ae3136e4 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 22 Jul 2018 14:23:39 +0200 Subject: Add type hints here and there --- poezio/timed_events.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'poezio/timed_events.py') 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) -- cgit v1.2.3