From 95b8ea4751294af3bdc0248951627c912940c876 Mon Sep 17 00:00:00 2001 From: Jerry Zhang Date: Wed, 6 Dec 2017 16:58:46 -0800 Subject: [PATCH] bots/followup: Use Python 3 type mypy annotations. --- tools/run-mypy | 2 ++ zulip_bots/zulip_bots/bots/followup/followup.py | 7 ++++--- zulip_bots/zulip_bots/bots/followup/test_followup.py | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/run-mypy b/tools/run-mypy index 001f888..2294ca2 100755 --- a/tools/run-mypy +++ b/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.") diff --git a/zulip_bots/zulip_bots/bots/followup/followup.py b/zulip_bots/zulip_bots/bots/followup/followup.py index dac5223..db95d75 100644 --- a/zulip_bots/zulip_bots/bots/followup/followup.py +++ b/zulip_bots/zulip_bots/bots/followup/followup.py @@ -1,4 +1,5 @@ # 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,) diff --git a/zulip_bots/zulip_bots/bots/followup/test_followup.py b/zulip_bots/zulip_bots/bots/followup/test_followup.py index f1e2216..600488b 100755 --- a/zulip_bots/zulip_bots/bots/followup/test_followup.py +++ b/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') ]