bots: Add mypy annotations for bots framework.

This commit adds mypy annotations for both the main
bots and the bots testing runner. It involves a change
to the BotHandlerApi send_message and update_message
funtions, which is compatible with every bot.

Tweaked by tabbott to use more expressive annotations.
This commit is contained in:
derAnfaenger
2017-05-26 06:58:19 +02:00
committed by Tim Abbott
parent c12023840d
commit 024101be6b
5 changed files with 54 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ import logging
import optparse
import os
import sys
from types import ModuleType
our_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, our_dir)
@@ -14,6 +15,7 @@ sys.path.insert(0, our_dir)
from bot_lib import run_message_handler_for_bot
def get_lib_module(bots_fn):
# type: (str) -> ModuleType
bots_fn = os.path.realpath(bots_fn)
if not os.path.dirname(bots_fn).startswith(os.path.join(our_dir, 'bots')):
print('Sorry, we will only import code from contrib_bots/bots.')
@@ -29,6 +31,7 @@ def get_lib_module(bots_fn):
return module
def run():
# type: () -> None
usage = '''
./run.py <lib file>
Example: ./run.py lib/followup.py