mypy: Annotate bots/gcal-bot.
This commit is contained in:
parent
1ae8ac85d8
commit
836e3379c9
|
@ -11,6 +11,7 @@ import os
|
|||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../api'))
|
||||
import zulip
|
||||
from typing import List, Set, Tuple, Iterable, Optional
|
||||
|
||||
parser = optparse.OptionParser(r"""
|
||||
|
||||
|
@ -57,6 +58,7 @@ except ImportError:
|
|||
parser.error('Install python-gdata')
|
||||
|
||||
def get_calendar_url():
|
||||
# type: () -> str
|
||||
parts = urllib.parse.urlparse(options.calendar)
|
||||
pat = os.path.split(parts.path)
|
||||
if pat[1] != 'basic':
|
||||
|
@ -70,6 +72,7 @@ calendar_url = get_calendar_url()
|
|||
client = zulip.init_from_options(options)
|
||||
|
||||
def get_events():
|
||||
# type: () -> Iterable[Tuple[int, datetime.datetime, str]]
|
||||
feed = CalendarClient().GetCalendarEventFeed(uri=calendar_url)
|
||||
|
||||
for event in feed.entry:
|
||||
|
@ -80,12 +83,13 @@ def get_events():
|
|||
yield (event.uid.value, start, event.title.text)
|
||||
|
||||
# Our cached view of the calendar, updated periodically.
|
||||
events = []
|
||||
events = [] # type: List[Tuple[int, datetime.datetime, str]]
|
||||
|
||||
# Unique keys for events we've already sent, so we don't remind twice.
|
||||
sent = set()
|
||||
sent = set() # type: Set[Tuple[int, datetime.datetime]]
|
||||
|
||||
def send_reminders():
|
||||
# type: () -> Optional[None]
|
||||
global sent
|
||||
|
||||
messages = []
|
||||
|
|
Loading…
Reference in a new issue