bots/followup: Use Python 3 type mypy annotations.
MODIFY
tools/run-mypy
tools/run-mypy
@@ -36,6 +36,8 @@ exclude = [
force_include = [
# Include bots that we migrate to mypy.
"zulip_bots/zulip_bots/bots/helloworld/helloworld.py",
+ "zulip_bots/zulip_bots/bots/followup/followup.py",
+ "zulip_bots/zulip_bots/bots/followup/test_followup.py",
]
parser = argparse.ArgumentParser(description="Run mypy on files tracked by git.")

MODIFY
zulip_bots/zulip_bots/bots/followup/followup.py
zulip_bots/zulip_bots/bots/followup/followup.py
# See readme.md for instructions on running this code.
+from typing import Dict, Any
class FollowupHandler(object):
'''
@@ -12,7 +13,7 @@ class FollowupHandler(object):
external issue tracker as well.
'''
- def usage(self):
+ def usage(self: Any) -> str:
return '''
This plugin will allow users to flag messages
as being follow-up items. Users should preface
@@ -22,7 +23,7 @@ class FollowupHandler(object):
called "followup" that your API user can send to.
'''
- def handle_message(self, message, bot_handler):
+ def handle_message(self: Any, message: Dict[str, str], bot_handler: Any) -> None:
if message['content'] == '':
bot_response = "Please specify the message you want to send to followup stream after @mention-bot"
bot_handler.send_reply(message, bot_response)
@@ -35,7 +36,7 @@ class FollowupHandler(object):
content=bot_response,
))
- def get_bot_followup_response(self, message):
+ def get_bot_followup_response(self: Any, message: Dict[str, str]) -> str:
original_content = message['content']
original_sender = message['sender_email']
temp_content = 'from %s: ' % (original_sender,)

MODIFY
zulip_bots/zulip_bots/bots/followup/test_followup.py
zulip_bots/zulip_bots/bots/followup/test_followup.py
@@ -5,10 +5,12 @@ from __future__ import print_function
from zulip_bots.test_lib import BotTestCase
+from typing import Any
+
class TestFollowUpBot(BotTestCase):
bot_name = "followup"
- def test_bot(self):
+ def test_bot(self: Any) -> None:
expected_send_reply = [
("", 'Please specify the message you want to send to followup stream after @mention-bot')
]

bots/followup: Use Python 3 type mypy annotations.