mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user